44
55use App \Enums \PluginStatus ;
66use App \Features \AllowPaidPlugins ;
7- use App \Jobs \ReviewPluginRepository ;
87use App \Models \Plugin ;
9- use App \Notifications \PluginSubmitted ;
108use App \Services \GitHubUserService ;
119use App \Services \PluginSyncService ;
1210use Illuminate \Support \Facades \Cache ;
1715use Livewire \Component ;
1816
1917#[Layout('components.layouts.dashboard ' )]
20- #[Title('Submit Your Plugin ' )]
18+ #[Title('Create Your Plugin ' )]
2119class Create extends Component
2220{
2321 public string $ pluginType = 'free ' ;
@@ -26,10 +24,6 @@ class Create extends Component
2624
2725 public string $ repository = '' ;
2826
29- public string $ notes = '' ;
30-
31- public string $ supportChannel = '' ;
32-
3327 /** @var array<int, array{id: int, full_name: string, name: string, owner: string, private: bool}> */
3428 public array $ repositories = [];
3529
@@ -113,12 +107,12 @@ public function loadRepositories(): void
113107 $ this ->loadingRepos = false ;
114108 }
115109
116- public function submitPlugin (PluginSyncService $ syncService ): void
110+ public function createPlugin (PluginSyncService $ syncService ): void
117111 {
118112 $ user = auth ()->user ();
119113
120114 if (! $ user ->github_id ) {
121- $ this ->addError ('repository ' , 'You must connect your GitHub account to submit a plugin. ' );
115+ $ this ->addError ('repository ' , 'You must connect your GitHub account to create a plugin. ' );
122116
123117 return ;
124118 }
@@ -132,26 +126,14 @@ public function submitPlugin(PluginSyncService $syncService): void
132126 function ($ attribute , $ value , $ fail ): void {
133127 $ url = 'https://github.com/ ' .trim ($ value , '/ ' );
134128 if (Plugin::where ('repository_url ' , $ url )->exists ()) {
135- $ fail ('This repository has already been submitted . ' );
129+ $ fail ('A plugin for this repository already exists . ' );
136130 }
137131 },
138132 ],
139133 'pluginType ' => ['required ' , 'string ' , 'in:free,paid ' ],
140- 'notes ' => ['nullable ' , 'string ' , 'max:5000 ' ],
141- 'supportChannel ' => [
142- 'required ' ,
143- 'string ' ,
144- 'max:255 ' ,
145- function (string $ attribute , mixed $ value , \Closure $ fail ) {
146- if (! filter_var ($ value , FILTER_VALIDATE_EMAIL ) && ! filter_var ($ value , FILTER_VALIDATE_URL )) {
147- $ fail ('The support channel must be a valid email address or URL. ' );
148- }
149- },
150- ],
151134 ], [
152135 'repository.required ' => 'Please select a repository for your plugin. ' ,
153136 'repository.regex ' => 'Please enter a valid repository in the format vendor/repo-name. ' ,
154- 'supportChannel.required ' => 'Please provide a support channel (email or URL) for your plugin. ' ,
155137 ]);
156138
157139 if ($ this ->pluginType === 'paid ' && ! Feature::active (AllowPaidPlugins::class)) {
@@ -195,31 +177,12 @@ function (string $attribute, mixed $value, \Closure $fail) {
195177 $ plugin = $ user ->plugins ()->create ([
196178 'repository_url ' => $ repositoryUrl ,
197179 'type ' => $ this ->pluginType ,
198- 'status ' => PluginStatus::Pending ,
180+ 'status ' => PluginStatus::Draft ,
199181 'developer_account_id ' => $ developerAccountId ,
200- 'notes ' => $ this ->notes ?: null ,
201- 'support_channel ' => $ this ->supportChannel ?: null ,
202182 ]);
203183
204- $ webhookSecret = $ plugin ->generateWebhookSecret ();
205-
206- $ webhookInstalled = false ;
207- if ($ user ->hasGitHubToken ()) {
208- $ webhookResult = $ githubService ->createWebhook (
209- $ owner ,
210- $ repo ,
211- $ plugin ->getWebhookUrl (),
212- $ webhookSecret
213- );
214- $ webhookInstalled = $ webhookResult ['success ' ];
215- }
216-
217- $ plugin ->update (['webhook_installed ' => $ webhookInstalled ]);
218-
219184 $ syncService ->sync ($ plugin );
220185
221- (new ReviewPluginRepository ($ plugin ))->handle ();
222-
223186 if (! $ plugin ->name ) {
224187 $ plugin ->delete ();
225188
@@ -228,21 +191,14 @@ function (string $attribute, mixed $value, \Closure $fail) {
228191 return ;
229192 }
230193
231- $ user ->notify (new PluginSubmitted ($ plugin ));
232-
233- $ successMessage = 'Your plugin has been submitted for review! ' ;
234- if (! $ webhookInstalled ) {
235- $ successMessage .= ' Please set up the webhook manually to enable automatic syncing. ' ;
236- }
237-
238194 [$ vendor , $ package ] = explode ('/ ' , $ plugin ->name );
239195
240196 $ this ->redirect (
241197 route ('customer.plugins.show ' , ['vendor ' => $ vendor , 'package ' => $ package ]),
242198 navigate: true
243199 );
244200
245- session ()->flash ('success ' , $ successMessage );
201+ session ()->flash ('success ' , ' Your plugin has been created as a draft. You can edit it and submit for review when ready. ' );
246202 }
247203
248204 public function render ()
0 commit comments