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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat(SourceManagement): add functionality to change Git source and display current source in the application settings
Andras Bacsaiec368255458f
diff --git a/app/Livewire/Project/Application/Source.php b/app/Livewire/Project/Application/Source.phpindex ade297d501..3afdbe0752 100644--- a/app/Livewire/Project/Application/Source.php+++ b/app/Livewire/Project/Application/Source.php@@ -30,11 +30,15 @@ class Source extends Component#[Validate(['nullable', 'string'])]public ?string $gitCommitSha = null;+ #[Locked]+ public $sources;+public function mount(){try {$this->syncData();$this->getPrivateKeys();+ $this->getSources();} catch (\Throwable $e) {handleError($e, $this);}@@ -66,6 +70,14 @@ class Source extends Component});}+ private function getSources()+ {+ // filter the current source out+ $this->sources = currentTeam()->sources()->whereNotNull('app_id')->reject(function ($source) {+ return $source->id === $this->application->source_id;+ });+ }+public function setPrivateKey(int $privateKeyId){try {@@ -92,4 +104,18 @@ class Source extends Componentreturn handleError($e, $this);}}++ public function changeSource($sourceId, $sourceType)+ {+ try {+ $this->application->update([+ 'source_id' => $sourceId,+ 'source_type' => $sourceType,+ ]);+ $this->application->refresh();+ $this->dispatch('success', 'Source updated!');+ } catch (\Throwable $e) {+ return handleError($e, $this);+ }+ }}diff --git a/resources/views/livewire/project/application/source.blade.php b/resources/views/livewire/project/application/source.blade.phpindex b542d5428d..a32742a018 100644--- a/resources/views/livewire/project/application/source.blade.php+++ b/resources/views/livewire/project/application/source.blade.php@@ -26,6 +26,9 @@<div class="pb-4">Code source of your application.</div><div class="flex flex-col gap-2">+ <div>Currently connected source: <span+ class="font-bold text-warning">{{ $application->source->name }}</span>+ </div><div class="flex gap-2"><x-forms.input placeholder="coollabsio/coolify-example" id="gitRepository" label="Repository" /><x-forms.input placeholder="main" id="gitBranch" label="Branch" />@@ -34,6 +37,35 @@<x-forms.input placeholder="HEAD" id="gitCommitSha" placeholder="HEAD" label="Commit SHA" /></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)+ <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() }}')"+ :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>+ </x-slot:customButton>+ </x-modal-confirmation>+ @endforeach+ </div>+ </div>+ @endif+@if ($privateKeyId)<h3 class="pt-4">Deploy Key</h3><div class="py-2 pt-4">Currently attached Private Key: <span