diff --git a/resources/views/modern/livewire/card.blade.php b/resources/views/modern/livewire/card.blade.php index f05d31e1a..a2db9261a 100644 --- a/resources/views/modern/livewire/card.blade.php +++ b/resources/views/modern/livewire/card.blade.php @@ -1,12 +1,15 @@ @props(['columnId', 'record', 'laneId' => null]) @php + use Filament\Actions\Action; + use Filament\Actions\ActionGroup; use Relaticle\Flowforge\Components\CardTitle; use function Filament\Support\generate_href_html; $board = $this->getBoard(); $recordActions = $board->getBoardRecordActions($record); $link = $board->getCardLink($recordActions); + $visibleRecordActions = array_filter($recordActions, fn (Action | ActionGroup $action): bool => $action->isVisible()); $href = $link['url'] ? generate_href_html($link['url'], $link['openInNewTab'], hasNestedClickEventHandler: true) : null; $mountAction = $link['action']; $isDraggable = $board->getPositionIdentifierAttribute() !== null; @@ -25,9 +28,9 @@ @if($isDraggable) x-sortable-handle @endif data-position="{{ $record['position'] ?? '' }}" > - @if (count($recordActions) > 0) + @if (count($visibleRecordActions) > 0)
- +
@endif diff --git a/resources/views/modern/livewire/column-header.blade.php b/resources/views/modern/livewire/column-header.blade.php index 84d770e3d..566b25f18 100644 --- a/resources/views/modern/livewire/column-header.blade.php +++ b/resources/views/modern/livewire/column-header.blade.php @@ -1,11 +1,13 @@ @props(['columnId', 'column', 'isCollapsed' => false]) @php + use Filament\Actions\Action; + use Filament\Actions\ActionGroup; use Filament\Support\Enums\IconSize; use Relaticle\Flowforge\Support\ColorResolver; use function Filament\Support\get_color_css_variables; - $actions = $this->getBoardColumnActions($columnId); + $actions = array_values(array_filter($this->getBoardColumnActions($columnId), fn (Action | ActionGroup $action): bool => $action->isVisible())); $dotColor = ColorResolver::resolve($column['color'] ?? null); $createAction = $this->getBoardCreateCardAction($columnId) ?->getClone() diff --git a/tests/Fixtures/Modern/TestHiddenActionsBoard.php b/tests/Fixtures/Modern/TestHiddenActionsBoard.php new file mode 100644 index 000000000..5aa9feb54 --- /dev/null +++ b/tests/Fixtures/Modern/TestHiddenActionsBoard.php @@ -0,0 +1,38 @@ +query($this->getEloquentQuery()) + ->recordTitleAttribute('title') + ->columnIdentifier('status') + ->columns([ + Column::make('todo')->label('To Do'), + ]) + ->columnActions([ + Action::make('renameColumn')->action(function (): void {})->hidden(), + Action::make('clearColumn')->action(function (): void {})->hidden(), + ]) + ->cardActions([ + Action::make('edit')->action(function (): void {})->hidden(), + Action::make('delete')->action(function (): void {})->hidden(), + ]); + } +} diff --git a/tests/Modern/Feature/CardShellTest.php b/tests/Modern/Feature/CardShellTest.php index e83a5212e..0575d3d9f 100644 --- a/tests/Modern/Feature/CardShellTest.php +++ b/tests/Modern/Feature/CardShellTest.php @@ -5,6 +5,7 @@ use Livewire\Livewire; use Relaticle\Flowforge\Tests\Fixtures\Modern\Task; use Relaticle\Flowforge\Tests\Fixtures\Modern\TestBoardResourcePage; +use Relaticle\Flowforge\Tests\Fixtures\Modern\TestHiddenActionsBoard; beforeEach(function () { Task::create(['title' => 'Shell card', 'status' => 'todo', 'order_position' => '65535.0000000000']); @@ -31,3 +32,15 @@ Livewire::test(TestBoardResourcePage::class) ->assertSeeHtml('wire:key="card-board-' . $task->id . '"'); }); + +test('a card whose actions are all hidden renders no action menu', function () { + Livewire::test(TestHiddenActionsBoard::class) + ->assertSeeHtml('ff-card-body') + ->assertDontSeeHtml('ff-card-actions'); +}); + +test('a column whose actions are all hidden renders no action menu', function () { + Livewire::test(TestHiddenActionsBoard::class) + ->assertSeeHtml('ff-column-title') + ->assertDontSeeHtml('ff-column-actions'); +});