diff --git a/app/Filament/Resources/ApiKeyResource.php b/app/Filament/Resources/ApiKeyResource.php index b4bea3352..0d7817cd9 100644 --- a/app/Filament/Resources/ApiKeyResource.php +++ b/app/Filament/Resources/ApiKeyResource.php @@ -4,9 +4,7 @@ namespace App\Filament\Resources; use App\Filament\Resources\ApiKeyResource\Pages; use App\Models\ApiKey; -use Filament\Resources\Components\Tab; use Filament\Resources\Resource; -use Illuminate\Database\Eloquent\Builder; class ApiKeyResource extends Resource { @@ -16,7 +14,7 @@ class ApiKeyResource extends Resource public static function getNavigationBadge(): ?string { - return static::getModel()::count() ?: null; + return static::getModel()::where('key_type', '2')->count() ?: null; } public static function canEdit($record): bool @@ -24,20 +22,6 @@ class ApiKeyResource extends Resource return false; } - 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)), - ]; - } - - public function getDefaultActiveTab(): string|int|null - { - return 'application'; - } - public static function getRelations(): array { return [ diff --git a/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php b/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php index b64e0f4f8..f55422299 100644 --- a/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php +++ b/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php @@ -19,11 +19,6 @@ class ListApiKeys extends ListRecords ->searchable(false) ->modifyQueryUsing(fn ($query) => $query->where('key_type', ApiKey::TYPE_APPLICATION)) ->columns([ - Tables\Columns\TextColumn::make('user.username') - ->hidden() - ->searchable() - ->sortable(), - Tables\Columns\TextColumn::make('key') ->copyable() ->icon('tabler-clipboard-text') @@ -40,6 +35,7 @@ class ListApiKeys extends ListRecords Tables\Columns\TextColumn::make('last_used_at') ->label('Last Used') + ->placeholder('Not Used') ->dateTime() ->sortable(), @@ -47,13 +43,13 @@ class ListApiKeys extends ListRecords ->label('Created') ->dateTime() ->sortable(), - ]) - ->filters([ - // + + Tables\Columns\TextColumn::make('user.username') + ->label('Created By') + ->url(fn (ApiKey $apiKey): string => route('filament.admin.resources.users.edit', ['record' => $apiKey->user])), ]) ->actions([ Tables\Actions\DeleteAction::make(), - //Tables\Actions\EditAction::make() ]); } diff --git a/app/Filament/Resources/UserResource/Pages/EditProfile.php b/app/Filament/Resources/UserResource/Pages/EditProfile.php index 7fe5728cf..1d86f4f02 100644 --- a/app/Filament/Resources/UserResource/Pages/EditProfile.php +++ b/app/Filament/Resources/UserResource/Pages/EditProfile.php @@ -158,7 +158,7 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile ->schema([ Grid::make('asdf')->columns(5)->schema([ Section::make('Create API Key')->columnSpan(3)->schema([ - TextInput::make('description'), + TextInput::make('description')->required(), TagsInput::make('allowed_ips') ->splitKeys([',', ' ', 'Tab']) ->placeholder('Example: 127.0.0.1 or 192.168.1.1') @@ -182,8 +182,9 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile $action->success(); }), ]), - Section::make('API Keys')->columnSpan(2)->schema([ + Section::make('Keys')->columnSpan(2)->schema([ Repeater::make('keys') + ->label('') ->relationship('apiKeys') ->addable(false) ->itemLabel(fn ($state) => $state['identifier'])