-
Notifications
You must be signed in to change notification settings - Fork 6
Fix/gitea repostiories #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| <?php | ||
|
|
||
| namespace App\Filament\Resources\CompanyJobs\RelationManagers; | ||
|
|
||
| use App\Enums\ApplicationStatus; | ||
| use App\Models\CompanyJobApplication; | ||
| use App\Models\Scopes\ApprovedScope; | ||
| use Filament\Resources\RelationManagers\RelationManager; | ||
| use Filament\Schemas\Schema; | ||
| use Filament\Tables\Columns\TextColumn; | ||
| use Filament\Tables\Table; | ||
| use Illuminate\Database\Eloquent\Builder; | ||
|
|
||
| class ApplicationsRelationManager extends RelationManager | ||
| { | ||
| protected static string $relationship = 'applications'; | ||
|
|
||
| protected static ?string $title = 'Participants'; | ||
|
|
||
| public function form(Schema $schema): Schema | ||
| { | ||
| return $schema->components([]); | ||
| } | ||
|
|
||
| public function table(Table $table): Table | ||
| { | ||
| return $table | ||
| ->recordTitleAttribute('id') | ||
| ->modifyQueryUsing(function (Builder $query): Builder { | ||
| return $query->with([ | ||
| 'developer' => fn ($q) => $q | ||
| ->withoutGlobalScope(ApprovedScope::class) | ||
| ->with('user'), | ||
| ]); | ||
| }) | ||
| ->columns([ | ||
| TextColumn::make('developer.name') | ||
| ->label('Developer') | ||
| ->sortable() | ||
| ->placeholder('—'), | ||
| TextColumn::make('participant_email') | ||
| ->label('Email') | ||
| ->state(function (CompanyJobApplication $record): string { | ||
| $developer = $record->developer; | ||
|
|
||
| if ($developer === null) { | ||
| return '—'; | ||
| } | ||
|
|
||
| return $developer->user?->email | ||
| ?? $developer->email | ||
| ?? '—'; | ||
| }), | ||
| TextColumn::make('status') | ||
| ->badge() | ||
| ->formatStateUsing(fn (ApplicationStatus $state): string => $state->getLabel()) | ||
| ->color(fn (ApplicationStatus $state): string => $state->getColor()) | ||
| ->sortable(), | ||
| TextColumn::make('cover_message') | ||
| ->label('Message') | ||
| ->limit(80) | ||
| ->wrap() | ||
| ->placeholder('—') | ||
| ->toggleable(), | ||
| TextColumn::make('created_at') | ||
| ->label('Applied') | ||
| ->dateTime() | ||
| ->sortable(), | ||
| ]) | ||
| ->defaultSort('created_at', 'desc') | ||
| ->filters([ | ||
| // | ||
| ]) | ||
| ->headerActions([ | ||
| // | ||
| ]) | ||
| ->recordActions([ | ||
| // | ||
| ]) | ||
| ->toolbarActions([ | ||
| // | ||
| ]); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,7 @@ public function provisionRepositoryForApprovedJob(CompanyJob $job): void | |
| throw new RuntimeException('Could not determine Gitea username for the post owner.'); | ||
| } | ||
|
|
||
| $repoName = 'remote-work-'.$job->id; | ||
| $repoName = $this->repositoryNameForJob($job); | ||
|
|
||
| $this->gitea->createRepositoryForUser( | ||
| $login, | ||
|
|
@@ -129,4 +129,18 @@ public function addAcceptedApplication(CompanyJobApplication $application): void | |
|
|
||
| $this->addDeveloperToJobRepository($job, $developer); | ||
| } | ||
|
|
||
| /** | ||
| * Gitea repository name matches the job's public slug, max 100 chars per API limits. | ||
| */ | ||
| private function repositoryNameForJob(CompanyJob $job): string | ||
| { | ||
| $slug = trim((string) $job->slug); | ||
|
|
||
| if ($slug === '') { | ||
| return 'remote-work-'.$job->id; | ||
| } | ||
|
|
||
| return mb_substr($slug, 0, 100); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Truncating the slug to 100 characters might lead to repository name collisions if multiple jobs have long slugs that are identical for the first 100 characters. While 100 characters is a generous limit, appending the job ID (or a portion of it) would guarantee uniqueness even after truncation. return mb_substr($slug, 0, 90) . '-' . $job->id; |
||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The closures for
formatStateUsingandcoloruse a non-nullable type hint forApplicationStatus. If thestatusfield is null in the database, this will trigger aTypeError. It is safer to use a nullable type hint and handle the null case with the null-safe operator or a fallback.