Skip to content

Commit c0e5aeb

Browse files
committed
update generic oidc provider form
1 parent 99a9b39 commit c0e5aeb

3 files changed

Lines changed: 45 additions & 36 deletions

File tree

generic-oidc-providers/lang/en/strings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
'display_color' => 'Display Color',
88
'display_icon' => 'Display Icon',
99
'base_url' => 'Base URL',
10+
'redirect_url' => 'Redirect URL',
1011
'verify_jwt' => 'Verify JWT?',
1112
'jwt_public_key' => 'JWT Public Key',
1213
];

generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/GenericOIDCProviderResource.php

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Boy132\GenericOIDCProviders\Filament\Admin\Resources\GenericOIDCProviders\Pages\EditGenericOIDCProvider;
77
use Boy132\GenericOIDCProviders\Filament\Admin\Resources\GenericOIDCProviders\Pages\ListGenericOIDCProviders;
88
use Boy132\GenericOIDCProviders\Models\GenericOIDCProvider;
9-
use Filament\Actions\CreateAction;
109
use Filament\Actions\DeleteAction;
1110
use Filament\Actions\DeleteBulkAction;
1211
use Filament\Actions\EditAction;
@@ -15,6 +14,7 @@
1514
use Filament\Forms\Components\TextInput;
1615
use Filament\Forms\Components\Toggle;
1716
use Filament\Resources\Resource;
17+
use Filament\Schemas\Components\Group;
1818
use Filament\Schemas\Components\StateCasts\BooleanStateCast;
1919
use Filament\Schemas\Components\Utilities\Get;
2020
use Filament\Schemas\Components\Utilities\Set;
@@ -33,6 +33,8 @@ class GenericOIDCProviderResource extends Resource
3333

3434
protected static string|\BackedEnum|null $navigationIcon = 'tabler-brand-oauth';
3535

36+
protected static ?string $recordTitleAttribute = 'id';
37+
3638
public static function getNavigationGroup(): ?string
3739
{
3840
return trans('admin/dashboard.advanced');
@@ -61,7 +63,6 @@ public static function getNavigationBadge(): ?string
6163
public static function form(Schema $schema): Schema
6264
{
6365
return $schema
64-
->columns(3)
6566
->components([
6667
TextInput::make('id')
6768
->label('ID')
@@ -88,15 +89,14 @@ public static function form(Schema $schema): Schema
8889
->label(trans('generic-oidc-providers::strings.base_url'))
8990
->required()
9091
->url()
91-
->autocomplete(false),
92-
Toggle::make('create_missing_users')
93-
->label(trans('admin/setting.oauth.create_missing_users'))
94-
->inline(false)
95-
->onIcon('tabler-check')
96-
->offIcon('tabler-x')
97-
->onColor('success')
98-
->offColor('danger')
99-
->stateCast(new BooleanStateCast(false)),
92+
->autocomplete(false)
93+
->columnSpan(fn ($operation) => $operation === 'create' ? 2 : 1),
94+
TextInput::make('redirect_url')
95+
->label(trans('generic-oidc-providers::strings.redirect_url'))
96+
->saved(false)
97+
->formatStateUsing(fn (Get $get) => url('/auth/oauth/callback/' . $get('id')))
98+
->disabled()
99+
->hiddenOn('create'),
100100
TextInput::make('client_id')
101101
->label(trans('admin/setting.oauth.client_id'))
102102
->required()
@@ -109,27 +109,40 @@ public static function form(Schema $schema): Schema
109109
->password()
110110
->revealable()
111111
->autocomplete(false),
112-
Toggle::make('link_missing_users')
113-
->label(trans('admin/setting.oauth.link_missing_users'))
114-
->inline(false)
115-
->onIcon('tabler-check')
116-
->offIcon('tabler-x')
117-
->onColor('success')
118-
->offColor('danger')
119-
->stateCast(new BooleanStateCast(false)),
120-
Toggle::make('verify_jwt')
121-
->label(trans('generic-oidc-providers::strings.verify_jwt'))
122-
->inline(false)
123-
->onIcon('tabler-check')
124-
->offIcon('tabler-x')
125-
->onColor('success')
126-
->offColor('danger')
127-
->stateCast(new BooleanStateCast(false))
128-
->live(),
112+
Group::make()
113+
->columns(3)
114+
->columnSpanFull()
115+
->schema([
116+
Toggle::make('create_missing_users')
117+
->label(trans('admin/setting.oauth.create_missing_users'))
118+
->inline(false)
119+
->onIcon('tabler-check')
120+
->offIcon('tabler-x')
121+
->onColor('success')
122+
->offColor('danger')
123+
->stateCast(new BooleanStateCast(false)),
124+
Toggle::make('link_missing_users')
125+
->label(trans('admin/setting.oauth.link_missing_users'))
126+
->inline(false)
127+
->onIcon('tabler-check')
128+
->offIcon('tabler-x')
129+
->onColor('success')
130+
->offColor('danger')
131+
->stateCast(new BooleanStateCast(false)),
132+
Toggle::make('verify_jwt')
133+
->label(trans('generic-oidc-providers::strings.verify_jwt'))
134+
->inline(false)
135+
->onIcon('tabler-check')
136+
->offIcon('tabler-x')
137+
->onColor('success')
138+
->offColor('danger')
139+
->stateCast(new BooleanStateCast(false))
140+
->live(),
141+
]),
129142
Textarea::make('jwt_public_key')
130143
->label(trans('generic-oidc-providers::strings.jwt_public_key'))
131144
->visible(fn (Get $get) => $get('verify_jwt'))
132-
->columnSpan(2)
145+
->columnSpanFull()
133146
->rows(3)
134147
->autosize()
135148
->placeholder('-----BEGIN PUBLIC KEY-----
@@ -178,10 +191,7 @@ public static function table(Table $table): Table
178191
])
179192
->emptyStateIcon('tabler-brand-oauth')
180193
->emptyStateDescription('')
181-
->emptyStateHeading(trans('generic-oidc-providers::strings.no_generic_oidc_providers'))
182-
->emptyStateActions([
183-
CreateAction::make(),
184-
]);
194+
->emptyStateHeading(trans('generic-oidc-providers::strings.no_generic_oidc_providers'));
185195
}
186196

187197
public static function getPages(): array

generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/ListGenericOIDCProviders.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Boy132\GenericOIDCProviders\Filament\Admin\Resources\GenericOIDCProviders\Pages;
44

55
use Boy132\GenericOIDCProviders\Filament\Admin\Resources\GenericOIDCProviders\GenericOIDCProviderResource;
6-
use Boy132\GenericOIDCProviders\Models\GenericOIDCProvider;
76
use Filament\Actions\CreateAction;
87
use Filament\Resources\Pages\ListRecords;
98

@@ -14,8 +13,7 @@ class ListGenericOIDCProviders extends ListRecords
1413
protected function getHeaderActions(): array
1514
{
1615
return [
17-
CreateAction::make()
18-
->hidden(fn () => GenericOIDCProvider::count() <= 0),
16+
CreateAction::make(),
1917
];
2018
}
2119
}

0 commit comments

Comments
 (0)