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
fix(applications): refresh pending configuration changes
Andras Bacsai0ecd488d6a58
diff --git a/app/Livewire/Project/Application/Advanced.php b/app/Livewire/Project/Application/Advanced.phpindex 618958140b..947368a0d6 100644--- a/app/Livewire/Project/Application/Advanced.php+++ b/app/Livewire/Project/Application/Advanced.php@@ -219,6 +219,7 @@ class Advanced extends Component}$this->syncData(true);$this->dispatch('success', 'Settings saved.');+ $this->dispatch('configurationChanged');} catch (\Throwable $e) {return handleError($e, $this);}@@ -237,6 +238,7 @@ class Advanced extends Componentif (is_null($this->customInternalName)) {$this->syncData(true);$this->dispatch('success', 'Custom name saved.');+ $this->dispatch('configurationChanged');return;}@@ -256,6 +258,7 @@ class Advanced extends Component}$this->syncData(true);$this->dispatch('success', 'Custom name saved.');+ $this->dispatch('configurationChanged');} catch (\Throwable $e) {return handleError($e, $this);}diff --git a/app/Livewire/Project/Application/Source.php b/app/Livewire/Project/Application/Source.phpindex 422dd6b285..3ef5ccf7c4 100644--- a/app/Livewire/Project/Application/Source.php+++ b/app/Livewire/Project/Application/Source.php@@ -109,6 +109,7 @@ class Source extends Component$this->application->refresh();$this->privateKeyName = $this->application->private_key->name;$this->dispatch('success', 'Private key updated!');+ $this->dispatch('configurationChanged');} catch (\Throwable $e) {return handleError($e, $this);}@@ -124,6 +125,7 @@ class Source extends Component}$this->syncData(true);$this->dispatch('success', 'Application source updated!');+ $this->dispatch('configurationChanged');} catch (\Throwable $e) {return handleError($e, $this);}diff --git a/app/Livewire/Project/Shared/ConfigurationChecker.php b/app/Livewire/Project/Shared/ConfigurationChecker.phpindex 1bf2ecadaa..d583e74e6a 100644--- a/app/Livewire/Project/Shared/ConfigurationChecker.php+++ b/app/Livewire/Project/Shared/ConfigurationChecker.php@@ -12,6 +12,7 @@ use App\Models\StandaloneMongodb;use App\Models\StandaloneMysql;use App\Models\StandalonePostgresql;use App\Models\StandaloneRedis;+use Illuminate\Contracts\View\View;use Livewire\Component;class ConfigurationChecker extends Component@@ -24,7 +25,7 @@ class ConfigurationChecker extends Componentpublic Application|Service|StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource;- public function getListeners()+ public function getListeners(): array{$teamId = auth()->user()->currentTeam()->id;@@ -34,18 +35,25 @@ class ConfigurationChecker extends Component];}- public function mount()+ public function mount(): void{$this->configurationChanged();}- public function render()+ public function render(): View{return view('livewire.project.shared.configuration-checker');}- public function configurationChanged()+ public function refreshConfigurationChanges(): void{+ $this->configurationChanged();+ }++ public function configurationChanged(): void+ {+ $this->resource->refresh();+if ($this->resource instanceof Application) {$diff = $this->resource->pendingDeploymentConfigurationDiff();$this->isConfigurationChanged = $diff->isChanged();diff --git a/resources/views/livewire/project/shared/configuration-checker.blade.php b/resources/views/livewire/project/shared/configuration-checker.blade.phpindex 7d5ee70af4..2c4440dfbb 100644--- a/resources/views/livewire/project/shared/configuration-checker.blade.php+++ b/resources/views/livewire/project/shared/configuration-checker.blade.php@@ -23,7 +23,8 @@Please redeploy to apply the new configuration.@endif<button type="button" class="ml-1 font-semibold underline text-coollabs dark:text-warning"- @click="configurationDiffModalOpen = true">+ x-on:click="$wire.refreshConfigurationChanges().then(() => configurationDiffModalOpen = true)"+ wire:loading.attr="disabled" wire:target="refreshConfigurationChanges">View changes</button>@elsediff --git a/tests/Feature/ApplicationSourceLocalhostKeyTest.php b/tests/Feature/ApplicationSourceLocalhostKeyTest.phpindex 9b9b7b184f..1a38bd26e7 100644--- a/tests/Feature/ApplicationSourceLocalhostKeyTest.php+++ b/tests/Feature/ApplicationSourceLocalhostKeyTest.php@@ -24,12 +24,23 @@ beforeEach(function () {$this->environment = Environment::factory()->create(['project_id' => $this->project->id]);});+function applicationSourceValidPrivateKey(): string+{+ return '-----BEGIN OPENSSH PRIVATE KEY-----+b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW+QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk+hwAAAAtzc2gtZWQyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevA+AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV+uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==+-----END OPENSSH PRIVATE KEY-----';+}+describe('Application Source with localhost key (id=0)', function () {test('renders deploy key section when private_key_id is 0', function () {$privateKey = PrivateKey::create(['id' => 0,'name' => 'localhost',- 'private_key' => 'test-key-content',+ 'private_key' => applicationSourceValidPrivateKey(),'team_id' => $this->team->id,]);@@ -56,4 +67,19 @@ describe('Application Source with localhost key (id=0)', function () {->assertDontSee('Deploy Key')->assertSee('No source connected');});++ test('dispatches configuration changed when source settings are saved', function () {+ $application = Application::factory()->create([+ 'environment_id' => $this->environment->id,+ 'git_repository' => 'coollabsio/coolify',+ 'git_branch' => 'main',+ 'git_commit_sha' => 'HEAD',+ ]);++ Livewire::test(Source::class, ['application' => $application])+ ->set('gitBranch', 'next')+ ->call('submit')+ ->assertHasNoErrors()+ ->assertDispatched('configurationChanged');+ });});diff --git a/tests/Feature/Livewire/ConfigurationCheckerTest.php b/tests/Feature/Livewire/ConfigurationCheckerTest.phpindex 3dfa447129..edf8c5044f 100644--- a/tests/Feature/Livewire/ConfigurationCheckerTest.php+++ b/tests/Feature/Livewire/ConfigurationCheckerTest.php@@ -70,6 +70,45 @@ it('renders the changed configuration labels', function () {->assertSee('A rebuild is required.');});+it('refreshes configuration changes when the event is received', function () {+ $application = configurationCheckerApplication($this->environment);+ markConfigurationCheckerApplicationDeployed($application);++ $component = Livewire::test(ConfigurationChecker::class, ['resource' => $application->refresh()])+ ->assertSet('isConfigurationChanged', false)+ ->assertDontSee('The latest configuration has not been applied');++ $application->update(['build_command' => 'pnpm build']);++ $component+ ->dispatch('configurationChanged')+ ->assertSet('isConfigurationChanged', true)+ ->assertSee('The latest configuration has not been applied')+ ->assertSee('Build command');+});++it('refreshes stale modal configuration diff before opening changes', function () {+ $application = configurationCheckerApplication($this->environment);+ markConfigurationCheckerApplicationDeployed($application);++ $application->update(['build_command' => 'pnpm build']);++ $component = Livewire::test(ConfigurationChecker::class, ['resource' => $application->refresh()])+ ->assertSee('Build command')+ ->assertDontSee('Start command');++ $application->update([+ 'build_command' => 'npm run build',+ 'start_command' => 'node server.js',+ ]);++ $component+ ->call('refreshConfigurationChanges')+ ->assertSet('isConfigurationChanged', true)+ ->assertSee('Start command')+ ->assertDontSee('Build command');+});+it('does not render environment variable secret values', function () {$application = configurationCheckerApplication($this->environment);EnvironmentVariable::create([diff --git a/tests/Feature/Livewire/Project/Application/AdvancedStopGracePeriodTest.php b/tests/Feature/Livewire/Project/Application/AdvancedStopGracePeriodTest.phpindex 8d8de1d471..1bc1795021 100644--- a/tests/Feature/Livewire/Project/Application/AdvancedStopGracePeriodTest.php+++ b/tests/Feature/Livewire/Project/Application/AdvancedStopGracePeriodTest.php@@ -48,6 +48,16 @@ it('saves a valid stop grace period', function () {expect($application->settings()->first()->stop_grace_period)->toBe(300);});+it('dispatches configuration changed when advanced settings are saved', function () {+ $application = createApplicationForAdvancedStopGracePeriodTest();++ Livewire::test(Advanced::class, ['application' => $application])+ ->set('includeSourceCommitInBuild', true)+ ->call('submit')+ ->assertHasNoErrors()+ ->assertDispatched('configurationChanged');+});+it('clears the stop grace period when submitted empty', function () {$application = createApplicationForAdvancedStopGracePeriodTest();$application->settings->update(['stop_grace_period' => 300]);