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 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-10-24 22:14:55 +02:00
co-authored by Claude Opus 5.5
parent 887461ab2d
commit d605e5dfa0
2 changed files with 18 additions and 7 deletions
+5 -3
View File
@@ -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
@@ -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')