Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

refactor(SourceManagement): sort sources by name and improve UI for changing Git source with better error handling

Andras Bacsai4c95dccfb3b0
diff --git a/app/Livewire/Project/Application/Source.php b/app/Livewire/Project/Application/Source.php
index 3afdbe0752..013d8b8fe2 100644
--- a/app/Livewire/Project/Application/Source.php
+++ b/app/Livewire/Project/Application/Source.php
@@ -75,7 +75,7 @@ class Source extends Component
// filter the current source out
$this->sources = currentTeam()->sources()->whereNotNull('app_id')->reject(function ($source) {
return $source->id === $this->application->source_id;
- });
+ })->sortBy('name');
}
public function setPrivateKey(int $privateKeyId)
@@ -113,6 +113,7 @@ class Source extends Component
'source_type' => $sourceType,
]);
$this->application->refresh();
+ $this->getSources();
$this->dispatch('success', 'Source updated!');
} catch (\Throwable $e) {
return handleError($e, $this);
diff --git a/bootstrap/helpers/github.php b/bootstrap/helpers/github.php
index 81f8ff18a8..0de2f2fd97 100644
--- a/bootstrap/helpers/github.php
+++ b/bootstrap/helpers/github.php
@@ -52,6 +52,9 @@ function generateGithubToken(GithubApp $source, string $type)
if (! $response->successful()) {
$error = data_get($response->json(), 'message', 'no error message found');
+ if ($error === 'Not Found') {
+ $error = 'Repository not found. Is it moved or deleted?';
+ }
throw new RuntimeException("Failed to get installation token for {$source->name} with error: ".$error);
}
diff --git a/resources/views/livewire/project/application/source.blade.php b/resources/views/livewire/project/application/source.blade.php
index a32742a018..29c5c61427 100644
--- a/resources/views/livewire/project/application/source.blade.php
+++ b/resources/views/livewire/project/application/source.blade.php
@@ -38,33 +38,37 @@
</div>
</div>
- @if (filled($sources) && $sources->count() > 0)
- <div class="pt-4">
- <h3 class="pb-2">Change Git Source</h3>
- <div class="grid grid-cols-1 gap-2">
- @foreach ($sources as $source)
+ <div class="pt-4">
+ <h3 class="pb-2">Change Git Source</h3>
+ <div class="grid grid-cols-1 gap-2">
+ @forelse ($sources as $source)
+ <div wire:key="{{ $source->name }}">
<x-modal-confirmation title="Change Git Source" :actions="['Change git source to ' . $source->name]" :buttonFullWidth="true"
:isHighlightedButton="$application->source_id === $source->id" :disabled="$application->source_id === $source->id"
- submitAction="changeSource('{{ $source->id }}', '{{ $source->getMorphClass() }}')"
+ submitAction="changeSource({{ $source->id }}, {{ $source->getMorphClass() }})"
:confirmWithText="true" confirmationText="Change Git Source"
confirmationLabel="Please confirm changing the git source by entering the text below"
shortConfirmationLabel="Confirmation Text" :confirmWithPassword="false">
<x-slot:customButton>
- <div class="box-title">
- {{ $source->name }}
- @if ($application->source_id === $source->id)
- <span class="text-xs">(current)</span>
- @endif
- </div>
- <div class="box-description">
- {{ $source->organization_name ?? 'Personal Account' }}
+ <div class="flex items-center gap-2">
+ <div class="box-title">
+ {{ $source->name }}
+ @if ($application->source_id === $source->id)
+ <span class="text-xs">(current)</span>
+ @endif
+ </div>
+ <div class="box-description">
+ {{ $source->organization ?? 'Personal Account' }}
+ </div>
</div>
</x-slot:customButton>
</x-modal-confirmation>
- @endforeach
- </div>
+ </div>
+ @empty
+ <div class="text-center">No sources found</div>
+ @endforelse
</div>
- @endif
+ </div>
@if ($privateKeyId)
<h3 class="pt-4">Deploy Key</h3>