Skip to content

Commit 12fd5b3

Browse files
authored
feat: make column action no exportable by default (#1741)
1 parent d976eeb commit 12fd5b3

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/Column.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public static function action(string $title): self
9393
{
9494
return (new static())
9595
->title($title)
96-
->isAction();
96+
->isAction()
97+
->visibleInExport(false);
9798
}
9899

99100
public function isAction(): Column

tests/Feature/ExportTest.php

+43
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

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

8+
use PowerComponents\LivewirePowerGrid\{Button,Column};
9+
810
it('properly export xls - all data', function () {
911
livewire(ExportTable::class)
1012
->call('exportToXLS', false)
@@ -85,6 +87,47 @@
8587
expect()->notToBeFileDownloaded($component);
8688
})->requiresOpenSpout();
8789

90+
$exportWithAction = new class () extends ExportTable {
91+
public function columns(): array
92+
{
93+
return [
94+
Column::action('Foo')
95+
->visibleInExport(true),
96+
];
97+
}
98+
99+
public function actions($row): array
100+
{
101+
return [
102+
Button::add('Foo'),
103+
];
104+
}
105+
};
106+
107+
it('properly export xls with action', function (string $component) {
108+
$downloadedFile = livewire($component)
109+
->call('exportToXLS', false)
110+
->assertFileDownloaded('export.xlsx');
111+
112+
$headings = ['Foo'];
113+
114+
expect($downloadedFile)->toBeXLSDownload($headings, []);
115+
})->with('export_with_action')->requiresOpenSpout();
116+
117+
it('properly export csv with action', function (string $component) {
118+
$downloadedFile = livewire($component)
119+
->call('exportToCsv', false)
120+
->assertFileDownloaded('export.csv');
121+
122+
$headings = ['Foo'];
123+
124+
expect($downloadedFile)->toBeCsvDownload($headings, []);
125+
})->with('export_with_action')->requiresOpenSpout();
126+
127+
dataset('export_with_action', [
128+
'data' => [$exportWithAction::class],
129+
]);
130+
88131
/*
89132
|--------------------------------------------------------------------------
90133
| Expectations for this test

0 commit comments

Comments
 (0)