-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: confirmation before any action. (#1599)
* adding macros functions and methods for Button class * adding English translations for default message * writing tests for confirm and confirmPrompt method * fix: test ConfirmPromptTest.php * style: adding line break in both macro functions * use camel case for $confirm_value to $confirmValue * adding missing multi_sort translations * adding english lang messages in all language * wip we change lang translation separator(-) to underscore(-) to make it similar to all other translations. * pint --------- Co-authored-by: luanfreitasdev <[email protected]>
- Loading branch information
1 parent
1899b41
commit c0d2be2
Showing
22 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
use PowerComponents\LivewirePowerGrid\Button; | ||
use PowerComponents\LivewirePowerGrid\Tests\Concerns\Components\DishTableBase; | ||
|
||
use function PowerComponents\LivewirePowerGrid\Tests\Plugins\livewire; | ||
|
||
$component = new class () extends DishTableBase { | ||
public function actions($row): array | ||
{ | ||
return [ | ||
Button::make('confirm-prompt') | ||
->slot('confirm-prompt: ' . $row->id) | ||
->confirmPrompt("$row->id Are you sure? Enter CONFIRM to confirm", "CONFIRM"), | ||
]; | ||
} | ||
}; | ||
|
||
dataset('action:confirm-prompt', [ | ||
'tailwind' => [$component::class, (object) ['theme' => 'tailwind', 'join' => false]], | ||
'bootstrap' => [$component::class, (object) ['theme' => 'bootstrap', 'join' => false]], | ||
'tailwind join' => [$component::class, (object) ['theme' => 'tailwind', 'join' => true]], | ||
'bootstrap join' => [$component::class, (object) ['theme' => 'bootstrap', 'join' => true]], | ||
]); | ||
|
||
it('properly displays "confirm" on button click', function (string $component, object $params) { | ||
livewire($component, [ | ||
'join' => $params->join, | ||
]) | ||
->call($params->theme) | ||
->set('search', 'Pastel de Nata') | ||
->assertSeeHtml('wire:confirm.prompt="1 Are you sure? Enter CONFIRM to confirm |CONFIRM"') | ||
->assertDontSeeHtml('wire:confirm.prompt="2 Are you sure? Enter CONFIRM to confirm |CONFIRM"') | ||
->set('search', 'Peixada da chef Nábia') | ||
->assertSeeHtml('wire:confirm.prompt="2 Are you sure? Enter CONFIRM to confirm |CONFIRM"') | ||
->assertDontSeeHtml('wire:confirm.prompt="1 Are you sure? Enter CONFIRM to confirm |CONFIRM"'); | ||
}) | ||
->with('action:confirm-prompt') | ||
->group('action'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
use PowerComponents\LivewirePowerGrid\Button; | ||
use PowerComponents\LivewirePowerGrid\Tests\Concerns\Components\DishTableBase; | ||
|
||
use function PowerComponents\LivewirePowerGrid\Tests\Plugins\livewire; | ||
|
||
$component = new class () extends DishTableBase { | ||
public function actions($row): array | ||
{ | ||
return [ | ||
Button::make('confirm') | ||
->slot('confirm: ' . $row->id) | ||
->confirm('Are you sure? ' . $row->id), | ||
]; | ||
} | ||
}; | ||
|
||
dataset('action:confirm', [ | ||
'tailwind' => [$component::class, (object) ['theme' => 'tailwind', 'join' => false]], | ||
'bootstrap' => [$component::class, (object) ['theme' => 'bootstrap', 'join' => false]], | ||
'tailwind join' => [$component::class, (object) ['theme' => 'tailwind', 'join' => true]], | ||
'bootstrap join' => [$component::class, (object) ['theme' => 'bootstrap', 'join' => true]], | ||
]); | ||
|
||
it('properly displays "confirm" on button click', function (string $component, object $params) { | ||
livewire($component, [ | ||
'join' => $params->join, | ||
]) | ||
->call($params->theme) | ||
->set('search', 'Pastel de Nata') | ||
->assertSeeHtml('wire:confirm="Are you sure? 1"') | ||
->assertDontSeeHtml('wire:confirm="Are you sure? 2"') | ||
->set('search', 'Peixada da chef Nábia') | ||
->assertSeeHtml('wire:confirm="Are you sure? 2"') | ||
->assertDontSeeHtml('wire:confirm="Are you sure? 1"'); | ||
}) | ||
->with('action:confirm') | ||
->group('action'); |