fix(service): show the selected resource status in the service heading

A merge (9ef1ab764) lost the resource-aware status from #11566.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-09-28 10:13:20 +02:00
co-authored by Claude Opus 5.5
parent 9c6a8e4767
commit 7e4fbc3499
2 changed files with 85 additions and 1 deletions
@@ -32,7 +32,8 @@
{{ $service->name }}
</h1>
<div class="relative flex w-full min-w-0 items-center gap-2">
<x-status-summary :status="$service->status" title="Service status" container-name="Containers" />
<x-status-summary :status="$displayStatus" :title="$selectedResource ? 'Resource status' : 'Service status'"
:container-name="$selectedResource ? 'Container' : 'Containers'" />
<x-services.links :service="$service" compact />
@if ($isDeploymentProgress)
<x-deploying-indicator />
@@ -0,0 +1,83 @@
<?php
use App\Livewire\Project\Service\Heading as ServiceHeading;
use App\Models\InstanceSettings;
use App\Models\Project;
use App\Models\Server;
use App\Models\Service;
use App\Models\ServiceApplication;
use App\Models\StandaloneDocker;
use App\Models\Team;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Str;
use Livewire\Livewire;
uses(RefreshDatabase::class);
beforeEach(function () {
InstanceSettings::unguarded(fn () => InstanceSettings::updateOrCreate(['id' => 0], ['id' => 0]));
$this->team = Team::factory()->create();
$this->user = User::factory()->create();
$this->user->teams()->attach($this->team, ['role' => 'admin']);
$this->actingAs($this->user);
session(['currentTeam' => $this->team]);
$server = Server::factory()->create(['team_id' => $this->team->id]);
$destination = StandaloneDocker::where('server_id', $server->id)->firstOrFail();
$project = Project::create([
'uuid' => (string) Str::uuid(),
'name' => 'Status Project',
'team_id' => $this->team->id,
]);
$environment = $project->environments()->first();
$this->service = Service::create([
'uuid' => (string) Str::uuid(),
'name' => 'Status Service',
'environment_id' => $environment->id,
'server_id' => $server->id,
'destination_id' => $destination->id,
'destination_type' => $destination->getMorphClass(),
'docker_compose_raw' => 'services: {}',
]);
$this->runningApp = ServiceApplication::create(['name' => 'web', 'service_id' => $this->service->id]);
$this->runningApp->forceFill(['status' => 'running:healthy'])->save();
$this->exitedApp = ServiceApplication::create(['name' => 'worker', 'service_id' => $this->service->id]);
$this->exitedApp->forceFill(['status' => 'exited'])->save();
$this->parameters = [
'project_uuid' => $project->uuid,
'environment_uuid' => $environment->uuid,
'service_uuid' => $this->service->uuid,
];
});
test('the heading shows the status of the selected service resource', function () {
$service = $this->service->fresh();
expect($service->status)->not->toBe($this->exitedApp->status);
Livewire::test(ServiceHeading::class, [
'service' => $service,
'parameters' => $this->parameters + ['stack_service_uuid' => $this->exitedApp->uuid],
'query' => [],
])
->assertSee('Resource status')
->assertDontSee('Service status')
->assertSeeInOrder(['Resource status', 'Container', 'Exited', 'Healthcheck'])
->assertDontSee('Degraded');
});
test('the heading shows the service status when no resource is selected', function () {
Livewire::test(ServiceHeading::class, [
'service' => $this->service->fresh(),
'parameters' => $this->parameters,
'query' => [],
])
->assertSee('Service status')
->assertDontSee('Resource status')
->assertSeeInOrder(['Service status', 'Containers', 'Healthcheck'])
->assertSee('Degraded');
});