Skip to content

Commit

Permalink
revert: Admin table action configuration changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed May 9, 2022
1 parent 0c25a7e commit 8e27cdd
Show file tree
Hide file tree
Showing 17 changed files with 25 additions and 100 deletions.
7 changes: 6 additions & 1 deletion packages/admin/config/filament.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Http\Middleware\MirrorConfigToSubpackages;
use Filament\Pages;
use Filament\Resources;
use Filament\Tables\Actions\Action;
use Filament\Widgets;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
Expand Down Expand Up @@ -204,6 +204,11 @@
'sidebar' => [
'is_collapsible_on_desktop' => false,
],
'tables' => [
'actions' => [
'type' => Action::class,
],
],
],

/*
Expand Down
6 changes: 3 additions & 3 deletions packages/admin/src/FilamentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,10 @@ public function makeTableAction(string $name): Action
{
$type = config('filament.layout.tables.actions.type');

if (filled($type) && class_exists($type)) {
return $type::make($name);
if (blank($type) || (! class_exists($type))) {
$type = Action::class;
}

return Action::make($name);
return $type::make($name);
}
}
7 changes: 1 addition & 6 deletions packages/admin/src/Pages/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ class Action extends BaseAction
use HasKeyBindings;
use HasTooltip;

protected function setUp(): void
{
$this->view ?? $this->button();

parent::setUp();
}
protected string $view = 'filament::pages.actions.button-action';

public function button(): static
{
Expand Down
7 changes: 1 addition & 6 deletions packages/admin/src/Pages/Actions/Modal/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@

class Action extends BaseAction
{
protected function setUp(): void
{
$this->view ?? $this->button();

parent::setUp();
}
protected string $view = 'filament::pages.actions.modal.actions.button-action';

public function button(): static
{
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/Resources/Pages/ListRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function getViewAction(): Tables\Actions\Action
return Filament::makeTableAction('view')
->label(__('filament::resources/pages/list-records.table.actions.view.label'))
->url(fn (Model $record): string => $resource::getUrl('view', ['record' => $record]))
->defaultIcon('heroicon-s-eye')
->icon('heroicon-s-eye')
->hidden(fn (Model $record): bool => ! $resource::canView($record));
}

Expand All @@ -97,7 +97,7 @@ protected function getEditAction(): Tables\Actions\Action
return Filament::makeTableAction('edit')
->label(__('filament::resources/pages/list-records.table.actions.edit.label'))
->url(fn (Model $record): string => $resource::getUrl('edit', ['record' => $record]))
->defaultIcon('heroicon-s-pencil')
->icon('heroicon-s-pencil')
->hidden(fn (Model $record): bool => ! $resource::canEdit($record));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function getDeleteAction(): Tables\Actions\Action
->modalHeading(fn (Model $record) => __('filament::resources/pages/list-records.table.actions.delete.modal.heading', ['label' => $resource::hasRecordTitle() ? $resource::getRecordTitle($record) : Str::title($resource::getLabel())]))
->action(fn () => $this->delete())
->color('danger')
->defaultIcon('heroicon-s-trash')
->icon('heroicon-s-trash')
->hidden(fn (Model $record): bool => ! $resource::canDelete($record));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function getDeleteAction(): Tables\Actions\Action
->modalHeading(__('filament::resources/relation-managers/delete.action.modal.heading', ['label' => static::getRecordLabel()]))
->action(fn () => $this->delete())
->color('danger')
->defaultIcon('heroicon-s-trash')
->icon('heroicon-s-trash')
->hidden(fn (Model $record): bool => ! static::canDelete($record));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function getDetachAction(): Tables\Actions\Action
->modalHeading(__('filament::resources/relation-managers/detach.action.modal.heading', ['label' => static::getRecordLabel()]))
->action(fn () => $this->detach())
->color('danger')
->defaultIcon('heroicon-s-x')
->icon('heroicon-s-x')
->hidden(fn (Model $record): bool => ! static::canDetach($record));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function getDissociateAction(): Tables\Actions\Action
->modalHeading(__('filament::resources/relation-managers/dissociate.action.modal.heading', ['label' => static::getRecordLabel()]))
->action(fn () => $this->dissociate())
->color('danger')
->defaultIcon('heroicon-s-x')
->icon('heroicon-s-x')
->hidden(fn (Model $record): bool => ! static::canDissociate($record));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function getEditAction(): Tables\Actions\Action
->modalButton(__('filament::resources/relation-managers/edit.action.modal.actions.save.label'))
->modalHeading(__('filament::resources/relation-managers/edit.action.modal.heading', ['label' => static::getRecordLabel()]))
->action(fn () => $this->save())
->defaultIcon('heroicon-s-pencil')
->icon('heroicon-s-pencil')
->hidden(fn (Model $record): bool => ! static::canEdit($record));
}
}
7 changes: 1 addition & 6 deletions packages/forms/src/Components/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ class Action extends BaseAction
use CanOpenUrl;
use HasTooltip;

protected function setUp(): void
{
$this->view ?? $this->iconButton();

parent::setUp();
}
protected string $view = 'forms::components.actions.icon-button-action';

public function iconButton(): static
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@

class Action extends BaseAction
{
protected function setUp(): void
{
$this->view ?? $this->button();

parent::setUp();
}
protected string $view = 'forms::components.actions.modal.actions.button-action';

public function button(): static
{
Expand Down
20 changes: 2 additions & 18 deletions packages/tables/src/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,10 @@ class Action extends BaseAction
use CanBeOutlined;
use CanOpenUrl;
use Concerns\BelongsToTable;
use Concerns\HasDefaultIcon;
use Concerns\HasRecord;
use HasTooltip;

protected function setUp(): void
{
$this->view ?? $this->link();

parent::setUp();
}
protected string $view = 'tables::actions.link-action';

public function button(): static
{
Expand All @@ -35,7 +29,7 @@ public function button(): static

public function link(): static
{
$this->view($this->getLinkView());
$this->view('tables::actions.link-action');

return $this;
}
Expand All @@ -47,16 +41,6 @@ public function iconButton(): static
return $this;
}

public function getIcon(): ?string
{
return parent::getIcon() ?? $this->getDefaultIcon();
}

protected function getLinkView(): string
{
return 'tables::actions.link-action';
}

public function call(array $data = [])
{
if ($this->isHidden()) {
Expand Down
7 changes: 1 addition & 6 deletions packages/tables/src/Actions/BulkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ class BulkAction extends BaseAction
use Concerns\CanDeselectRecordsAfterCompletion;
use Concerns\HasRecords;

protected function setUp(): void
{
$this->view ?? $this->view('tables::actions.bulk-action');

parent::setUp();
}
protected string $view = 'tables::actions.bulk-action';

public function call(array $data = [])
{
Expand Down
34 changes: 0 additions & 34 deletions packages/tables/src/Actions/Concerns/HasDefaultIcon.php

This file was deleted.

7 changes: 1 addition & 6 deletions packages/tables/src/Actions/Modal/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@

class Action extends BaseAction
{
protected function setUp(): void
{
$this->view ?? $this->button();

parent::setUp();
}
protected string $view = 'tables::actions.modal.actions.button-action';

public function button(): static
{
Expand Down
2 changes: 1 addition & 1 deletion packages/tables/src/Actions/ReplicateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function setUp(): void
return $action->callAfterReplicaSaved($replica, $data);
});

$this->defaultIcon('heroicon-s-duplicate');
$this->icon('heroicon-s-duplicate');
}

public function beforeReplicaSaved(Closure $callback): static
Expand Down

0 comments on commit 8e27cdd

Please sign in to comment.