Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Refactor backup execution and cleanup functionality

Andras Bacsai051a1405e715
diff --git a/app/Livewire/Project/Database/Backup/Execution.php b/app/Livewire/Project/Database/Backup/Execution.php
index 07f7db03c4..1f790d6438 100644
--- a/app/Livewire/Project/Database/Backup/Execution.php
+++ b/app/Livewire/Project/Database/Backup/Execution.php
@@ -10,7 +10,8 @@ class Execution extends Component
public $backup;
public $executions;
public $s3s;
- public function mount() {
+ public function mount()
+ {
$backup_uuid = request()->route('backup_uuid');
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
@@ -34,6 +35,11 @@ class Execution extends Component
$this->executions = $executions;
$this->s3s = currentTeam()->s3s;
}
+ public function cleanupFailed()
+ {
+ $this->backup->executions()->where('status', 'failed')->delete();
+ $this->dispatch('refreshBackupExecutions');
+ }
public function render()
{
return view('livewire.project.database.backup.execution');
diff --git a/app/Livewire/Project/Database/BackupExecutions.php b/app/Livewire/Project/Database/BackupExecutions.php
index c78a8cbee5..5484dfdc8e 100644
--- a/app/Livewire/Project/Database/BackupExecutions.php
+++ b/app/Livewire/Project/Database/BackupExecutions.php
@@ -34,7 +34,7 @@ class BackupExecutions extends Component
}
$execution->delete();
$this->dispatch('success', 'Backup deleted.');
- $this->dispatch('refreshBackupExecutions');
+ $this->refreshBackupExecutions();
}
public function download($exeuctionId)
{
@@ -65,6 +65,6 @@ class BackupExecutions extends Component
}
public function refreshBackupExecutions(): void
{
- $this->executions = data_get($this->backup, 'executions', []);
+ $this->executions = $this->backup->executions()->get()->sortByDesc('created_at');
}
}
diff --git a/resources/views/livewire/project/database/backup/execution.blade.php b/resources/views/livewire/project/database/backup/execution.blade.php
index 437186b608..f63ed2be7d 100644
--- a/resources/views/livewire/project/database/backup/execution.blade.php
+++ b/resources/views/livewire/project/database/backup/execution.blade.php
@@ -13,7 +13,10 @@
</x-modal>
<div class="pt-6">
<livewire:project.database.backup-edit :backup="$backup" :s3s="$s3s" :status="data_get($database, 'status')" />
- <h3 class="py-4">Executions</h3>
+ <div class="flex items-center gap-2">
+ <h3 class="py-4">Executions</h3>
+ <x-forms.button wire:click='cleanupFailed'>Cleanup Failed Backups</x-forms.button>
+ </div>
<livewire:project.database.backup-executions :backup="$backup" :executions="$executions" />
</div>
</div>