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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(ui): load the Compose file automatically only on the General page
Andras Bacsaid605e5dfa04c
diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.phpindex 9c83db4219..9b40240c19 100644--- a/app/Livewire/Project/Application/Heading.php+++ b/app/Livewire/Project/Application/Heading.php@@ -33,8 +33,8 @@ class Heading extends Componentpublic bool $docker_cleanup = true;/**- * Set once on page open, so that a later switch to the Compose build pack does not load the file- * before the user confirms its location.+ * Set once when the General page opens, where the user sees the Compose file location. Other pages+ * only show the button, and a later switch to the Compose build pack waits for the user.*/#[Locked]public bool $loadComposeOnOpen = false;@@ -64,7 +64,9 @@ class Heading extends Component$lastDeployment = $this->application->get_last_successful_deployment();$this->lastDeploymentInfo = data_get_str($lastDeployment, 'commit')->limit(7).' '.data_get($lastDeployment, 'commit_message');$this->lastDeploymentLink = $this->application->gitCommitLink(data_get($lastDeployment, 'commit'));- $this->loadComposeOnOpen = $this->needsComposeFile() && auth()->user()?->can('update', $this->application);+ $this->loadComposeOnOpen = $this->activeRouteName === 'project.application.configuration'+ && $this->needsComposeFile()+ && auth()->user()?->can('update', $this->application);}public function needsComposeFile(): booldiff --git a/tests/Feature/ApplicationHeadingComposeLoadTest.php b/tests/Feature/ApplicationHeadingComposeLoadTest.phpindex 4ca4338024..48ca92166d 100644--- a/tests/Feature/ApplicationHeadingComposeLoadTest.php+++ b/tests/Feature/ApplicationHeadingComposeLoadTest.php@@ -51,21 +51,30 @@ beforeEach(function () {session(['currentTeam' => $this->team]);});-test('an admin opening a compose application without a compose file loads it automatically', function () {+test('an admin opening the general page of a compose application without a compose file loads it automatically', function () {$this->actingAs($this->admin);- Livewire::test(Heading::class, ['application' => $this->application])+ Livewire::test(Heading::class, ['application' => $this->application, 'activeRouteName' => 'project.application.configuration'])->assertSet('loadComposeOnOpen', true)->assertSee('Load compose')->assertSee('Load the Compose file before you deploy.')->assertDontSee('Load a Compose file to deploy.');});+test('other application pages show the load button but do not load the compose file', function () {+ $this->actingAs($this->admin);++ Livewire::test(Heading::class, ['application' => $this->application, 'activeRouteName' => 'project.application.danger'])+ ->assertSet('loadComposeOnOpen', false)+ ->assertSee('Load compose')+ ->assertSee('Load the Compose file before you deploy.');+});+test('a compose application that already has a compose file does not load it on open', function () {$this->actingAs($this->admin);$this->application->update(['docker_compose_raw' => "services:\n web:\n image: nginx\n"]);- Livewire::test(Heading::class, ['application' => $this->application])+ Livewire::test(Heading::class, ['application' => $this->application, 'activeRouteName' => 'project.application.configuration'])->assertSet('loadComposeOnOpen', false)->assertDontSee('Load compose');});@@ -84,7 +93,7 @@ test('the automatic load is skipped when the compose file is already loaded', futest('a member cannot load the compose file and does not load it on open', function () {$this->actingAs($this->member);- Livewire::test(Heading::class, ['application' => $this->application])+ Livewire::test(Heading::class, ['application' => $this->application, 'activeRouteName' => 'project.application.configuration'])->assertSet('loadComposeOnOpen', false)->assertDontSee('Load compose')->call('loadComposeFile')