Skip to content

Commit

Permalink
Pint and code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Poseidon281 committed May 18, 2024
1 parent 3a3a0f8 commit 39a973f
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 64 deletions.
52 changes: 26 additions & 26 deletions app/Filament/Admin/Resources/ApiKeyResource/Pages/CreateApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,32 @@ public function form(Form $form): Form
])
->schema(
collect(ApiKey::RESOURCES)->map(fn ($resource) => Forms\Components\ToggleButtons::make("r_$resource")
->label(str($resource)->replace('_', ' ')->title())->inline()
->options([
0 => 'None',
1 => 'Read',
// 2 => 'Write',
3 => 'Read & Write',
])
->icons([
0 => 'tabler-book-off',
1 => 'tabler-book',
2 => 'tabler-writing',
3 => 'tabler-writing',
])
->colors([
0 => 'success',
1 => 'warning',
2 => 'danger',
3 => 'danger',
])
->required()
->columnSpan([
'default' => 1,
'sm' => 1,
'md' => 1,
])
->default(0),
->label(str($resource)->replace('_', ' ')->title())->inline()
->options([
0 => 'None',
1 => 'Read',
// 2 => 'Write',
3 => 'Read & Write',
])
->icons([
0 => 'tabler-book-off',
1 => 'tabler-book',
2 => 'tabler-writing',
3 => 'tabler-writing',
])
->colors([
0 => 'success',
1 => 'warning',
2 => 'danger',
3 => 'danger',
])
->required()
->columnSpan([
'default' => 1,
'sm' => 1,
'md' => 1,
])
->default(0),
)->all(),
),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,10 @@ public function getTabs(): array
return [
'all' => Tab::make('All Keys'),
'application' => Tab::make('Application Keys')
->modifyQueryUsing(
fn (Builder $query) => $query->where('key_type', ApiKey::TYPE_APPLICATION)
->modifyQueryUsing(fn (Builder $query) => $query->where('key_type', ApiKey::TYPE_APPLICATION)
),
'account' => Tab::make('Account Keys')
->modifyQueryUsing(
fn (Builder $query) => $query->where('key_type', ApiKey::TYPE_ACCOUNT)
->modifyQueryUsing(fn (Builder $query) => $query->where('key_type', ApiKey::TYPE_ACCOUNT)
),
];
}
Expand Down
4 changes: 1 addition & 3 deletions app/Filament/Admin/Resources/EggResource/Pages/CreateEgg.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ public function form(Form $form): Form
->debounce(750)
->maxLength(191)
->columnSpanFull()
->afterStateUpdated(
fn (Forms\Set $set, $state) => $set('env_variable', str($state)->trim()->snake()->upper()->toString())
)
->afterStateUpdated(fn (Forms\Set $set, $state) => $set('env_variable', str($state)->trim()->snake()->upper()->toString()))
->required(),
Forms\Components\Textarea::make('description')->columnSpanFull(),
Forms\Components\TextInput::make('env_variable')
Expand Down
4 changes: 1 addition & 3 deletions app/Filament/Admin/Resources/EggResource/Pages/EditEgg.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ public function form(Form $form): Form
->debounce(750)
->maxLength(191)
->columnSpanFull()
->afterStateUpdated(
fn (Forms\Set $set, $state) => $set('env_variable', str($state)->trim()->snake()->upper()->toString())
)
->afterStateUpdated(fn (Forms\Set $set, $state) => $set('env_variable', str($state)->trim()->snake()->upper()->toString()))
->required(),
Forms\Components\Textarea::make('description')->columnSpanFull(),
Forms\Components\TextInput::make('env_variable')
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Admin/Resources/NodeResource/Pages/EditNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ public function form(Forms\Form $form): Forms\Form
'http' => 'tabler-lock-open-off',
'https' => 'tabler-lock',
])
->default(fn () => request()->isSecure() ? 'https' : 'http'),
]),
->default(fn () => request()->isSecure() ? 'https' : 'http'), ]),

