fix form for webhooks

This commit is contained in:
Boy132 2025-07-23 09:13:16 +02:00
parent 74b3f423ed
commit 88cbe37712

View File

@ -132,14 +132,15 @@ class WebhookResource extends Resource
->live() ->live()
->inline() ->inline()
->options(WebhookType::class) ->options(WebhookType::class)
->default(WebhookType::Regular->value) ->default(WebhookType::Regular)
->afterStateHydrated(function (string $state) { ->afterStateHydrated(function (WebhookType $state) {
if ($state === WebhookType::Discord->value) { if ($state === WebhookType::Discord) {
self::sendHelpBanner(); self::sendHelpBanner();
} }
}) })
->afterStateUpdated(function (string $state) { ->afterStateUpdated(function (WebhookType $state) {
if ($state === WebhookType::Discord->value) { if ($state === WebhookType::Discord) {
self::sendHelpBanner();
} }
}), }),
TextInput::make('description') TextInput::make('description')
@ -150,23 +151,26 @@ class WebhookResource extends Resource
->activeUrl() ->activeUrl()
->required() ->required()
->columnSpanFull() ->columnSpanFull()
->afterStateUpdated(fn (string $state, Set $set) => $set('type', str($state)->contains('discord.com') ? WebhookType::Discord->value : WebhookType::Regular->value)), ->afterStateUpdated(fn (string $state, Set $set) => $set('type', str($state)->contains('discord.com') ? WebhookType::Discord : WebhookType::Regular)),
Section::make(trans('admin/webhook.regular')) Section::make(trans('admin/webhook.regular'))
->hidden(fn (Get $get) => $get('type') === WebhookType::Discord->value) ->hidden(fn (Get $get) => $get('type') === WebhookType::Discord)
->dehydratedWhenHidden() ->dehydratedWhenHidden()
->schema(fn () => self::getRegularFields()) ->schema(fn () => self::getRegularFields())
->formBefore(), ->formBefore()
->columnSpanFull(),
Section::make(trans('admin/webhook.discord')) Section::make(trans('admin/webhook.discord'))
->hidden(fn (Get $get) => $get('type') === WebhookType::Regular->value) ->hidden(fn (Get $get) => $get('type') === WebhookType::Regular)
->dehydratedWhenHidden() ->dehydratedWhenHidden()
->afterStateUpdated(fn (Livewire $livewire) => $livewire->dispatch('refresh-widget')) ->afterStateUpdated(fn (Livewire $livewire) => $livewire->dispatch('refresh-widget'))
->schema(fn () => self::getDiscordFields()) ->schema(fn () => self::getDiscordFields())
->view('filament.components.webhooksection') ->view('filament.components.webhooksection')
->aside() ->aside()
->formBefore(), ->formBefore()
->columnSpanFull(),
Section::make(trans('admin/webhook.events')) Section::make(trans('admin/webhook.events'))
->collapsible() ->collapsible()
->collapsed(fn (Get $get) => count($get('events') ?? [])) ->collapsed(fn (Get $get) => count($get('events') ?? []))
->columnSpanFull()
->schema([ ->schema([
CheckboxList::make('events') CheckboxList::make('events')
->live() ->live()