mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 22:14:45 +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
68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Components\Tables\Actions;
|
|
|
|
use App\Models\Egg;
|
|
use App\Services\Eggs\Sharing\EggImporterService;
|
|
use Exception;
|
|
use Filament\Actions\StaticAction;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Tables\Actions\Action;
|
|
|
|
class UpdateEggAction extends Action
|
|
{
|
|
public static function getDefaultName(): ?string
|
|
{
|
|
return 'update';
|
|
}
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->label(trans('admin/egg.update'));
|
|
|
|
$this->icon('tabler-cloud-download');
|
|
|
|
$this->color('success');
|
|
|
|
$this->requiresConfirmation();
|
|
|
|
$this->modalHeading(trans('admin/egg.update_question'));
|
|
|
|
$this->modalDescription(trans('admin/egg.update_description'));
|
|
|
|
$this->modalIconColor('danger');
|
|
|
|
$this->modalSubmitAction(fn (StaticAction $action) => $action->color('danger'));
|
|
|
|
$this->action(function (Egg $egg, EggImporterService $eggImporterService) {
|
|
try {
|
|
$eggImporterService->fromUrl($egg->update_url, $egg);
|
|
|
|
cache()->forget("eggs.$egg->uuid.update");
|
|
} catch (Exception $exception) {
|
|
Notification::make()
|
|
->title(trans('admin/egg.update_failed'))
|
|
->body($exception->getMessage())
|
|
->danger()
|
|
->send();
|
|
|
|
report($exception);
|
|
|
|
return;
|
|
}
|
|
|
|
Notification::make()
|
|
->title(trans('admin/egg.updated'))
|
|
->body($egg->name)
|
|
->success()
|
|
->send();
|
|
});
|
|
|
|
$this->authorize(fn () => auth()->user()->can('import egg'));
|
|
|
|
$this->visible(fn (Egg $egg) => cache()->get("eggs.$egg->uuid.update", false));
|
|
}
|
|
}
|