components([ Select::make('provider') ->label(__('panel.repositories.fields.provider')) ->options(GitProvider::class) ->default(GitProvider::default()) ->required() ->disableOptionWhen(fn (string $value) => ! GitProvider::from($value)->isSupported()), TextInput::make('full_name') ->label(__('panel.repositories.fields.full_name')) ->placeholder('colectivo/mi-proyecto') ->helperText(__('panel.repositories.fields.full_name_hint')) ->required() ->maxLength(255), Toggle::make('is_primary') ->label(__('panel.repositories.fields.is_primary')), Toggle::make('show_publicly') ->label(__('panel.repositories.fields.show_publicly')) ->default(true), ]); } public function table(Table $table): Table { return $table ->recordTitleAttribute('full_name') ->columns([ TextColumn::make('full_name') ->label(__('panel.repositories.fields.full_name')) ->url(fn (Repository $r) => $r->html_url, shouldOpenInNewTab: true), TextColumn::make('primary_language') ->label(__('panel.repositories.fields.language')) ->badge() ->placeholder('—'), TextColumn::make('stars')->label('★')->badge()->color('warning'), TextColumn::make('good_first_issues_count') ->label(__('panel.repositories.fields.good_first_issues')) ->counts('goodFirstIssues') ->badge(), TextColumn::make('pushed_at') ->label(__('panel.repositories.fields.pushed_at')) ->since() ->color(fn (Repository $r) => $r->isDormant() ? 'danger' : null) ->placeholder('—'), ]) ->headerActions([ CreateAction::make() // Sync straight away so the stats are not blank until the // next scheduled run. ->after(function (Repository $record, GitManager $git): void { try { $git->sync($record); } catch (GitException $e) { Notification::make() ->warning() ->title(__('panel.repositories.notifications.sync_failed')) ->body($e->getMessage()) ->send(); } }), ]) ->recordActions([ Action::make('sync') ->label(__('panel.repositories.actions.sync')) ->icon('heroicon-o-arrow-path') ->color('gray') ->visible(fn () => Auth::user()?->can('repositories.sync')) ->action(function (Repository $record, GitManager $git): void { try { $git->sync($record); Notification::make() ->success() ->title(__('panel.repositories.notifications.synced')) ->send(); } catch (GitException $e) { Notification::make() ->danger() ->title(__('panel.repositories.notifications.sync_failed')) ->body($e->getMessage()) ->send(); } }), DeleteAction::make(), ]); } }