Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/Livewire/DatabaseServer/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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).",
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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.",
Expand Down
4 changes: 4 additions & 0 deletions lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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).",
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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.",
Expand Down
10 changes: 10 additions & 0 deletions resources/views/livewire/database-server/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ class="text-info" />
wire:click="confirmRestore('{{ $server->id }}')" spinner
class="text-success" />
@endcan
@can('update', $server)
@if($server->backups->isNotEmpty())
<x-menu-item
:title="$server->backups_enabled ? __('Disable Backup') : __('Enable Backup')"
:icon="$server->backups_enabled ? 'o-pause-circle' : 'o-play-circle'"
wire:click="toggleBackupsEnabled('{{ $server->id }}')"
spinner
/>
@endif
@endcan
@can('viewForm', $server)
<x-menu-item :title="__('Edit')" icon="o-pencil"
link="{{ route('database-servers.edit', $server) }}" wire:navigate />
Expand Down
17 changes: 17 additions & 0 deletions tests/Feature/DatabaseServer/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});