mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
feat: enhance custom container name handling with validation and UI updates
This commit is contained in:
parent
a5599da836
commit
dd2fe5a3ac
2 changed files with 44 additions and 8 deletions
|
|
@ -236,12 +236,19 @@ class Advanced extends Component
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->customContainerNamePrefix = null;
|
||||||
$customInternalName = $this->customInternalName;
|
$customInternalName = $this->customInternalName;
|
||||||
$server = $this->application->destination->server;
|
$server = $this->application->destination->server;
|
||||||
$allApplications = $server->applications();
|
$allApplications = $server->applications();
|
||||||
|
|
||||||
$foundSameInternalName = $allApplications->filter(function ($application) {
|
$foundSameInternalName = $allApplications->filter(function ($application) {
|
||||||
return $application->id !== $this->application->id && $application->settings->custom_internal_name === $this->customInternalName;
|
if ($application->id === $this->application->id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $application->settings->custom_internal_name === $this->customInternalName
|
||||||
|
|| $application->settings->custom_container_name_prefix === $this->customInternalName;
|
||||||
});
|
});
|
||||||
if ($foundSameInternalName->isNotEmpty()) {
|
if ($foundSameInternalName->isNotEmpty()) {
|
||||||
$this->dispatch('error', 'This custom container name is already in use by another application on this server.');
|
$this->dispatch('error', 'This custom container name is already in use by another application on this server.');
|
||||||
|
|
@ -268,6 +275,32 @@ class Advanced extends Component
|
||||||
$this->customContainerNamePrefix = null;
|
$this->customContainerNamePrefix = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_null($this->customContainerNamePrefix)) {
|
||||||
|
$this->syncData(true);
|
||||||
|
$this->dispatch('success', 'Custom container name prefix saved.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->customInternalName = null;
|
||||||
|
$server = $this->application->destination->server;
|
||||||
|
$allApplications = $server->applications();
|
||||||
|
|
||||||
|
$foundDuplicate = $allApplications->filter(function ($application) {
|
||||||
|
if ($application->id === $this->application->id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $application->settings->custom_container_name_prefix === $this->customContainerNamePrefix
|
||||||
|
|| $application->settings->custom_internal_name === $this->customContainerNamePrefix;
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($foundDuplicate->isNotEmpty()) {
|
||||||
|
$this->dispatch('error', 'This custom container name prefix is already in use by another application on this server.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->syncData(true);
|
$this->syncData(true);
|
||||||
$this->dispatch('success', 'Custom container name prefix saved.');
|
$this->dispatch('success', 'Custom container name prefix saved.');
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|
|
||||||
|
|
@ -63,17 +63,20 @@
|
||||||
@if ($isConsistentContainerNameEnabled === false)
|
@if ($isConsistentContainerNameEnabled === false)
|
||||||
<form class="flex items-end gap-2 " wire:submit.prevent='saveCustomName'>
|
<form class="flex items-end gap-2 " wire:submit.prevent='saveCustomName'>
|
||||||
<x-forms.input
|
<x-forms.input
|
||||||
helper="You can add a custom name for your container.<br><br>The name will be converted to slug format when you save it. <span class='font-bold dark:text-warning'>You will lose the rolling update feature!</span>"
|
helper="You can add a custom name for your container.<br><br>The name will be converted to slug format when you save it. <span class='font-bold dark:text-warning'>You will lose the rolling update feature!</span><br><br><span class='dark:text-red-500 text-red-600'>Cannot be used together with Custom Container Name Prefix.</span>"
|
||||||
instantSave id="customInternalName" label="Custom Container Name" canGate="update"
|
id="customInternalName" label="Custom Container Name" canGate="update"
|
||||||
:canResource="$application" />
|
:canResource="$application" :disabled="!empty($customContainerNamePrefix)" />
|
||||||
<x-forms.button canGate="update" :canResource="$application" type="submit">Save</x-forms.button>
|
<x-forms.button canGate="update" :canResource="$application" type="submit"
|
||||||
|
:disabled="!empty($customContainerNamePrefix)">Save</x-forms.button>
|
||||||
</form>
|
</form>
|
||||||
<form class="flex items-end gap-2 " wire:submit.prevent='saveCustomNamePrefix'>
|
<form class="flex items-end gap-2 " wire:submit.prevent='saveCustomNamePrefix'>
|
||||||
<x-forms.input
|
<x-forms.input
|
||||||
helper="Set a custom prefix for your container name. The final name will be: <span class='font-bold'>your-prefix-randomGibberish</span>.<br><br>The name will be converted to slug format when you save it.<br><br>This option <span class='font-bold dark:text-success'>keeps rolling updates working!</span>"
|
helper="Set a custom prefix for your container name. The final name will be: <span class='font-bold'>your-prefix-timestamp</span>.<br><br>The name will be converted to slug format when you save it.<br><br>This option <span class='font-bold dark:text-success'>keeps rolling updates working!</span><br><br><span class='dark:text-red-500 text-red-600'>Cannot be used together with Custom Container Name.</span>"
|
||||||
id="customContainerNamePrefix" label="Custom Container Name Prefix" canGate="update"
|
id="customContainerNamePrefix" label="Custom Container Name Prefix" canGate="update"
|
||||||
:canResource="$application" placeholder="e.g. my-nextjs-app" />
|
:canResource="$application" placeholder="e.g. my-nextjs-app"
|
||||||
<x-forms.button canGate="update" :canResource="$application" type="submit">Save</x-forms.button>
|
:disabled="!empty($customInternalName)" />
|
||||||
|
<x-forms.button canGate="update" :canResource="$application" type="submit"
|
||||||
|
:disabled="!empty($customInternalName)">Save</x-forms.button>
|
||||||
</form>
|
</form>
|
||||||
@endif
|
@endif
|
||||||
@if ($application->build_pack === 'dockercompose')
|
@if ($application->build_pack === 'dockercompose')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue