Refactor gitCommitLink method to handle different git repository formats
This commit is contained in:
		@@ -189,6 +189,17 @@ class Application extends BaseModel
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    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
 | 
					    public function dockerfileLocation(): Attribute
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return Attribute::make(
 | 
					        return Attribute::make(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,18 +27,15 @@
 | 
				
			|||||||
            </form>
 | 
					            </form>
 | 
				
			||||||
        @endif
 | 
					        @endif
 | 
				
			||||||
        @forelse ($deployments as $deployment)
 | 
					        @forelse ($deployments as $deployment)
 | 
				
			||||||
            <a @class([
 | 
					            <div @class([
 | 
				
			||||||
                'dark:bg-coolgray-100 p-2 border-l border-dashed transition-colors hover:no-underline box-without-bg-without-border bg-white flex-col',
 | 
					                'dark:bg-coolgray-100 p-2 border-l border-dashed transition-colors hover:no-underline box-without-bg-without-border bg-white flex-col cursor-pointer dark:hover:text-neutral-400 dark:hover:bg-coolgray-200',
 | 
				
			||||||
                'dark:hover:bg-coolgray-200' =>
 | 
					                'border-warning' =>
 | 
				
			||||||
                    data_get($deployment, 'status') === 'queued',
 | 
					 | 
				
			||||||
                'border-warning hover:bg-warning hover:text-black' =>
 | 
					 | 
				
			||||||
                    data_get($deployment, 'status') === 'in_progress' ||
 | 
					                    data_get($deployment, 'status') === 'in_progress' ||
 | 
				
			||||||
                    data_get($deployment, 'status') === 'cancelled-by-user',
 | 
					                    data_get($deployment, 'status') === 'cancelled-by-user',
 | 
				
			||||||
                'border-error dark:hover:bg-error hover:bg-neutral-200' =>
 | 
					                'border-error' => data_get($deployment, 'status') === 'failed',
 | 
				
			||||||
                    data_get($deployment, 'status') === 'failed',
 | 
					                'border-success' => data_get($deployment, 'status') === 'finished',
 | 
				
			||||||
                'border-success dark:hover:bg-success hover:bg-neutral-200' =>
 | 
					            ])
 | 
				
			||||||
                    data_get($deployment, 'status') === 'finished',
 | 
					                x-on:click.stop="goto('{{ $current_url . '/' . data_get($deployment, 'deployment_uuid') }}')">
 | 
				
			||||||
            ]) href="{{ $current_url . '/' . data_get($deployment, 'deployment_uuid') }}">
 | 
					 | 
				
			||||||
                <div class="flex flex-col justify-start">
 | 
					                <div class="flex flex-col justify-start">
 | 
				
			||||||
                    <div class="flex gap-1">
 | 
					                    <div class="flex gap-1">
 | 
				
			||||||
                        {{ $deployment->created_at }} UTC
 | 
					                        {{ $deployment->created_at }} UTC
 | 
				
			||||||
@@ -64,8 +61,17 @@
 | 
				
			|||||||
                            @endif
 | 
					                            @endif
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    @else
 | 
					                    @else
 | 
				
			||||||
                        <div class="flex gap-1">
 | 
					                        <div class="flex items-center gap-1">
 | 
				
			||||||
                            Manual
 | 
					                            Manual @if (data_get($deployment, 'rollback') === true)
 | 
				
			||||||
 | 
					                                <div class="text-xs">rolled back to </div>
 | 
				
			||||||
 | 
					                            @endif
 | 
				
			||||||
 | 
					                            @if (data_get($deployment, 'commit'))
 | 
				
			||||||
 | 
					                                <div class="dark:hover:text-white"
 | 
				
			||||||
 | 
					                                x-on:click.stop="goto('{{ $application->gitCommitLink(data_get($deployment, 'commit')) }}')">
 | 
				
			||||||
 | 
					                                    <div class="text-xs underline">
 | 
				
			||||||
 | 
					                                        ({{ data_get($deployment, 'commit') }})</div>
 | 
				
			||||||
 | 
					                                </div>
 | 
				
			||||||
 | 
					                            @endif
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    @endif
 | 
					                    @endif
 | 
				
			||||||
                    @if (data_get($deployment, 'server_name'))
 | 
					                    @if (data_get($deployment, 'server_name'))
 | 
				
			||||||
@@ -85,15 +91,19 @@
 | 
				
			|||||||
                        <span class="font-bold" x-text="measure_finished_time()">0s</span>
 | 
					                        <span class="font-bold" x-text="measure_finished_time()">0s</span>
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            </a>
 | 
					            </div>
 | 
				
			||||||
        @empty
 | 
					        @empty
 | 
				
			||||||
            <div class="">No deployments found</div>
 | 
					            <div class="">No deployments found</div>
 | 
				
			||||||
        @endforelse
 | 
					        @endforelse
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        @if ($deployments_count > 0)
 | 
					        @if ($deployments_count > 0)
 | 
				
			||||||
            <script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script>
 | 
					            <script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script>
 | 
				
			||||||
            <script src="https://cdn.jsdelivr.net/npm/dayjs@1/plugin/utc.js"></script>
 | 
					            <script src="https://cdn.jsdelivr.net/npm/dayjs@1/plugin/utc.js"></script>
 | 
				
			||||||
            <script src="https://cdn.jsdelivr.net/npm/dayjs@1/plugin/relativeTime.js"></script>
 | 
					            <script src="https://cdn.jsdelivr.net/npm/dayjs@1/plugin/relativeTime.js"></script>
 | 
				
			||||||
            <script>
 | 
					            <script>
 | 
				
			||||||
 | 
					                function goto(url) {
 | 
				
			||||||
 | 
					                    window.location.href = url;
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
                document.addEventListener('alpine:init', () => {
 | 
					                document.addEventListener('alpine:init', () => {
 | 
				
			||||||
                    let timers = {};
 | 
					                    let timers = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user