From d605e5dfa04cdad1ac2d4d525dfc4764aa352e05 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sat, 24 Oct 2026 22:14:55 +0200 Subject: [PATCH] fix(ui): load the Compose file automatically only on the General page Other application pages still show Load compose and the disabled Deploy button, but they do not start a load on their own. Co-Authored-By: Claude Opus 5.5 --- app/Livewire/Project/Application/Heading.php | 8 +++++--- .../ApplicationHeadingComposeLoadTest.php | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php index 9c83db4219..9b40240c19 100644 --- a/app/Livewire/Project/Application/Heading.php +++ b/app/Livewire/Project/Application/Heading.php @@ -33,8 +33,8 @@ class Heading extends Component public 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(): bool diff --git a/tests/Feature/ApplicationHeadingComposeLoadTest.php b/tests/Feature/ApplicationHeadingComposeLoadTest.php index 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', fu test('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')