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
25 changes: 20 additions & 5 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

permissions:
contents: write
pull-requests: write

jobs:
update:
Expand Down Expand Up @@ -34,9 +35,23 @@ jobs:
latest-version: ${{ github.event.release.name }}
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v7
- name: Open changelog PR
id: cpr
uses: peter-evans/create-pull-request@v7
with:
branch: ${{ steps.branch.outputs.name }}
commit_message: Update CHANGELOG
file_pattern: CHANGELOG.md
base: ${{ steps.branch.outputs.name }}
Comment on lines +38 to +42
branch: chore/changelog-${{ github.event.release.tag_name }}
delete-branch: true
commit-message: "chore: update CHANGELOG for ${{ github.event.release.tag_name }}"
title: "chore: update CHANGELOG for ${{ github.event.release.tag_name }}"
body: |
Auto-generated CHANGELOG update for release ${{ github.event.release.tag_name }}.

Release notes: ${{ github.event.release.html_url }}
labels: skip-changelog

- name: Enable auto-merge
if: steps.cpr.outputs.pull-request-operation == 'created'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash "${{ steps.cpr.outputs.pull-request-number }}"
2 changes: 1 addition & 1 deletion docs/content/2.essentials/2.customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function board(Board $board): Board
->options(['low' => 'Low', 'medium' => 'Medium', 'high' => 'High'])
->default('medium'),
])
->mutateFormDataUsing(function (array $data, array $arguments): array {
->mutateDataUsing(function (array $data, array $arguments): array {
if (isset($arguments['column'])) {
$data['status'] = $arguments['column'];
$data['position'] = $this->getBoardPositionInColumn($arguments['column']);
Expand Down
2 changes: 1 addition & 1 deletion docs/content/2.essentials/5.troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class TaskBoard extends BoardPage

```php
CreateAction::make()
->mutateFormDataUsing(function (array $data, array $arguments): array {
->mutateDataUsing(function (array $data, array $arguments): array {
if (isset($arguments['column'])) {
$data['status'] = $arguments['column'];
$data['position'] = $this->getBoardPositionInColumn($arguments['column']);
Expand Down
17 changes: 12 additions & 5 deletions src/BoardResourcePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Filament\Actions\Exceptions\ActionNotResolvableException;
use Filament\Forms\Contracts\HasForms;
use Filament\Resources\Pages\Page;
use Filament\Tables\Contracts\HasTable;
use Livewire\Attributes\Url;
use Relaticle\Flowforge\Concerns\BaseBoard;
use Relaticle\Flowforge\Concerns\InteractsWithBoard;
Expand Down Expand Up @@ -86,7 +87,7 @@ protected function resolveActions(array $actions, bool $isMounting = true): arra
$resolvedAction = $this->resolveBoardAction($action, $resolvedActions);
} elseif (filled($action['context']['schemaComponent'] ?? null)) {
$resolvedAction = $this->resolveSchemaComponentAction($action, $resolvedActions);
} elseif (filled($action['context']['table'] ?? null)) {
} elseif ($this instanceof HasTable && filled($action['context']['table'] ?? null)) {
$resolvedAction = $this->resolveTableAction($action, $resolvedActions);
} else {
$resolvedAction = $this->resolveAction($action, $resolvedActions);
Expand All @@ -96,15 +97,21 @@ protected function resolveActions(array $actions, bool $isMounting = true): arra
continue;
}

if (filled($action['arguments'] ?? [])) {
$resolvedAction->mergeArguments($action['arguments']);
}

$resolvedAction->nestingIndex($actionNestingIndex);
$resolvedAction->boot();

$resolvedActions[] = $resolvedAction;

$this->cacheSchema(
"mountedActionSchema{$actionNestingIndex}",
$this->getMountedActionSchema($actionNestingIndex, $resolvedAction),
);
if ($isMounting) {
$this->cacheSchema(
"mountedActionSchema{$actionNestingIndex}",
$this->getMountedActionSchema($actionNestingIndex, $resolvedAction),
);
}
}

return $resolvedActions;
Expand Down
20 changes: 20 additions & 0 deletions tests/Feature/BoardResourcePageColumnActionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use Filament\Actions\Testing\TestAction;
use Livewire\Livewire;
use Relaticle\Flowforge\Tests\Fixtures\Task;
use Relaticle\Flowforge\Tests\Fixtures\TestBoardResourcePage;

test('column action receives column argument in mutateDataUsing', function () {
Livewire::test(TestBoardResourcePage::class)
->callAction(
TestAction::make('createTask')->arguments(['column' => 'in_progress']),
['title' => 'New Task'],
);

$task = Task::where('title', 'New Task')->firstOrFail();

expect($task->status)->toBe('in_progress');
});
48 changes: 48 additions & 0 deletions tests/Fixtures/TestBoardResourcePage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

namespace Relaticle\Flowforge\Tests\Fixtures;

use Filament\Actions\CreateAction;
use Filament\Forms\Components\TextInput;
use Illuminate\Database\Eloquent\Builder;
use Relaticle\Flowforge\Board;
use Relaticle\Flowforge\BoardResourcePage;
use Relaticle\Flowforge\Column;

class TestBoardResourcePage extends BoardResourcePage
{
protected static string $resource = TestResource::class;

public function getEloquentQuery(): Builder
{
return Task::query();
}

public function board(Board $board): Board
{
return $board
->query($this->getEloquentQuery())
->recordTitleAttribute('title')
->columnIdentifier('status')
->positionIdentifier('order_position')
->columns([
Column::make('todo')->label('To Do'),
Column::make('in_progress')->label('In Progress'),
Column::make('completed')->label('Completed'),
])
->columnActions([
CreateAction::make('createTask')
->model(Task::class)
->schema([
TextInput::make('title')->required(),
])
->mutateDataUsing(function (array $data, array $arguments): array {
$data['status'] = $arguments['column'] ?? 'todo';

return $data;
}),
]);
}
}
3 changes: 3 additions & 0 deletions tests/Fixtures/TestPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public function panel(Panel $panel): Panel
->pages([
TestBoard::class,
])
->resources([
TestResource::class,
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
Expand Down
23 changes: 23 additions & 0 deletions tests/Fixtures/TestResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Relaticle\Flowforge\Tests\Fixtures;

use Filament\Resources\Resource;

class TestResource extends Resource
{
protected static ?string $model = Task::class;

protected static bool $shouldCheckPolicyExistence = false;

protected static bool $shouldSkipAuthorization = true;

public static function getPages(): array
{
return [
'index' => TestBoardResourcePage::route('/'),
];
}
}
2 changes: 2 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Filament\Forms\FormsServiceProvider;
use Filament\Infolists\InfolistsServiceProvider;
use Filament\Notifications\NotificationsServiceProvider;
use Filament\Schemas\SchemasServiceProvider;
use Filament\Support\SupportServiceProvider;
use Filament\Tables\TablesServiceProvider;
use Filament\Widgets\WidgetsServiceProvider;
Expand Down Expand Up @@ -48,6 +49,7 @@ protected function getPackageProviders($app): array
InfolistsServiceProvider::class,
LivewireServiceProvider::class,
NotificationsServiceProvider::class,
SchemasServiceProvider::class,
SupportServiceProvider::class,
TablesServiceProvider::class,
WidgetsServiceProvider::class,
Expand Down