Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table header action now extends Filament\Actions\Action #132

Closed
Michael-HEIW opened this issue Oct 30, 2023 · 5 comments
Closed

Table header action now extends Filament\Actions\Action #132

Michael-HEIW opened this issue Oct 30, 2023 · 5 comments

Comments

@Michael-HEIW
Copy link

Following the documentation for Actions\Tables\ExportAction for table header actions, this now throws an exception in Filament v3

use pxlrbt\FilamentExcel\Actions\Tables\ExportAction;

// ...

    protected function getHeaderActions(): array
    {
        return [
            ExportAction::make()->exports([
                ExcelExport::make('table')->fromTable(),
            ])
        ];
    }

// ....

This now throws an exception:

InvalidArgumentException
PHP 8.2.9
10.29.0
Header actions must be an instance of Filament\Actions\Action, or Filament\Actions\ActionGroup.

The fix is to update pxlrbt/filament-excel/src/Actions/Tables/ExportAction.php

- use Filament\Tables\Actions\Action;
+ use Filament\Actions\Action; 

The export action then works as expected.

@buzkall
Copy link

buzkall commented Oct 31, 2023

The merged PR #133 breaks the code if you're adding a header option directly to the table function in the resource like this

->headerActions([
      ExportAction::make()->exports( [
              ExcelExport::make()->fromTable()
      ])
])

with version 2.1.7 throws exception "Method pxlrbt\FilamentExcel\Actions\Tables\ExportAction::table does not exist."
with version 2.1.6 works

@saulens22
Copy link

Yes, it seems to be broken.

getHeaderActions() is a method used for pages, so pxlrbt\FilamentExcel\Actions\Pages\ExportAction should be used.

pxlrbt\FilamentExcel\Actions\Tables\ExportAction should be only used like this:

return $table
  ->columns([...])
  ->headerActions([
      \pxlrbt\FilamentExcel\Actions\Tables\ExportAction::make('myexportaction')->exports([
          // export logic
      ]),
  ]);

Pull request #133 should be reverted.

@pxlrbt
Copy link
Owner

pxlrbt commented Oct 31, 2023

Thanks for confirming. I just reverted the PR.

@pxlrbt
Copy link
Owner

pxlrbt commented Oct 31, 2023

@saulens22 Thanks for pointing out that the wrong Action was used.

@Michael-HEIW
Copy link
Author

Sorry for the problem, that was not my intension.

I tried the return $table->headerAction it worked perfect.

@pxlrbt pxlrbt closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants