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

feat: make column action no exportable by default #1741

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
3 changes: 2 additions & 1 deletion src/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public static function action(string $title): self
{
return (new static())
->title($title)
->isAction();
->isAction()
->visibleInExport(false);
}

public function isAction(): Column
Expand Down
43 changes: 43 additions & 0 deletions tests/Feature/ExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

use function PowerComponents\LivewirePowerGrid\Tests\Plugins\livewire;

use PowerComponents\LivewirePowerGrid\{Button,Column};

it('properly export xls - all data', function () {
livewire(ExportTable::class)
->call('exportToXLS', false)
Expand Down Expand Up @@ -85,6 +87,47 @@
expect()->notToBeFileDownloaded($component);
})->requiresOpenSpout();

$exportWithAction = new class () extends ExportTable {
public function columns(): array
{
return [
Column::action('Foo')
->visibleInExport(true),
];
}

public function actions($row): array
{
return [
Button::add('Foo'),
];
}
};

it('properly export xls with action', function (string $component) {
$downloadedFile = livewire($component)
->call('exportToXLS', false)
->assertFileDownloaded('export.xlsx');

$headings = ['Foo'];

expect($downloadedFile)->toBeXLSDownload($headings, []);
})->with('export_with_action')->requiresOpenSpout();

it('properly export csv with action', function (string $component) {
$downloadedFile = livewire($component)
->call('exportToCsv', false)
->assertFileDownloaded('export.csv');

$headings = ['Foo'];

expect($downloadedFile)->toBeCsvDownload($headings, []);
})->with('export_with_action')->requiresOpenSpout();

dataset('export_with_action', [
'data' => [$exportWithAction::class],
]);

/*
|--------------------------------------------------------------------------
| Expectations for this test
Expand Down