diff --git a/app/Filament/Resources/UserResource.php b/app/Filament/Resources/UserResource.php index d6d01caf..97ad4b3a 100644 --- a/app/Filament/Resources/UserResource.php +++ b/app/Filament/Resources/UserResource.php @@ -86,21 +86,23 @@ public static function table(Table $table): Table // ]) ->actions([ - Tables\Actions\EditAction::make(), - Tables\Actions\Action::make('view_on_stripe') - ->label('View on Stripe') - ->color('gray') - ->icon('heroicon-o-arrow-top-right-on-square') - ->url(fn (User $record) => 'https://dashboard.stripe.com/customers/'.$record->stripe_id) - ->openUrlInNewTab() - ->visible(fn (User $record) => filled($record->stripe_id)), - Tables\Actions\Action::make('view_on_anystack') - ->label('View on Anystack') - ->color('gray') - ->icon('heroicon-o-arrow-top-right-on-square') - ->url(fn (User $record) => 'https://app.anystack.sh/contacts/'.$record->anystack_contact_id) - ->openUrlInNewTab() - ->visible(fn (User $record) => filled($record->anystack_contact_id)), + Tables\Actions\ActionGroup::make([ + Tables\Actions\EditAction::make(), + Tables\Actions\Action::make('view_on_stripe') + ->label('View on Stripe') + ->color('gray') + ->icon('heroicon-o-arrow-top-right-on-square') + ->url(fn (User $record) => 'https://dashboard.stripe.com/customers/'.$record->stripe_id) + ->openUrlInNewTab() + ->visible(fn (User $record) => filled($record->stripe_id)), + Tables\Actions\Action::make('view_on_anystack') + ->label('View on Anystack') + ->color('gray') + ->icon('heroicon-o-arrow-top-right-on-square') + ->url(fn (User $record) => 'https://app.anystack.sh/contacts/'.$record->anystack_contact_id) + ->openUrlInNewTab() + ->visible(fn (User $record) => filled($record->anystack_contact_id)), + ])->label('Actions')->icon('heroicon-m-ellipsis-vertical'), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ diff --git a/app/Filament/Resources/UserResource/Pages/EditUser.php b/app/Filament/Resources/UserResource/Pages/EditUser.php index a0d9894e..30eff4a1 100644 --- a/app/Filament/Resources/UserResource/Pages/EditUser.php +++ b/app/Filament/Resources/UserResource/Pages/EditUser.php @@ -15,60 +15,81 @@ class EditUser extends EditRecord protected function getHeaderActions(): array { return [ - Actions\Action::make('createStripeCustomer') - ->label('Create Stripe Customer') - ->color('gray') - ->icon('heroicon-o-credit-card') - ->action(function (User $record) { - if ($record->hasStripeId()) { - Notification::make() - ->danger() - ->title('User is already a Stripe customer.') - ->send(); + Actions\ActionGroup::make([ + Actions\Action::make('createStripeCustomer') + ->label('Create Stripe Customer') + ->color('gray') + ->icon('heroicon-o-credit-card') + ->action(function (User $record) { + if ($record->hasStripeId()) { + Notification::make() + ->danger() + ->title('User is already a Stripe customer.') + ->send(); - return; - } + return; + } - $record->createOrGetStripeCustomer(); - }) - ->visible(fn (User $record) => empty($record->stripe_id)), + $record->createOrGetStripeCustomer(); + }) + ->visible(fn (User $record) => empty($record->stripe_id)), - Actions\Action::make('createAnystackLicense') - ->label('Create Anystack License') - ->color('gray') - ->icon('heroicon-o-key') - ->form([ - \Filament\Forms\Components\Select::make('subscription') - ->label('Subscription Plan') - ->options(collect(\App\Enums\Subscription::cases())->mapWithKeys(function ($case) { - return [$case->value => $case->name()]; - })) - ->required(), - ]) - ->action(function (array $data, User $record) { - $subscription = \App\Enums\Subscription::from($data['subscription']); + Actions\Action::make('createAnystackLicense') + ->label('Create Anystack License') + ->color('gray') + ->icon('heroicon-o-key') + ->form([ + \Filament\Forms\Components\Select::make('subscription') + ->label('Subscription Plan') + ->options(collect(\App\Enums\Subscription::cases())->mapWithKeys(function ($case) { + return [$case->value => $case->name()]; + })) + ->required(), + ]) + ->action(function (array $data, User $record) { + $subscription = \App\Enums\Subscription::from($data['subscription']); - \App\Jobs\CreateAnystackLicenseJob::dispatch( - $record, - $subscription, - null, - $record->first_name, - $record->last_name, - ); - }), + \App\Jobs\CreateAnystackLicenseJob::dispatch( + $record, + $subscription, + null, + $record->first_name, + $record->last_name, + ); + }), - Actions\Action::make('sendPasswordReset') - ->label('Send Password Reset') - ->color('gray') - ->icon('heroicon-o-envelope') - ->requiresConfirmation() - ->action(function (User $record) { - \Illuminate\Support\Facades\Password::sendResetLink( - ['email' => $record->email] - ); - }), + Actions\Action::make('sendPasswordReset') + ->label('Send Password Reset') + ->color('gray') + ->icon('heroicon-o-envelope') + ->requiresConfirmation() + ->action(function (User $record) { + \Illuminate\Support\Facades\Password::sendResetLink( + ['email' => $record->email] + ); + }), - Actions\DeleteAction::make(), + Actions\Action::make('view_on_stripe') + ->label('View on Stripe') + ->color('gray') + ->icon('heroicon-o-arrow-top-right-on-square') + ->url(fn (User $record) => 'https://dashboard.stripe.com/customers/'.$record->stripe_id) + ->openUrlInNewTab() + ->visible(fn (User $record) => filled($record->stripe_id)), + + Actions\Action::make('view_on_anystack') + ->label('View on Anystack') + ->color('gray') + ->icon('heroicon-o-arrow-top-right-on-square') + ->url(fn (User $record) => 'https://app.anystack.sh/contacts/'.$record->anystack_contact_id) + ->openUrlInNewTab() + ->visible(fn (User $record) => filled($record->anystack_contact_id)), + + Actions\DeleteAction::make(), + + ]) + ->label('Actions') + ->icon('heroicon-m-ellipsis-vertical'), ]; } }