refactor(SourceManagement): sort sources by name and improve UI for changing Git source with better error handling
This commit is contained in:
@@ -75,7 +75,7 @@ class Source extends Component
|
|||||||
// filter the current source out
|
// filter the current source out
|
||||||
$this->sources = currentTeam()->sources()->whereNotNull('app_id')->reject(function ($source) {
|
$this->sources = currentTeam()->sources()->whereNotNull('app_id')->reject(function ($source) {
|
||||||
return $source->id === $this->application->source_id;
|
return $source->id === $this->application->source_id;
|
||||||
});
|
})->sortBy('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPrivateKey(int $privateKeyId)
|
public function setPrivateKey(int $privateKeyId)
|
||||||
@@ -113,6 +113,7 @@ class Source extends Component
|
|||||||
'source_type' => $sourceType,
|
'source_type' => $sourceType,
|
||||||
]);
|
]);
|
||||||
$this->application->refresh();
|
$this->application->refresh();
|
||||||
|
$this->getSources();
|
||||||
$this->dispatch('success', 'Source updated!');
|
$this->dispatch('success', 'Source updated!');
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ function generateGithubToken(GithubApp $source, string $type)
|
|||||||
|
|
||||||
if (! $response->successful()) {
|
if (! $response->successful()) {
|
||||||
$error = data_get($response->json(), 'message', 'no error message found');
|
$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);
|
throw new RuntimeException("Failed to get installation token for {$source->name} with error: ".$error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,18 +38,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (filled($sources) && $sources->count() > 0)
|
|
||||||
<div class="pt-4">
|
<div class="pt-4">
|
||||||
<h3 class="pb-2">Change Git Source</h3>
|
<h3 class="pb-2">Change Git Source</h3>
|
||||||
<div class="grid grid-cols-1 gap-2">
|
<div class="grid grid-cols-1 gap-2">
|
||||||
@foreach ($sources as $source)
|
@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"
|
<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"
|
: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"
|
:confirmWithText="true" confirmationText="Change Git Source"
|
||||||
confirmationLabel="Please confirm changing the git source by entering the text below"
|
confirmationLabel="Please confirm changing the git source by entering the text below"
|
||||||
shortConfirmationLabel="Confirmation Text" :confirmWithPassword="false">
|
shortConfirmationLabel="Confirmation Text" :confirmWithPassword="false">
|
||||||
<x-slot:customButton>
|
<x-slot:customButton>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
<div class="box-title">
|
<div class="box-title">
|
||||||
{{ $source->name }}
|
{{ $source->name }}
|
||||||
@if ($application->source_id === $source->id)
|
@if ($application->source_id === $source->id)
|
||||||
@@ -57,14 +58,17 @@
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="box-description">
|
<div class="box-description">
|
||||||
{{ $source->organization_name ?? 'Personal Account' }}
|
{{ $source->organization ?? 'Personal Account' }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</x-slot:customButton>
|
</x-slot:customButton>
|
||||||
</x-modal-confirmation>
|
</x-modal-confirmation>
|
||||||
@endforeach
|
</div>
|
||||||
|
@empty
|
||||||
|
<div class="text-center">No sources found</div>
|
||||||
|
@endforelse
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
|
||||||
|
|
||||||
@if ($privateKeyId)
|
@if ($privateKeyId)
|
||||||
<h3 class="pt-4">Deploy Key</h3>
|
<h3 class="pt-4">Deploy Key</h3>
|
||||||
|
|||||||
Reference in New Issue
Block a user