diff --git a/app/Livewire/DatabaseServer/Index.php b/app/Livewire/DatabaseServer/Index.php
index 827a0c4e..9e7cba9f 100644
--- a/app/Livewire/DatabaseServer/Index.php
+++ b/app/Livewire/DatabaseServer/Index.php
@@ -160,6 +160,21 @@ public function runBackupAll(string $serverId, TriggerBackupAction $action): voi
$this->triggerAllBackups($server, $action);
}
+ public function toggleBackupsEnabled(string $id): void
+ {
+ $server = DatabaseServer::findOrFail($id);
+
+ $this->authorize('update', $server);
+
+ $server->update(['backups_enabled' => ! $server->backups_enabled]);
+
+ $this->success(
+ title: $server->backups_enabled
+ ? __('Backups enabled successfully!')
+ : __('Backups disabled successfully!')
+ );
+ }
+
public function render(): View
{
$servers = DatabaseServerQuery::buildFromParams(
diff --git a/lang/es.json b/lang/es.json
index 0fab7fce..8a66d05e 100644
--- a/lang/es.json
+++ b/lang/es.json
@@ -85,6 +85,8 @@
"Backup file not found.": "Archivo de backup no encontrado.",
"Backup schedule deleted.": "Programación de backup eliminada.",
"Backup schedule saved.": "Programación de backup guardada.",
+ "Backups enabled successfully!": "Backups activados correctamente.",
+ "Backups disabled successfully!": "Backups desactivados correctamente.",
"Backups will be stored in the specified root directory on the FTP server. Enable SSL/TLS for encrypted connections (FTPS).": "Los backups se almacenarán en el directorio raíz especificado en el servidor FTP. Active SSL/TLS para conexiones cifradas (FTPS).",
"Backups will be stored in the specified root directory on the SFTP server.": "Los backups se almacenarán en el directorio raíz especificado en el servidor SFTP.",
"Base URL of your Gotify server (e.g. https://gotify.example.com).": "URL base de su servidor Gotify (ej.: https://gotify.example.com).",
@@ -207,6 +209,7 @@
"Detected databases:": "Bases detectadas:",
"Disable": "Desactivar",
"Disable 2FA": "Desactivar 2FA",
+ "Disable Backup": "Desactivar backup",
"Disabled": "Desactivado",
"Discord (Bot)": "Discord (Bot)",
"Discord (Webhook)": "Discord (Webhook)",
@@ -238,6 +241,7 @@
"Email password reset link": "Enviar enlace de restablecimiento de contraseña",
"Enable": "Activar",
"Enable 2FA": "Activar 2FA",
+ "Enable Backup": "Activar backup",
"Enable GitHub OAuth authentication.": "Activar autenticación OAuth de GitHub.",
"Enable GitLab OAuth authentication.": "Activar autenticación OAuth de GitLab.",
"Enable Google OAuth authentication.": "Activar autenticación OAuth de Google.",
diff --git a/lang/fr.json b/lang/fr.json
index 5c6830bf..a9a5f7ca 100644
--- a/lang/fr.json
+++ b/lang/fr.json
@@ -85,6 +85,8 @@
"Backup file not found.": "Fichier de sauvegarde introuvable.",
"Backup schedule deleted.": "Planning de sauvegarde supprimé.",
"Backup schedule saved.": "Planning de sauvegarde enregistré.",
+ "Backups enabled successfully!": "Sauvegardes activées avec succès !",
+ "Backups disabled successfully!": "Sauvegardes désactivées avec succès !",
"Backups will be stored in the specified root directory on the FTP server. Enable SSL/TLS for encrypted connections (FTPS).": "Les sauvegardes seront stockées dans le répertoire racine spécifié sur le serveur FTP. Activez SSL/TLS pour les connexions chiffrées (FTPS).",
"Backups will be stored in the specified root directory on the SFTP server.": "Les sauvegardes seront stockées dans le répertoire racine spécifié sur le serveur SFTP.",
"Base URL of your Gotify server (e.g. https://gotify.example.com).": "URL de base de votre serveur Gotify (ex. : https://gotify.example.com).",
@@ -207,6 +209,7 @@
"Detected databases:": "Bases détectées :",
"Disable": "Désactiver",
"Disable 2FA": "Désactiver 2FA",
+ "Disable Backup": "Désactiver les sauvegardes",
"Disabled": "Désactivé",
"Discord (Bot)": "Discord (Bot)",
"Discord (Webhook)": "Discord (Webhook)",
@@ -238,6 +241,7 @@
"Email password reset link": "Envoyer le lien de réinitialisation",
"Enable": "Activer",
"Enable 2FA": "Activer 2FA",
+ "Enable Backup": "Activer les sauvegardes",
"Enable GitHub OAuth authentication.": "Activer l’authentification OAuth GitHub.",
"Enable GitLab OAuth authentication.": "Activer l’authentification OAuth GitLab.",
"Enable Google OAuth authentication.": "Activer l’authentification OAuth Google.",
diff --git a/resources/views/livewire/database-server/index.blade.php b/resources/views/livewire/database-server/index.blade.php
index ec287733..e72ee2a4 100644
--- a/resources/views/livewire/database-server/index.blade.php
+++ b/resources/views/livewire/database-server/index.blade.php
@@ -150,6 +150,16 @@ class="text-info" />
wire:click="confirmRestore('{{ $server->id }}')" spinner
class="text-success" />
@endcan
+ @can('update', $server)
+ @if($server->backups->isNotEmpty())
+
+ @endif
+ @endcan
@can('viewForm', $server)
diff --git a/tests/Feature/DatabaseServer/IndexTest.php b/tests/Feature/DatabaseServer/IndexTest.php
index c62d460d..4ee115ef 100644
--- a/tests/Feature/DatabaseServer/IndexTest.php
+++ b/tests/Feature/DatabaseServer/IndexTest.php
@@ -106,3 +106,20 @@
$snapshotBackupIds = $snapshots->pluck('backup_id')->sort()->values();
expect($snapshotBackupIds->all())->toBe($backupIds->all());
});
+
+test('user can toggle backups for a server from the index', function () {
+ $user = User::factory()->create();
+ $server = DatabaseServer::factory()->create(['backups_enabled' => true]);
+
+ Livewire::actingAs($user)
+ ->test(Index::class)
+ ->call('toggleBackupsEnabled', $server->id);
+
+ expect($server->fresh()->backups_enabled)->toBeFalse();
+
+ Livewire::actingAs($user)
+ ->test(Index::class)
+ ->call('toggleBackupsEnabled', $server->id);
+
+ expect($server->fresh()->backups_enabled)->toBeTrue();
+});