Refactor custom labels handling in General.php and update Docker Compose Content label in general.blade.php

This commit is contained in:
Andras Bacsai 2024-01-02 17:14:52 +01:00
parent a8ca57d095
commit 83d96c8d11
2 changed files with 11 additions and 6 deletions

View File

@ -117,7 +117,9 @@ public function mount()
$this->isConfigurationChanged = $this->application->isConfigurationChanged();
$this->customLabels = $this->application->parseContainerLabels();
if (!$this->customLabels) {
$this->resetDefaultLabels(false);
$this->customLabels = str(implode(",", generateLabelsApplication($this->application)))->replace(',', "\n");
$this->application->custom_labels = base64_encode($this->customLabels);
$this->application->save();
}
$this->initialDockerComposeLocation = $this->application->docker_compose_location;
$this->checkLabelUpdates();
@ -204,7 +206,12 @@ public function updatedApplicationFqdn()
public function submit($showToaster = true)
{
try {
ray($this->initialDockerComposeLocation, $this->application->docker_compose_location);
if (!$this->customLabels) {
$this->customLabels = str(implode(",", generateLabelsApplication($this->application)))->replace(',', "\n");
$this->application->custom_labels = base64_encode($this->customLabels);
$this->application->save();
}
if ($this->application->build_pack === 'dockercompose' && $this->initialDockerComposeLocation !== $this->application->docker_compose_location) {
$this->loadComposeFile();
}
@ -212,9 +219,7 @@ public function submit($showToaster = true)
if ($this->ports_exposes !== $this->application->ports_exposes) {
$this->resetDefaultLabels(false);
}
if (!$this->customLabels) {
$this->resetDefaultLabels(false);
}
if (data_get($this->application, 'build_pack') === 'dockerimage') {
$this->validate([
'application.docker_registry_image_name' => 'required',

View File

@ -189,7 +189,7 @@ class="underline" href="https://coolify.io/docs/docker-registries"
<x-forms.button wire:click="loadComposeFile">Reload Compose File</x-forms.button>
@if ($application->settings->is_raw_compose_deployment_enabled)
<x-forms.textarea rows="10" readonly id="application.docker_compose_raw"
label="Docker Compose Content" helper="You need to modify the docker compose file." />
label="Docker Compose Content (applicationId: {{$application->id}})" helper="You need to modify the docker compose file." />
@else
<x-forms.textarea rows="10" readonly id="application.docker_compose"
label="Docker Compose Content" helper="You need to modify the docker compose file." />