mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 08:34:45 +02:00
Add force delete for servers
This commit is contained in:
parent
07244c38eb
commit
7bbbba37f5
@ -590,11 +590,17 @@ class EditServer extends EditRecord
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
Actions\Action::make('Force Delete')
|
||||||
|
->successRedirectUrl($this->getResource()::getUrl('index'))
|
||||||
|
->color('danger')
|
||||||
|
->action(fn (Server $server) => resolve(ServerDeletionService::class)->withForce()->handle($server))
|
||||||
|
->requiresConfirmation(),
|
||||||
Actions\Action::make('Delete')
|
Actions\Action::make('Delete')
|
||||||
->successRedirectUrl($this->getResource()::getUrl('index'))
|
->successRedirectUrl($this->getResource()::getUrl('index'))
|
||||||
->color('danger')
|
->color('danger')
|
||||||
->action(fn (Server $server) => resolve(ServerDeletionService::class)->handle($server))
|
->action(fn (Server $server) => resolve(ServerDeletionService::class)->handle($server))
|
||||||
->requiresConfirmation(),
|
->requiresConfirmation(),
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Servers;
|
namespace App\Services\Servers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Database\ConnectionInterface;
|
use Illuminate\Database\ConnectionInterface;
|
||||||
@ -43,7 +44,7 @@ class ServerDeletionService
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->daemonServerRepository->setServer($server)->delete();
|
$this->daemonServerRepository->setServer($server)->delete();
|
||||||
} catch (DaemonConnectionException $exception) {
|
} catch (Exception $exception) {
|
||||||
// If there is an error not caused a 404 error and this isn't a forced delete,
|
// If there is an error not caused a 404 error and this isn't a forced delete,
|
||||||
// go ahead and bail out. We specifically ignore a 404 since that can be assumed
|
// go ahead and bail out. We specifically ignore a 404 since that can be assumed
|
||||||
// to be a safe error, meaning the server doesn't exist at all on daemon so there
|
// to be a safe error, meaning the server doesn't exist at all on daemon so there
|
||||||
|
Loading…
x
Reference in New Issue
Block a user