Skip to content

Commit

Permalink
feat: make column action no exportable by default (#1741)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrYamous authored Oct 19, 2024
1 parent d976eeb commit 12fd5b3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
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

0 comments on commit 12fd5b3

Please sign in to comment.