mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 13:14:45 +02:00
Update Webhooks to match other resources (#686)
* Move these Move List/Create to their own pages to follow the flow of the other resources. * Move EditPage aswell * Move Save * Labels * Change Edit/Delete --------- Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
This commit is contained in:
parent
382dcb3868
commit
cf57c28c40
@ -4,13 +4,7 @@ namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\WebhookResource\Pages;
|
||||
use App\Models\WebhookConfiguration;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class WebhookResource extends Resource
|
||||
{
|
||||
@ -22,44 +16,9 @@ class WebhookResource extends Resource
|
||||
|
||||
protected static ?string $label = 'Webhooks';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
TextInput::make('endpoint')
|
||||
->activeUrl()
|
||||
->required(),
|
||||
TextInput::make('description')
|
||||
->required(),
|
||||
CheckboxList::make('events')
|
||||
->lazy()
|
||||
->options(fn () => WebhookConfiguration::filamentCheckboxList())
|
||||
->searchable()
|
||||
->bulkToggleable()
|
||||
->columns(3)
|
||||
->columnSpanFull()
|
||||
->gridDirection('row')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('description'),
|
||||
TextColumn::make('endpoint'),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
return static::getModel()::count() ?: null;
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
|
@ -3,9 +3,34 @@
|
||||
namespace App\Filament\Resources\WebhookResource\Pages;
|
||||
|
||||
use App\Filament\Resources\WebhookResource;
|
||||
use App\Models\WebhookConfiguration;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateWebhookConfiguration extends CreateRecord
|
||||
{
|
||||
protected static string $resource = WebhookResource::class;
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
TextInput::make('endpoint')
|
||||
->activeUrl()
|
||||
->required(),
|
||||
TextInput::make('description')
|
||||
->required(),
|
||||
CheckboxList::make('events')
|
||||
->lazy()
|
||||
->options(fn () => WebhookConfiguration::filamentCheckboxList())
|
||||
->searchable()
|
||||
->bulkToggleable()
|
||||
->columns(3)
|
||||
->columnSpanFull()
|
||||
->gridDirection('row')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,56 @@
|
||||
|
||||
namespace App\Filament\Resources\WebhookResource\Pages;
|
||||
|
||||
use App\Models\WebhookConfiguration;
|
||||
use App\Filament\Resources\WebhookResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditWebhookConfiguration extends EditRecord
|
||||
{
|
||||
protected static string $resource = WebhookResource::class;
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
TextInput::make('endpoint')
|
||||
->label('Endpoint')
|
||||
->activeUrl()
|
||||
->required(),
|
||||
TextInput::make('description')
|
||||
->label('Description')
|
||||
->required(),
|
||||
CheckboxList::make('events')
|
||||
->label('Events')
|
||||
->lazy()
|
||||
->options(fn () => WebhookConfiguration::filamentCheckboxList())
|
||||
->searchable()
|
||||
->bulkToggleable()
|
||||
->columns(3)
|
||||
->columnSpanFull()
|
||||
->gridDirection('row')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getFormActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\DeleteAction::make()
|
||||
->label('Delete')
|
||||
->modalHeading('Are you sure you want to delete this?')
|
||||
->modalDescription('')
|
||||
->modalSubmitActionLabel('Delete'),
|
||||
$this->getSaveFormAction()->formId('form'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -3,17 +3,50 @@
|
||||
namespace App\Filament\Resources\WebhookResource\Pages;
|
||||
|
||||
use App\Filament\Resources\WebhookResource;
|
||||
use App\Models\WebhookConfiguration;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
|
||||
class ListWebhookConfigurations extends ListRecords
|
||||
{
|
||||
protected static string $resource = WebhookResource::class;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('description')
|
||||
->label('Description'),
|
||||
TextColumn::make('endpoint')
|
||||
->label('Endpoint'),
|
||||
])
|
||||
->actions([
|
||||
DeleteAction::make()
|
||||
->label('Delete'),
|
||||
EditAction::make()
|
||||
->label('Edit'),
|
||||
])
|
||||
->emptyStateIcon('tabler-webhook')
|
||||
->emptyStateDescription('')
|
||||
->emptyStateHeading('No Webhooks')
|
||||
->emptyStateActions([
|
||||
CreateAction::make('create')
|
||||
->label('Create Webhook')
|
||||
->button(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
Actions\CreateAction::make()
|
||||
->label('Create Webhook')
|
||||
->hidden(fn () => WebhookConfiguration::count() <= 0),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user