Tabs\Tab::make('Advanced Settings')
->icon('tabler-server-cog')
->schema([
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Admin/Resources/ServerResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ServerResource extends Resource
{
protected static ?string $model = Server::class;

protected static ?string $navigationIcon = 'tabler-server';
protected static ?string $navigationIcon = 'tabler-brand-docker';

protected static ?string $recordTitleAttribute = 'name';

Expand Down
24 changes: 8 additions & 16 deletions app/Filament/Admin/Resources/ServerResource/Pages/EditServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,15 @@ public function form(Form $form): Form
->options(
fn ($state) => collect(ContainerStatus::cases())->filter(fn ($containerStatus) => $containerStatus->value === $state)->mapWithKeys(
fn (ContainerStatus $state) => [$state->value => str($state->value)->replace('_', ' ')->ucwords()]
)
)
))
->colors(
collect(ContainerStatus::cases())->mapWithKeys(
fn (ContainerStatus $status) => [$status->value => $status->color()]
)
)
))
->icons(
collect(ContainerStatus::cases())->mapWithKeys(
fn (ContainerStatus $status) => [$status->value => $status->icon()]
)
)
))
->columnSpan([
'default' => 1,
'sm' => 2,
Expand All @@ -75,18 +72,15 @@ public function form(Form $form): Form
->options(
fn ($state) => collect(ServerState::cases())->filter(fn ($serverState) => $serverState->value === $state)->mapWithKeys(
fn (ServerState $state) => [$state->value => str($state->value)->replace('_', ' ')->ucwords()]
)
)
))
->colors(
collect(ServerState::cases())->mapWithKeys(
fn (ServerState $state) => [$state->value => $state->color()]
)
)
))
->icons(
collect(ServerState::cases())->mapWithKeys(
fn (ServerState $state) => [$state->value => $state->icon()]
)
)
))
->columnSpan([
'default' => 1,
'sm' => 2,
Expand Down Expand Up @@ -543,8 +537,7 @@ public function getRelationManagers(): array
private function shouldHideComponent(Forms\Get $get, Forms\Components\Component $component): bool
{
$containsRuleIn = str($get('rules'))->explode('|')->reduce(
fn ($result, $value) => $result === true && !str($value)->startsWith('in:'),
true
fn ($result, $value) => $result === true && !str($value)->startsWith('in:'), true
);

if ($component instanceof Forms\Components\Select) {
Expand All @@ -561,8 +554,7 @@ private function shouldHideComponent(Forms\Get $get, Forms\Components\Component
private function getSelectOptionsFromRules(Forms\Get $get): array
{
$inRule = str($get('rules'))->explode('|')->reduce(
fn ($result, $value) => str($value)->startsWith('in:') ? $value : $result,
''
fn ($result, $value) => str($value)->startsWith('in:') ? $value : $result, ''
);

return str($inRule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public function table(Table $table): Table
->label('Primary Allocation')
->options(
fn ($state, Server $server) => $server->allocations->mapWithKeys(
fn ($allocation) => [$allocation->id => $allocation->address]
)
fn ($allocation) => [$allocation->id => $allocation->address])
)
->selectablePlaceholder(false)
->sortable(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ protected function getForms(): array
->prefixIcon('tabler-flag')
->live()
->default('en')
->helperText(
fn (User $user, $state) => new HtmlString($user->isLanguageTranslated($state) ? '' : "
->helperText(fn (User $user, $state) => new HtmlString($user->isLanguageTranslated($state) ? '' : "
Your language ($state) has not been translated yet!
But never fear, you can help fix that by
<a style='color: rgb(56, 189, 248)' href='https://crowdin.com/project/pelican-dev'>contributing directly here</a>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ public function table(Table $table): Table
->searchable(false)
->headerActions([
Actions\Action::make('toggleSuspend')
->hidden(
fn () => $user->servers()
->whereNot('status', ServerState::Suspended)
->orWhereNull('status')
->count() === 0
->hidden(fn () => $user->servers()
->whereNot('status', ServerState::Suspended)
->orWhereNull('status')
->count() === 0
)
->label('Suspend All Servers')
->color('warning')
Expand Down

0 comments on commit 39a973f

Please sign in to comment.