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.

fix(backups): render form for directory-only targets (#11332)

Andras Bacsaidb1316f878d3
diff --git a/app/Livewire/Project/Application/Backup/Create.php b/app/Livewire/Project/Application/Backup/Create.php
index 68115e7751..f26d81b887 100644
--- a/app/Livewire/Project/Application/Backup/Create.php
+++ b/app/Livewire/Project/Application/Backup/Create.php
@@ -82,7 +82,7 @@ class Create extends Component
'type' => 'Directory',
'name' => $directory->fs_path,
]);
- $this->targets = $volumes->concat($directories)->values();
+ $this->targets = collect($volumes->concat($directories)->all())->values();
$this->targetKey = $this->selectedTargetKey ?? data_get($this->targets->first(), 'key');
$this->loadSelectedBackup();
}
diff --git a/tests/Feature/VolumeBackupTest.php b/tests/Feature/VolumeBackupTest.php
index 88e679a7c7..4968945916 100644
--- a/tests/Feature/VolumeBackupTest.php
+++ b/tests/Feature/VolumeBackupTest.php
@@ -222,6 +222,18 @@ it('creates a scheduled backup for a preselected application directory', functio
expect(ScheduledVolumeBackup::query()->sole()->backupable->is($directory))->toBeTrue();
});
+it('renders the backup form for an application with only a directory target', function () {
+ $team = Team::factory()->create();
+ signInForVolumeBackups($this, $team);
+ [$application, $volume] = createVolumeBackupApplication($team);
+ $volume->delete();
+ $directory = createApplicationBackupDirectory($application);
+
+ Livewire::test(CreateScheduledVolumeBackup::class, ['application' => $application])
+ ->assertSet('targetKey', 'directory:'.$directory->id)
+ ->assertSuccessful();
+});
+
it('rejects files and directory mounts owned by another application as backup targets', function () {
$team = Team::factory()->create();
signInForVolumeBackups($this, $team);