fix(ui): Instance Backup settings

- Only show and enable instance backup settings when the server is functional
This commit is contained in:
peaklabs-dev
2025-04-01 14:31:38 +02:00
parent ab63797db4
commit 7519e6a939
2 changed files with 38 additions and 18 deletions

View File

@@ -15,6 +15,8 @@ class SettingsBackup extends Component
{
public InstanceSettings $settings;
public Server $server;
public ?StandalonePostgresql $database = null;
public ScheduledDatabaseBackup|null|array $backup = [];
@@ -46,6 +48,7 @@ class SettingsBackup extends Component
return redirect()->route('dashboard');
} else {
$settings = instanceSettings();
$this->server = Server::findOrFail(0);
$this->database = StandalonePostgresql::whereName('coolify-db')->first();
$s3s = S3Storage::whereTeamId(0)->get() ?? [];
if ($this->database) {
@@ -60,6 +63,10 @@ class SettingsBackup extends Component
$this->database->save();
}
$this->backup = $this->database->scheduledBackups->first();
if ($this->backup && ! $this->server->isFunctional()) {
$this->backup->enabled = false;
$this->backup->save();
}
$this->executions = $this->backup->executions;
}
$this->settings = $settings;

View File

@@ -6,7 +6,7 @@
<div class="flex flex-col">
<div class="flex items-center gap-2">
<h2>Backup</h2>
@if (isset($database))
@if (isset($database) && $server->isFunctional())
<x-forms.button type="submit" wire:click="submit">
Save
</x-forms.button>
@@ -14,6 +14,7 @@
</div>
<div class="pb-4">Backup configuration for Coolify instance.</div>
<div>
@if ($server->isFunctional())
@if (isset($database) && isset($backup))
<div class="flex flex-col gap-3 pb-4">
<div class="flex gap-2">
@@ -35,6 +36,18 @@
into Coolify.
<x-forms.button class="mt-2" wire:click="addCoolifyDatabase">Configure Backup</x-forms.button>
@endif
@else
<div class="p-6 bg-red-500/10 rounded-lg border border-red-500/20">
<div class="text-red-500 font-medium mb-4">
Instance Backup is currently disabled because the localhost server is not properly validated.
Please validate your server to enable Instance Backup.
</div>
<a href="{{ route('server.show', [$server->uuid]) }}"
class="text-black hover:text-gray-700 dark:text-white dark:hover:text-gray-200 underline">
Go to Server Settings to Validate
</a>
</div>
@endif
</div>
</div>
</div>