mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 15:34:44 +02:00
Only show application api keys
This commit is contained in:
parent
97ac0fe54b
commit
8cec7368ab
@ -25,24 +25,10 @@ class CreateApiKey extends CreateRecord
|
|||||||
->default(auth()->user()->id)
|
->default(auth()->user()->id)
|
||||||
->required(),
|
->required(),
|
||||||
|
|
||||||
Forms\Components\Select::make('key_type')
|
Forms\Components\Hidden::make('key_type')
|
||||||
->inlineLabel()
|
->inlineLabel()
|
||||||
->options(function (ApiKey $apiKey) {
|
->default(ApiKey::TYPE_APPLICATION)
|
||||||
$originalOptions = [
|
->required(),
|
||||||
//ApiKey::TYPE_NONE => 'None',
|
|
||||||
ApiKey::TYPE_ACCOUNT => 'Account',
|
|
||||||
ApiKey::TYPE_APPLICATION => 'Application',
|
|
||||||
//ApiKey::TYPE_DAEMON_USER => 'Daemon User',
|
|
||||||
//ApiKey::TYPE_DAEMON_APPLICATION => 'Daemon Application',
|
|
||||||
];
|
|
||||||
|
|
||||||
return collect($originalOptions)
|
|
||||||
->filter(fn ($value, $key) => $key <= ApiKey::TYPE_APPLICATION || $apiKey->key_type === $key)
|
|
||||||
->all();
|
|
||||||
})
|
|
||||||
->selectablePlaceholder(false)
|
|
||||||
->required()
|
|
||||||
->default(ApiKey::TYPE_APPLICATION),
|
|
||||||
|
|
||||||
Forms\Components\Fieldset::make('Permissions')
|
Forms\Components\Fieldset::make('Permissions')
|
||||||
->columns([
|
->columns([
|
||||||
|
@ -19,6 +19,7 @@ class ListApiKeys extends ListRecords
|
|||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->searchable(false)
|
->searchable(false)
|
||||||
|
->modifyQueryUsing(fn ($query) => $query->where('key_type', ApiKey::TYPE_APPLICATION))
|
||||||
->columns([
|
->columns([
|
||||||
Tables\Columns\TextColumn::make('user.username')
|
Tables\Columns\TextColumn::make('user.username')
|
||||||
->hidden()
|
->hidden()
|
||||||
@ -64,22 +65,4 @@ class ListApiKeys extends ListRecords
|
|||||||
Actions\CreateAction::make(),
|
Actions\CreateAction::make(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|
||||||
),
|
|
||||||
'account' => Tab::make('Account Keys')
|
|
||||||
->modifyQueryUsing(fn (Builder $query) => $query->where('key_type', ApiKey::TYPE_ACCOUNT)
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDefaultActiveTab(): string|int|null
|
|
||||||
{
|
|
||||||
return 'application';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user