mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(env): keep preview variable order when sorting is disabled
Closes #9876
This commit is contained in:
@@ -1216,15 +1216,7 @@ class Application extends BaseModel
|
||||
public 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()
|
||||
|
||||
@@ -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']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user