mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 21:04:44 +02:00

* Init * Health Page * Admin API Keys * Update API Keys * Database Hosts * Mounts * remove `s` * Users * Webhooks * Server never again... * Fix Server * Settings * Update Mounts * Update Databasehost * Update Server * Oops, Update Server * Nodes * Update User * Dashboard * Update Server * Profile * Egg * Role & Update Egg * Add base Laravel lang files * update apikey * remove html back to settings, remove comment * add `:resource` to create_action * Update Egg * Update Egg v2 * Update 1 * trans cf info label * Update charts * more trans * Update Webhook * update Health * Update Server * Update Role * Fixes * Bulk Update * AnotherOne * Fix relation button label * rename `admin1` to `admin` Leftover from testing... oops * More Translations * Updates * `pint` + Relation Manager Titles
63 lines
1.7 KiB
PHP
63 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Components\Forms\Actions;
|
|
|
|
use App\Models\Database;
|
|
use App\Services\Databases\DatabasePasswordService;
|
|
use Exception;
|
|
use Filament\Actions\StaticAction;
|
|
use Filament\Forms\Components\Actions\Action;
|
|
use Filament\Forms\Set;
|
|
use Filament\Notifications\Notification;
|
|
|
|
class RotateDatabasePasswordAction extends Action
|
|
{
|
|
public static function getDefaultName(): ?string
|
|
{
|
|
return 'rotate';
|
|
}
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->label(trans('admin/databasehost.rotate'));
|
|
|
|
$this->icon('tabler-refresh');
|
|
|
|
$this->authorize(fn (Database $database) => auth()->user()->can('update database', $database));
|
|
|
|
$this->modalHeading(trans('admin/databasehost.rotate_password'));
|
|
|
|
$this->modalIconColor('warning');
|
|
|
|
$this->modalSubmitAction(fn (StaticAction $action) => $action->color('warning'));
|
|
|
|
$this->requiresConfirmation();
|
|
|
|
$this->action(function (DatabasePasswordService $service, Database $database, Set $set) {
|
|
try {
|
|
$service->handle($database);
|
|
|
|
$database->refresh();
|
|
|
|
$set('password', $database->password);
|
|
$set('jdbc', $database->jdbc);
|
|
|
|
Notification::make()
|
|
->title(trans('admin/databasehost.rotated'))
|
|
->success()
|
|
->send();
|
|
} catch (Exception $exception) {
|
|
Notification::make()
|
|
->title(trans('admin/databasehost.rotate_error'))
|
|
->body($exception->getMessage())
|
|
->danger()
|
|
->send();
|
|
|
|
report($exception);
|
|
}
|
|
});
|
|
}
|
|
}
|