|
14 | 14 | use Filament\Forms; |
15 | 15 | use Filament\Notifications\Notification; |
16 | 16 | use Filament\Resources\Pages\EditRecord; |
| 17 | +use Illuminate\Support\Facades\Log; |
17 | 18 | use Illuminate\Support\HtmlString; |
18 | 19 |
|
19 | 20 | class EditPlugin extends EditRecord |
@@ -230,21 +231,46 @@ protected function getHeaderActions(): array |
230 | 231 | ->modalHeading('Re-sync Plugin') |
231 | 232 | ->modalDescription(fn () => "This will re-fetch the README, composer.json, nativephp.json, license, and latest version from GitHub for '{$this->record->name}'.") |
232 | 233 | ->action(function (): void { |
233 | | - $syncService = app(PluginSyncService::class); |
234 | | - $result = $syncService->sync($this->record); |
| 234 | + Log::info('[Filament:Resync] Action triggered', [ |
| 235 | + 'plugin_id' => $this->record->id, |
| 236 | + 'name' => $this->record->name, |
| 237 | + 'repository_url' => $this->record->repository_url, |
| 238 | + ]); |
235 | 239 |
|
236 | | - $this->record->refresh(); |
| 240 | + try { |
| 241 | + $syncService = app(PluginSyncService::class); |
| 242 | + $result = $syncService->sync($this->record); |
| 243 | + |
| 244 | + Log::info('[Filament:Resync] Sync returned', [ |
| 245 | + 'plugin_id' => $this->record->id, |
| 246 | + 'result' => $result, |
| 247 | + ]); |
| 248 | + |
| 249 | + $this->record->refresh(); |
| 250 | + |
| 251 | + if ($result) { |
| 252 | + Notification::make() |
| 253 | + ->title('Plugin synced successfully') |
| 254 | + ->body("README, versions, and metadata have been updated for '{$this->record->name}'.") |
| 255 | + ->success() |
| 256 | + ->send(); |
| 257 | + } else { |
| 258 | + Notification::make() |
| 259 | + ->title('Sync failed') |
| 260 | + ->body('Could not fetch repository data. Check the repository URL and try again.') |
| 261 | + ->danger() |
| 262 | + ->send(); |
| 263 | + } |
| 264 | + } catch (\Throwable $e) { |
| 265 | + Log::error('[Filament:Resync] Exception', [ |
| 266 | + 'plugin_id' => $this->record->id, |
| 267 | + 'error' => $e->getMessage(), |
| 268 | + 'trace' => $e->getTraceAsString(), |
| 269 | + ]); |
237 | 270 |
|
238 | | - if ($result) { |
239 | | - Notification::make() |
240 | | - ->title('Plugin synced successfully') |
241 | | - ->body("README, versions, and metadata have been updated for '{$this->record->name}'.") |
242 | | - ->success() |
243 | | - ->send(); |
244 | | - } else { |
245 | 271 | Notification::make() |
246 | | - ->title('Sync failed') |
247 | | - ->body('Could not fetch repository data. Check the repository URL and try again.') |
| 272 | + ->title('Sync error') |
| 273 | + ->body($e->getMessage()) |
248 | 274 | ->danger() |
249 | 275 | ->send(); |
250 | 276 | } |
|
0 commit comments