How to change action color from Gate

(vendor )
// ...
public function table(Table $table): Table
{
return $table
// ...,
->actions([
Tables\Actions\Action::make('download')
->label(__('filament-spatie-backup::backup.components.backup_destination_list.table.actions.download'))
->icon('heroicon-o-arrow-down-tray')
->visible(auth()->user()->can('download-backup'))
// ->color('success')
->action(fn (BackupDestination $record) => Storage::disk($record->disk)->download($record->path)),

Tables\Actions\Action::make('delete')
->label(__('filament-spatie-backup::backup.components.backup_destination_list.table.actions.delete'))
->icon('heroicon-o-trash')
->visible(auth()->user()->can('delete-backup'))
->requiresConfirmation()
// ->color('danger')
->action(function (BackupDestination $record) {
SpatieBackupDestination::create($record->disk, config('backup.backup.name'))
->backups()
->first(function (Backup $backup) use ($record) {
return $backup->path() === $record->path;
})
->delete();

Notification::make()
->title(__('filament-spatie-backup::backup.pages.backups.messages.backup_delete_success'))
->success()
->send();
}),
])
->bulkActions([
// ...
]);
}
// ...
public function table(Table $table): Table
{
return $table
// ...,
->actions([
Tables\Actions\Action::make('download')
->label(__('filament-spatie-backup::backup.components.backup_destination_list.table.actions.download'))
->icon('heroicon-o-arrow-down-tray')
->visible(auth()->user()->can('download-backup'))
// ->color('success')
->action(fn (BackupDestination $record) => Storage::disk($record->disk)->download($record->path)),

Tables\Actions\Action::make('delete')
->label(__('filament-spatie-backup::backup.components.backup_destination_list.table.actions.delete'))
->icon('heroicon-o-trash')
->visible(auth()->user()->can('delete-backup'))
->requiresConfirmation()
// ->color('danger')
->action(function (BackupDestination $record) {
SpatieBackupDestination::create($record->disk, config('backup.backup.name'))
->backups()
->first(function (Backup $backup) use ($record) {
return $backup->path() === $record->path;
})
->delete();

Notification::make()
->title(__('filament-spatie-backup::backup.pages.backups.messages.backup_delete_success'))
->success()
->send();
}),
])
->bulkActions([
// ...
]);
}
Solution:
But no, there is no way to target that action from outside the plugin. So you'll have to ask the author if they can add a configuration method for that on their plugin registration.
Jump to solution
5 Replies
Matthew
MatthewOP2y ago
<?php

namespace App\Providers;
use Gate;
use App\Models\User;

// use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
//
];

/**
* Register any authentication / authorization services.
*/
public function boot(): void
{
Gate::define('download-backup', fn(User $user) => true);
Gate::define('delete-backup', fn(User $user) => true);
}
}
<?php

namespace App\Providers;
use Gate;
use App\Models\User;

// use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
//
];

/**
* Register any authentication / authorization services.
*/
public function boot(): void
{
Gate::define('download-backup', fn(User $user) => true);
Gate::define('delete-backup', fn(User $user) => true);
}
}
Is it possible to change the color of the action without changing the vendor file?
cheesegrits
cheesegrits2y ago
Are you asking about a plugin? If so, as per #✅┊rules please ask in the plugin channel, which I think is probably #spatie-backup
Matthew
MatthewOP2y ago
It is, but isnt this more of a general filament question?
cheesegrits
cheesegrits2y ago
You are trying to change the color of an action() button in a table schema inside a plugin, yes? I'm not sure what gates have to do with it?
Solution
cheesegrits
cheesegrits2y ago
But no, there is no way to target that action from outside the plugin. So you'll have to ask the author if they can add a configuration method for that on their plugin registration.

Did you find this page helpful?