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(env): keep preview variable order when sorting is disabled
Andras Bacsai623d367a2ad1
diff --git a/app/Models/Application.php b/app/Models/Application.phpindex ce6ca04afe..1ea0bc9114 100644--- a/app/Models/Application.php+++ b/app/Models/Application.php@@ -1216,15 +1216,7 @@ class Application extends BaseModelpublic function environment_variables_preview(){return $this->morphMany(EnvironmentVariable::class, 'resourceable')- ->where('is_preview', true)- ->orderByRaw("- CASE- WHEN is_required = true THEN 1- WHEN LOWER(key) LIKE 'service_%' THEN 2- ELSE 3- END,- LOWER(key) ASC- ");+ ->where('is_preview', true);}public function runtime_environment_variables_preview()diff --git a/tests/Feature/EnvironmentVariableDevViewDirectiveTest.php b/tests/Feature/EnvironmentVariableDevViewDirectiveTest.phpindex 2a963edbef..8ce8a51e20 100644--- a/tests/Feature/EnvironmentVariableDevViewDirectiveTest.php+++ b/tests/Feature/EnvironmentVariableDevViewDirectiveTest.php@@ -144,3 +144,15 @@ it('names the preview text area in a directive error', function () {->call('submit')->assertDispatched('error', 'Preview deployments: Line 2: a "# coolify:" line must be directly above a KEY=value line.');});++it('keeps the saved order of preview variables when alphabetical sorting is disabled', function () {+ $component = ($this->devView)()+ ->assertSet('showPreview', true)+ ->assertSet('is_env_sorting_enabled', false)+ ->set('variablesPreview', "ZEBRA=1\nALPHA=2\nMIDDLE=3")+ ->call('submit')+ ->assertNotDispatched('error');++ expect($component->get('variablesPreview'))->toBe("ZEBRA=1\nALPHA=2\nMIDDLE=3")+ ->and($component->instance()->environmentVariablesPreview->pluck('key')->all())->toBe(['ZEBRA', 'ALPHA', 'MIDDLE']);+});