diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 9fa8b0a1f..86798af0d 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -6,6 +6,7 @@ on: permissions: contents: write + pull-requests: write jobs: update: @@ -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 }} + 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 }}" diff --git a/docs/content/2.essentials/2.customization.md b/docs/content/2.essentials/2.customization.md index 3b9d72434..5b31379d8 100644 --- a/docs/content/2.essentials/2.customization.md +++ b/docs/content/2.essentials/2.customization.md @@ -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']); diff --git a/docs/content/2.essentials/5.troubleshooting.md b/docs/content/2.essentials/5.troubleshooting.md index 9b041d8f0..855a6b012 100644 --- a/docs/content/2.essentials/5.troubleshooting.md +++ b/docs/content/2.essentials/5.troubleshooting.md @@ -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']); diff --git a/src/BoardResourcePage.php b/src/BoardResourcePage.php index 313801742..7a12389bf 100644 --- a/src/BoardResourcePage.php +++ b/src/BoardResourcePage.php @@ -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; @@ -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); @@ -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; diff --git a/tests/Feature/BoardResourcePageColumnActionTest.php b/tests/Feature/BoardResourcePageColumnActionTest.php new file mode 100644 index 000000000..d6ea782d9 --- /dev/null +++ b/tests/Feature/BoardResourcePageColumnActionTest.php @@ -0,0 +1,20 @@ +callAction( + TestAction::make('createTask')->arguments(['column' => 'in_progress']), + ['title' => 'New Task'], + ); + + $task = Task::where('title', 'New Task')->firstOrFail(); + + expect($task->status)->toBe('in_progress'); +}); diff --git a/tests/Fixtures/TestBoardResourcePage.php b/tests/Fixtures/TestBoardResourcePage.php new file mode 100644 index 000000000..e27a672c1 --- /dev/null +++ b/tests/Fixtures/TestBoardResourcePage.php @@ -0,0 +1,48 @@ +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; + }), + ]); + } +} diff --git a/tests/Fixtures/TestPanelProvider.php b/tests/Fixtures/TestPanelProvider.php index b74c3d3d9..0ca4ad8af 100644 --- a/tests/Fixtures/TestPanelProvider.php +++ b/tests/Fixtures/TestPanelProvider.php @@ -29,6 +29,9 @@ public function panel(Panel $panel): Panel ->pages([ TestBoard::class, ]) + ->resources([ + TestResource::class, + ]) ->middleware([ EncryptCookies::class, AddQueuedCookiesToResponse::class, diff --git a/tests/Fixtures/TestResource.php b/tests/Fixtures/TestResource.php new file mode 100644 index 000000000..296cb88f6 --- /dev/null +++ b/tests/Fixtures/TestResource.php @@ -0,0 +1,23 @@ + TestBoardResourcePage::route('/'), + ]; + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index ba4dc40c7..eb6b6e150 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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; @@ -48,6 +49,7 @@ protected function getPackageProviders($app): array InfolistsServiceProvider::class, LivewireServiceProvider::class, NotificationsServiceProvider::class, + SchemasServiceProvider::class, SupportServiceProvider::class, TablesServiceProvider::class, WidgetsServiceProvider::class,