mirror of
https://github.com/filamentphp/filament.git
synced 2026-10-24 23:35:30 +08:00
Use action name best practice
This commit is contained in:
@@ -16,49 +16,49 @@ class Actions extends Component implements HasActions
|
||||
|
||||
public function buttonAction(): Action
|
||||
{
|
||||
return Action::make('buttonAction')
|
||||
return Action::make('button')
|
||||
->label('Edit')
|
||||
->button();
|
||||
}
|
||||
|
||||
public function linkAction(): Action
|
||||
{
|
||||
return Action::make('linkAction')
|
||||
return Action::make('link')
|
||||
->label('Edit')
|
||||
->link();
|
||||
}
|
||||
|
||||
public function iconButtonAction(): Action
|
||||
{
|
||||
return Action::make('iconButtonAction')
|
||||
return Action::make('iconButton')
|
||||
->icon('heroicon-o-pencil-square')
|
||||
->iconButton();
|
||||
}
|
||||
|
||||
public function dangerAction(): Action
|
||||
{
|
||||
return Action::make('dangerAction')
|
||||
return Action::make('danger')
|
||||
->label('Delete')
|
||||
->color('danger');
|
||||
}
|
||||
|
||||
public function largeAction(): Action
|
||||
{
|
||||
return Action::make('largeAction')
|
||||
return Action::make('large')
|
||||
->label('Create')
|
||||
->size('lg');
|
||||
}
|
||||
|
||||
public function iconAction(): Action
|
||||
{
|
||||
return Action::make('iconAction')
|
||||
return Action::make('icon')
|
||||
->label('Edit')
|
||||
->icon('heroicon-m-pencil-square');
|
||||
}
|
||||
|
||||
public function iconAfterAction(): Action
|
||||
{
|
||||
return Action::make('iconAfterAction')
|
||||
return Action::make('iconAfter')
|
||||
->label('Edit')
|
||||
->icon('heroicon-m-pencil-square')
|
||||
->iconPosition('after');
|
||||
@@ -66,7 +66,7 @@ class Actions extends Component implements HasActions
|
||||
|
||||
public function indicatorAction(): Action
|
||||
{
|
||||
return Action::make('indicatorAction')
|
||||
return Action::make('indicator')
|
||||
->iconButton()
|
||||
->icon('heroicon-m-funnel')
|
||||
->indicator(5);
|
||||
@@ -74,7 +74,7 @@ class Actions extends Component implements HasActions
|
||||
|
||||
public function successIndicatorAction(): Action
|
||||
{
|
||||
return Action::make('successIndicatorAction')
|
||||
return Action::make('successIndicator')
|
||||
->iconButton()
|
||||
->icon('heroicon-m-funnel')
|
||||
->indicator(5)
|
||||
@@ -83,7 +83,7 @@ class Actions extends Component implements HasActions
|
||||
|
||||
public function outlinedAction(): Action
|
||||
{
|
||||
return Action::make('outlinedAction')
|
||||
return Action::make('outlined')
|
||||
->label('Edit')
|
||||
->button()
|
||||
->outlined();
|
||||
@@ -91,7 +91,7 @@ class Actions extends Component implements HasActions
|
||||
|
||||
public function inlineIconAction(): Action
|
||||
{
|
||||
return Action::make('inlineIconAction')
|
||||
return Action::make('inlineIcon')
|
||||
->icon('heroicon-o-pencil-square')
|
||||
->iconButton()
|
||||
->inline();
|
||||
@@ -99,7 +99,7 @@ class Actions extends Component implements HasActions
|
||||
|
||||
public function confirmationModalAction(): Action
|
||||
{
|
||||
return Action::make('confirmationModalAction')
|
||||
return Action::make('confirmationModal')
|
||||
->label('Delete')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
@@ -108,7 +108,7 @@ class Actions extends Component implements HasActions
|
||||
|
||||
public function confirmationModalCustomTextAction(): Action
|
||||
{
|
||||
return Action::make('confirmationModalCustomTextAction')
|
||||
return Action::make('confirmationModalCustomText')
|
||||
->label('Delete')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
@@ -120,7 +120,7 @@ class Actions extends Component implements HasActions
|
||||
|
||||
public function modalFormAction(): Action
|
||||
{
|
||||
return Action::make('modalFormAction')
|
||||
return Action::make('modalForm')
|
||||
->label('Update author')
|
||||
->form([
|
||||
Select::make('authorId')
|
||||
@@ -132,7 +132,7 @@ class Actions extends Component implements HasActions
|
||||
|
||||
public function wizardAction(): Action
|
||||
{
|
||||
return Action::make('wizardAction')
|
||||
return Action::make('wizard')
|
||||
->label('Create')
|
||||
->steps([
|
||||
Step::make('Name')
|
||||
@@ -157,7 +157,7 @@ class Actions extends Component implements HasActions
|
||||
|
||||
public function slideOverAction(): Action
|
||||
{
|
||||
return Action::make('slideOverAction')
|
||||
return Action::make('slideOver')
|
||||
->label('Update author')
|
||||
->form([
|
||||
Select::make('authorId')
|
||||
|
||||
@@ -38,7 +38,7 @@ class EmailVerificationPrompt extends CardPage
|
||||
|
||||
public function resendNotificationAction(): Action
|
||||
{
|
||||
return Action::make('resendNotificationAction')
|
||||
return Action::make('resendNotification')
|
||||
->link()
|
||||
->label(__('filament::pages/auth/email-verification/email-verification-prompt.buttons.resend_notification.label') . '.')
|
||||
->action(function (): void {
|
||||
|
||||
@@ -98,14 +98,14 @@ class Login extends CardPage
|
||||
|
||||
public function authenticateAction(): Action
|
||||
{
|
||||
return Action::make('authenticateAction')
|
||||
return Action::make('authenticate')
|
||||
->label(__('filament::pages/auth/login.buttons.authenticate.label'))
|
||||
->submit('authenticate');
|
||||
}
|
||||
|
||||
public function registerAction(): Action
|
||||
{
|
||||
return Action::make('registerAction')
|
||||
return Action::make('register')
|
||||
->link()
|
||||
->label(__('filament::pages/auth/login.buttons.register.label'))
|
||||
->url(filament()->getRegistrationUrl());
|
||||
|
||||
@@ -105,14 +105,14 @@ class RequestPasswordReset extends CardPage
|
||||
|
||||
public function requestAction(): Action
|
||||
{
|
||||
return Action::make('requestAction')
|
||||
return Action::make('request')
|
||||
->label(__('filament::pages/auth/password-reset/request-password-reset.buttons.request.label'))
|
||||
->submit('request');
|
||||
}
|
||||
|
||||
public function loginAction(): Action
|
||||
{
|
||||
return Action::make('loginAction')
|
||||
return Action::make('login')
|
||||
->link()
|
||||
->label(__('filament::pages/auth/password-reset/request-password-reset.buttons.login.label'))
|
||||
->icon(match (__('filament::layout.direction')) {
|
||||
|
||||
@@ -129,7 +129,7 @@ class ResetPassword extends CardPage
|
||||
|
||||
public function resetPasswordAction(): Action
|
||||
{
|
||||
return Action::make('resetPasswordAction')
|
||||
return Action::make('resetPassword')
|
||||
->label(__('filament::pages/auth/password-reset/reset-password.buttons.reset.label'))
|
||||
->submit('resetPassword');
|
||||
}
|
||||
|
||||
@@ -113,14 +113,14 @@ class Register extends CardPage
|
||||
|
||||
public function registerAction(): Action
|
||||
{
|
||||
return Action::make('registerAction')
|
||||
return Action::make('register')
|
||||
->label(__('filament::pages/auth/register.buttons.register.label'))
|
||||
->submit('register');
|
||||
}
|
||||
|
||||
public function loginAction(): Action
|
||||
{
|
||||
return Action::make('loginAction')
|
||||
return Action::make('login')
|
||||
->link()
|
||||
->label(__('filament::pages/auth/register.buttons.login.label'))
|
||||
->url(filament()->getLoginUrl());
|
||||
|
||||
@@ -120,7 +120,7 @@ abstract class RegisterTenant extends CardPage
|
||||
|
||||
public function registerAction(): Action
|
||||
{
|
||||
return Action::make('registerAction')
|
||||
return Action::make('register')
|
||||
->label(static::getLabel())
|
||||
->submit('register');
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ it('can resend notification', function () {
|
||||
$this->actingAs($userToVerify);
|
||||
|
||||
livewire(EmailVerificationPrompt::class)
|
||||
->callAction('resendNotificationAction')
|
||||
->callAction('resendNotification')
|
||||
->assertNotified();
|
||||
|
||||
Notification::assertSentTo($userToVerify, VerifyEmail::class);
|
||||
@@ -47,14 +47,14 @@ it('can throttle resend notification attempts', function () {
|
||||
|
||||
foreach (range(1, 2) as $i) {
|
||||
livewire(EmailVerificationPrompt::class)
|
||||
->callAction('resendNotificationAction')
|
||||
->callAction('resendNotification')
|
||||
->assertNotified();
|
||||
}
|
||||
|
||||
Notification::assertSentToTimes($userToVerify, VerifyEmail::class, times: 2);
|
||||
|
||||
livewire(EmailVerificationPrompt::class)
|
||||
->callAction('resendNotificationAction')
|
||||
->callAction('resendNotification')
|
||||
->assertNotified();
|
||||
|
||||
Notification::assertSentToTimes($userToVerify, VerifyEmail::class, times: 2);
|
||||
|
||||
Reference in New Issue
Block a user