From 10fde1b1efa33024a7d59676fa26a5e92a17cfe7 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 May 2024 08:53:25 +0200 Subject: [PATCH] feat: shows the latest deployment commit + message on status --- app/Livewire/Project/Application/Heading.php | 7 ++++++- app/Models/Application.php | 4 ++++ .../views/components/resources/breadcrumbs.blade.php | 4 ++-- resources/views/components/status/index.blade.php | 8 ++++++-- .../views/components/status/restarting.blade.php | 12 ++++++++++-- resources/views/components/status/running.blade.php | 12 +++++++++--- .../livewire/project/application/heading.blade.php | 2 +- 7 files changed, 38 insertions(+), 11 deletions(-) diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php index 06b9a3c3c..619be693d 100644 --- a/app/Livewire/Project/Application/Heading.php +++ b/app/Livewire/Project/Application/Heading.php @@ -5,7 +5,7 @@ namespace App\Livewire\Project\Application; use App\Actions\Application\StopApplication; use App\Actions\Docker\GetContainersStatus; use App\Events\ApplicationStatusChanged; - use App\Jobs\ContainerStatusJob; +use App\Jobs\ContainerStatusJob; use App\Jobs\ServerStatusJob; use App\Models\Application; use Livewire\Component; @@ -14,6 +14,8 @@ use Visus\Cuid2\Cuid2; class Heading extends Component { public Application $application; + public ?string $lastDeploymentInfo = null; + public ?string $lastDeploymentLink = null; public array $parameters; protected string $deploymentUuid; @@ -28,6 +30,9 @@ class Heading extends Component public function mount() { $this->parameters = get_route_parameters(); + $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')); } public function check_status($showNotification = false) diff --git a/app/Models/Application.php b/app/Models/Application.php index fd3faa166..63ae132b1 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -454,6 +454,10 @@ class Application extends BaseModel } return false; } + public function get_last_successful_deployment() + { + return ApplicationDeploymentQueue::where('application_id', $this->id)->where('status', 'finished')->orderBy('created_at', 'desc')->first(); + } public function get_last_days_deployments() { return ApplicationDeploymentQueue::where('application_id', $this->id)->where('created_at', '>=', now()->subDays(7))->orderBy('created_at', 'desc')->get(); diff --git a/resources/views/components/resources/breadcrumbs.blade.php b/resources/views/components/resources/breadcrumbs.blade.php index 1e5aaa997..90477810c 100644 --- a/resources/views/components/resources/breadcrumbs.blade.php +++ b/resources/views/components/resources/breadcrumbs.blade.php @@ -1,5 +1,5 @@ diff --git a/resources/views/components/status/index.blade.php b/resources/views/components/status/index.blade.php index 4ee3319ff..c8a9f9b55 100644 --- a/resources/views/components/status/index.blade.php +++ b/resources/views/components/status/index.blade.php @@ -1,9 +1,13 @@ +@props([ + 'lastDeploymentInfo' => null, + 'lastDeploymentLink' => null, +]) @if (str($resource->status)->startsWith('running')) - + @elseif(str($resource->status)->startsWith('restarting') || str($resource->status)->startsWith('starting') || str($resource->status)->startsWith('degraded')) - + @else @endif diff --git a/resources/views/components/status/restarting.blade.php b/resources/views/components/status/restarting.blade.php index bb555c745..f269b4a5a 100644 --- a/resources/views/components/status/restarting.blade.php +++ b/resources/views/components/status/restarting.blade.php @@ -1,12 +1,20 @@ @props([ 'status' => 'Restarting', + 'lastDeploymentInfo' => null, + 'lastDeploymentLink' => null, ])
-
- {{ str($status)->before(':')->headline() }} +
+ @if ($lastDeploymentLink) + + {{ str($status)->before(':')->headline() }} + + @else + {{ str($status)->before(':')->headline() }} + @endif
@if (!str($status)->startsWith('Proxy') && !str($status)->contains('('))
({{ str($status)->after(':') }})
diff --git a/resources/views/components/status/running.blade.php b/resources/views/components/status/running.blade.php index 52758303b..b22f2d057 100644 --- a/resources/views/components/status/running.blade.php +++ b/resources/views/components/status/running.blade.php @@ -1,12 +1,20 @@ @props([ 'status' => 'Running', + 'lastDeploymentInfo' => null, + 'lastDeploymentLink' => null, ])
-
+
+ @if ($lastDeploymentLink) + + {{ str($status)->before(':')->headline() }} + + @else {{ str($status)->before(':')->headline() }} + @endif
@if (!str($status)->startsWith('Proxy') && !str($status)->contains('(')) @if (str($status)->contains('unhealthy')) @@ -17,8 +25,6 @@ - {{-- @else -
({{ str($status)->after(':') }})
--}} @endif @endif diff --git a/resources/views/livewire/project/application/heading.blade.php b/resources/views/livewire/project/application/heading.blade.php index 7cd686d83..2f0bba535 100644 --- a/resources/views/livewire/project/application/heading.blade.php +++ b/resources/views/livewire/project/application/heading.blade.php @@ -1,5 +1,5 @@