From cd3e2963b3050a6c307fcd0adbc3fbac52579b84 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 15 May 2024 10:45:08 +0200 Subject: [PATCH] Refactor gitCommitLink method to handle different git repository formats --- app/Models/Application.php | 11 ++++++ .../application/deployment/index.blade.php | 36 ++++++++++++------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/app/Models/Application.php b/app/Models/Application.php index d84c4af39..fd3faa166 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -189,6 +189,17 @@ public function gitCommits(): Attribute } ); } + public function gitCommitLink($link): string + { + if (!is_null($this->source?->html_url) && !is_null($this->git_repository) && !is_null($this->git_branch)) { + return "{$this->source->html_url}/{$this->git_repository}/commit/{$link}"; + } + if (strpos($this->git_repository, 'git@') === 0) { + $git_repository = str_replace(['git@', ':', '.git'], ['', '/', ''], $this->git_repository); + return "https://{$git_repository}/commit/{$link}"; + } + return $this->git_repository; + } public function dockerfileLocation(): Attribute { return Attribute::make( diff --git a/resources/views/livewire/project/application/deployment/index.blade.php b/resources/views/livewire/project/application/deployment/index.blade.php index 9c5e44080..65ba94152 100644 --- a/resources/views/livewire/project/application/deployment/index.blade.php +++ b/resources/views/livewire/project/application/deployment/index.blade.php @@ -27,18 +27,15 @@ class="w-6 h-6" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> @endif @forelse ($deployments as $deployment) - - data_get($deployment, 'status') === 'queued', - 'border-warning hover:bg-warning hover:text-black' => +
data_get($deployment, 'status') === 'in_progress' || data_get($deployment, 'status') === 'cancelled-by-user', - 'border-error dark:hover:bg-error hover:bg-neutral-200' => - data_get($deployment, 'status') === 'failed', - 'border-success dark:hover:bg-success hover:bg-neutral-200' => - data_get($deployment, 'status') === 'finished', - ]) href="{{ $current_url . '/' . data_get($deployment, 'deployment_uuid') }}"> + 'border-error' => data_get($deployment, 'status') === 'failed', + 'border-success' => data_get($deployment, 'status') === 'finished', + ]) + x-on:click.stop="goto('{{ $current_url . '/' . data_get($deployment, 'deployment_uuid') }}')">
{{ $deployment->created_at }} UTC @@ -64,8 +61,17 @@ class="w-6 h-6" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> @endif
@else -
- Manual +
+ Manual @if (data_get($deployment, 'rollback') === true) +
rolled back to
+ @endif + @if (data_get($deployment, 'commit')) +
+
+ ({{ data_get($deployment, 'commit') }})
+
+ @endif
@endif @if (data_get($deployment, 'server_name')) @@ -85,15 +91,19 @@ class="w-6 h-6" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 0s
-
+
@empty
No deployments found
@endforelse + @if ($deployments_count > 0)