mirror of
https://github.com/pelican-dev/panel.git
synced 2025-08-03 14:12:13 +02:00
Move header actions to iconbuttons (#1541)
This commit is contained in:
parent
083e3dc62a
commit
d0d3418e03
@ -13,6 +13,7 @@ use Filament\Actions\Action;
|
|||||||
use Filament\Actions\ActionGroup;
|
use Filament\Actions\ActionGroup;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
use Filament\Support\Enums\IconSize;
|
||||||
|
|
||||||
class ListAllocations extends ListRecords
|
class ListAllocations extends ListRecords
|
||||||
{
|
{
|
||||||
@ -29,8 +30,10 @@ class ListAllocations extends ListRecords
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
Action::make('addAllocation')
|
Action::make('addAllocation')
|
||||||
|
->hiddenLabel()->iconButton()->iconSize(IconSize::Large)
|
||||||
|
->icon(fn () => $server->allocations()->count() >= $server->allocation_limit ? 'tabler-network-off' : 'tabler-network')
|
||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_ALLOCATION_CREATE, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_ALLOCATION_CREATE, $server))
|
||||||
->label(fn () => $server->allocations()->count() >= $server->allocation_limit ? 'Allocation limit reached' : 'Add Allocation')
|
->tooltip(fn () => $server->allocations()->count() >= $server->allocation_limit ? 'Allocation limit reached' : 'Add Allocation')
|
||||||
->hidden(fn () => !config('panel.client_features.allocations.enabled'))
|
->hidden(fn () => !config('panel.client_features.allocations.enabled'))
|
||||||
->disabled(fn () => $server->allocations()->count() >= $server->allocation_limit)
|
->disabled(fn () => $server->allocations()->count() >= $server->allocation_limit)
|
||||||
->color(fn () => $server->allocations()->count() >= $server->allocation_limit ? 'danger' : 'primary')
|
->color(fn () => $server->allocations()->count() >= $server->allocation_limit ? 'danger' : 'primary')
|
||||||
|
@ -15,6 +15,7 @@ use Filament\Actions\CreateAction;
|
|||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
use Filament\Support\Enums\IconSize;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
|
||||||
class ListBackups extends ListRecords
|
class ListBackups extends ListRecords
|
||||||
@ -33,8 +34,9 @@ class ListBackups extends ListRecords
|
|||||||
return [
|
return [
|
||||||
CreateAction::make()
|
CreateAction::make()
|
||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_BACKUP_CREATE, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_BACKUP_CREATE, $server))
|
||||||
->label(fn () => $server->backups()->count() >= $server->backup_limit ? 'Backup limit reached' : 'Create Backup')
|
->icon('tabler-file-zip')->iconButton()->iconSize(IconSize::Large)
|
||||||
->disabled(fn () => $server->backups()->count() >= $server->backup_limit)
|
->disabled(fn () => $server->backups()->count() >= $server->backup_limit)
|
||||||
|
->tooltip(fn () => $server->backups()->count() >= $server->backup_limit ? 'Backup Limit Reached' : 'Create Backup') // Disabled Buttons have no tooltips in v3 :/
|
||||||
->color(fn () => $server->backups()->count() >= $server->backup_limit ? 'danger' : 'primary')
|
->color(fn () => $server->backups()->count() >= $server->backup_limit ? 'danger' : 'primary')
|
||||||
->createAnother(false)
|
->createAnother(false)
|
||||||
->action(function (InitiateBackupService $initiateBackupService, $data) use ($server) {
|
->action(function (InitiateBackupService $initiateBackupService, $data) use ($server) {
|
||||||
|
@ -16,6 +16,7 @@ use Filament\Forms\Components\Grid;
|
|||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
use Filament\Support\Enums\IconSize;
|
||||||
|
|
||||||
class ListDatabases extends ListRecords
|
class ListDatabases extends ListRecords
|
||||||
{
|
{
|
||||||
@ -32,7 +33,9 @@ class ListDatabases extends ListRecords
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
CreateAction::make('new')
|
CreateAction::make('new')
|
||||||
->label(fn () => $server->databases()->count() >= $server->database_limit ? 'Database limit reached' : 'Create Database')
|
->hiddenLabel()->iconButton()->iconSize(IconSize::Large)
|
||||||
|
->icon(fn () => $server->databases()->count() >= $server->database_limit ? 'tabler-database-x' : 'tabler-database-plus')
|
||||||
|
->tooltip(fn () => $server->databases()->count() >= $server->database_limit ? 'Database limit reached' : 'Create Database')
|
||||||
->disabled(fn () => $server->databases()->count() >= $server->database_limit)
|
->disabled(fn () => $server->databases()->count() >= $server->database_limit)
|
||||||
->color(fn () => $server->databases()->count() >= $server->database_limit ? 'danger' : 'primary')
|
->color(fn () => $server->databases()->count() >= $server->database_limit ? 'danger' : 'primary')
|
||||||
->createAnother(false)
|
->createAnother(false)
|
||||||
|
@ -31,6 +31,7 @@ use Filament\Notifications\Notification;
|
|||||||
use Filament\Panel;
|
use Filament\Panel;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
use Filament\Resources\Pages\PageRegistration;
|
use Filament\Resources\Pages\PageRegistration;
|
||||||
|
use Filament\Support\Enums\IconSize;
|
||||||
use Filament\Tables\Actions\Action;
|
use Filament\Tables\Actions\Action;
|
||||||
use Filament\Tables\Actions\ActionGroup;
|
use Filament\Tables\Actions\ActionGroup;
|
||||||
use Filament\Tables\Actions\BulkAction;
|
use Filament\Tables\Actions\BulkAction;
|
||||||
@ -416,9 +417,9 @@ class ListFiles extends ListRecords
|
|||||||
return [
|
return [
|
||||||
HeaderAction::make('new_file')
|
HeaderAction::make('new_file')
|
||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server))
|
||||||
->label('New File')
|
->tooltip('New File')
|
||||||
->color('gray')
|
->hiddenLabel()->icon('tabler-file-plus')->iconButton()->iconSize(IconSize::Large)
|
||||||
->keyBindings('')
|
->color('primary')
|
||||||
->modalSubmitActionLabel('Create')
|
->modalSubmitActionLabel('Create')
|
||||||
->action(function ($data) {
|
->action(function ($data) {
|
||||||
$path = join_paths($this->path, $data['name']);
|
$path = join_paths($this->path, $data['name']);
|
||||||
@ -458,8 +459,9 @@ class ListFiles extends ListRecords
|
|||||||
]),
|
]),
|
||||||
HeaderAction::make('new_folder')
|
HeaderAction::make('new_folder')
|
||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server))
|
||||||
->label('New Folder')
|
->hiddenLabel()->icon('tabler-folder-plus')->iconButton()->iconSize(IconSize::Large)
|
||||||
->color('gray')
|
->tooltip('New Folder')
|
||||||
|
->color('primary')
|
||||||
->action(function ($data) {
|
->action(function ($data) {
|
||||||
try {
|
try {
|
||||||
$this->getDaemonFileRepository()->createDirectory($data['name'], $this->path);
|
$this->getDaemonFileRepository()->createDirectory($data['name'], $this->path);
|
||||||
@ -485,7 +487,9 @@ class ListFiles extends ListRecords
|
|||||||
]),
|
]),
|
||||||
HeaderAction::make('upload')
|
HeaderAction::make('upload')
|
||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server))
|
||||||
->label('Upload')
|
->hiddenLabel()->icon('tabler-upload')->iconButton()->iconSize(IconSize::Large)
|
||||||
|
->tooltip('Upload')
|
||||||
|
->color('success')
|
||||||
->action(function ($data) {
|
->action(function ($data) {
|
||||||
if (count($data['files']) > 0 && !isset($data['url'])) {
|
if (count($data['files']) > 0 && !isset($data['url'])) {
|
||||||
/** @var UploadedFile $file */
|
/** @var UploadedFile $file */
|
||||||
@ -534,7 +538,11 @@ class ListFiles extends ListRecords
|
|||||||
]),
|
]),
|
||||||
HeaderAction::make('search')
|
HeaderAction::make('search')
|
||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_READ, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_READ, $server))
|
||||||
->label('Global Search')
|
->hiddenLabel()->iconButton()->iconSize(IconSize::Large)
|
||||||
|
->tooltip('Global Search')
|
||||||
|
->color('primary')
|
||||||
|
->icon('tabler-world-search')
|
||||||
|
->modalHeading('Global Search')
|
||||||
->modalSubmitActionLabel('Search')
|
->modalSubmitActionLabel('Search')
|
||||||
->form([
|
->form([
|
||||||
TextInput::make('searchTerm')
|
TextInput::make('searchTerm')
|
||||||
|
@ -10,6 +10,7 @@ use App\Traits\Filament\CanCustomizeHeaderActions;
|
|||||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Resources\Pages\EditRecord;
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
use Filament\Support\Enums\IconSize;
|
||||||
|
|
||||||
class EditSchedule extends EditRecord
|
class EditSchedule extends EditRecord
|
||||||
{
|
{
|
||||||
@ -46,14 +47,26 @@ class EditSchedule extends EditRecord
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Actions\DeleteAction::make()
|
Actions\DeleteAction::make()
|
||||||
|
->hiddenLabel()->iconButton()->iconSize(IconSize::Large)
|
||||||
|
->icon('tabler-trash')
|
||||||
|
->tooltip('Delete Schedule')
|
||||||
->after(function ($record) {
|
->after(function ($record) {
|
||||||
Activity::event('server:schedule.delete')
|
Activity::event('server:schedule.delete')
|
||||||
->property('name', $record->name)
|
->property('name', $record->name)
|
||||||
->log();
|
->log();
|
||||||
}),
|
}),
|
||||||
ExportScheduleAction::make(),
|
ExportScheduleAction::make()
|
||||||
$this->getSaveFormAction()->formId('form')->label('Save'),
|
->hiddenLabel()->iconButton()->iconSize(IconSize::Large)
|
||||||
$this->getCancelFormAction()->formId('form'),
|
->icon('tabler-download')
|
||||||
|
->tooltip('Export Schedule'),
|
||||||
|
$this->getSaveFormAction()->formId('form')
|
||||||
|
->hiddenLabel()->iconButton()->iconSize(IconSize::Large)
|
||||||
|
->icon('tabler-device-floppy')
|
||||||
|
->tooltip('Save Schedule'),
|
||||||
|
$this->getCancelFormAction()->formId('form')
|
||||||
|
->hiddenLabel()->iconButton()->iconSize(IconSize::Large)
|
||||||
|
->icon('tabler-cancel')
|
||||||
|
->tooltip('Cancel'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ use Filament\Actions\Action;
|
|||||||
use Filament\Actions\ActionGroup;
|
use Filament\Actions\ActionGroup;
|
||||||
use Filament\Actions\CreateAction;
|
use Filament\Actions\CreateAction;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
use Filament\Support\Enums\IconSize;
|
||||||
|
|
||||||
class ListSchedules extends ListRecords
|
class ListSchedules extends ListRecords
|
||||||
{
|
{
|
||||||
@ -23,8 +24,13 @@ class ListSchedules extends ListRecords
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
CreateAction::make()
|
CreateAction::make()
|
||||||
->label('New Schedule'),
|
->hiddenLabel()->iconButton()->iconSize(IconSize::Large)
|
||||||
ImportScheduleAction::make(),
|
->icon('tabler-calendar-plus')
|
||||||
|
->tooltip('New Schedule'),
|
||||||
|
ImportScheduleAction::make()
|
||||||
|
->hiddenLabel()->iconButton()->iconSize(IconSize::Large)
|
||||||
|
->icon('tabler-download')
|
||||||
|
->tooltip('Import Schedule'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ use Filament\Actions\ActionGroup;
|
|||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
use Filament\Support\Enums\IconSize;
|
||||||
|
|
||||||
class ViewSchedule extends ViewRecord
|
class ViewSchedule extends ViewRecord
|
||||||
{
|
{
|
||||||
@ -41,7 +42,10 @@ class ViewSchedule extends ViewRecord
|
|||||||
|
|
||||||
$this->fillForm();
|
$this->fillForm();
|
||||||
}),
|
}),
|
||||||
EditAction::make(),
|
EditAction::make()
|
||||||
|
->hiddenLabel()->iconButton()->iconSize(IconSize::Large)
|
||||||
|
->icon('tabler-calendar-code')
|
||||||
|
->tooltip('Edit Schedule'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ use Filament\Forms\Get;
|
|||||||
use Filament\Forms\Set;
|
use Filament\Forms\Set;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
use Filament\Support\Enums\IconSize;
|
||||||
|
|
||||||
class ListUsers extends ListRecords
|
class ListUsers extends ListRecords
|
||||||
{
|
{
|
||||||
@ -69,7 +70,9 @@ class ListUsers extends ListRecords
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
Actions\CreateAction::make('invite')
|
Actions\CreateAction::make('invite')
|
||||||
->label('Invite User')
|
->hiddenLabel()->iconButton()->iconSize(IconSize::Large)
|
||||||
|
->icon('tabler-user-plus')
|
||||||
|
->tooltip('Invite User')
|
||||||
->createAnother(false)
|
->createAnother(false)
|
||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_USER_CREATE, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_USER_CREATE, $server))
|
||||||
->form([
|
->form([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user