Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions resources/views/modern/livewire/card.blade.php
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -25,9 +28,9 @@
@if($isDraggable) x-sortable-handle @endif
data-position="{{ $record['position'] ?? '' }}"
>
@if (count($recordActions) > 0)
@if (count($visibleRecordActions) > 0)
<div class="ff-card-actions">
<x-filament-actions::group :actions="$recordActions" />
<x-filament-actions::group :actions="$visibleRecordActions" />
</div>
@endif

Expand Down
4 changes: 3 additions & 1 deletion resources/views/modern/livewire/column-header.blade.php
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
38 changes: 38 additions & 0 deletions tests/Fixtures/Modern/TestHiddenActionsBoard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Relaticle\Flowforge\Tests\Fixtures\Modern;

use Filament\Actions\Action;
use Illuminate\Database\Eloquent\Builder;
use Relaticle\Flowforge\Board;
use Relaticle\Flowforge\Column;
use Relaticle\Flowforge\Modern\BoardPage;

class TestHiddenActionsBoard extends BoardPage
{
public function getEloquentQuery(): Builder
{
return Task::query();
}

public function board(Board $board): Board
{
return $board
->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(),
]);
}
}
13 changes: 13 additions & 0 deletions tests/Modern/Feature/CardShellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand All @@ -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');
});
Loading