fix dashes on the name and better error handling (#336)

This commit is contained in:
Saeed Vaziry
2024-11-02 22:44:02 +01:00
committed by GitHub
parent f743611b22
commit 6639fac9c0
16 changed files with 53 additions and 96 deletions

View File

@ -6,7 +6,6 @@
use App\Actions\Database\LinkUser;
use App\Models\DatabaseUser;
use App\Models\Server;
use Exception;
use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
@ -98,21 +97,14 @@ private function linkAction(): Action
->default(fn (DatabaseUser $record) => $record->databases),
])
->action(function (DatabaseUser $record, array $data) {
try {
run_action($this, function () use ($record, $data) {
app(LinkUser::class)->link($record, $data);
Notification::make()
->success()
->title('User linked to databases!')
->send();
} catch (Exception $e) {
Notification::make()
->danger()
->title($e->getMessage())
->send();
throw $e;
}
});
});
}
@ -127,18 +119,10 @@ private function deleteAction(): Action
->authorize(fn ($record) => auth()->user()->can('delete', $record))
->requiresConfirmation()
->action(function (DatabaseUser $record) {
try {
run_action($this, function () use ($record) {
app(DeleteDatabaseUser::class)->delete($this->server, $record);
} catch (Exception $e) {
Notification::make()
->danger()
->title($e->getMessage())
->send();
throw $e;
}
$this->dispatch('$refresh');
$this->dispatch('$refresh');
});
});
}
}