feat(domains): implement domain conflict detection and user confirmation modal across application components

This commit is contained in:
Andras Bacsai
2025-08-28 10:52:41 +02:00
parent 643343785a
commit 80499a03d8
14 changed files with 390 additions and 26 deletions
+48 -3
View File
@@ -51,9 +51,16 @@ class General extends Component
public $parsedServiceDomains = [];
public $domainConflicts = [];
public $showDomainConflictModal = false;
public $forceSaveDomains = false;
protected $listeners = [
'resetDefaultLabels',
'configurationChanged' => '$refresh',
'confirmDomainUsage',
];
protected function rules(): array
@@ -485,10 +492,33 @@ class General extends Component
}
}
}
checkDomainUsage(resource: $this->application);
// Check for domain conflicts if not forcing save
if (! $this->forceSaveDomains) {
$result = checkDomainUsage(resource: $this->application);
if ($result['hasConflicts']) {
$this->domainConflicts = $result['conflicts'];
$this->showDomainConflictModal = true;
return false;
}
} else {
// Reset the force flag after using it
$this->forceSaveDomains = false;
}
$this->application->fqdn = $domains->implode(',');
$this->resetDefaultLabels(false);
}
return true;
}
public function confirmDomainUsage()
{
$this->forceSaveDomains = true;
$this->showDomainConflictModal = false;
$this->submit();
}
public function setRedirect()
@@ -536,7 +566,9 @@ class General extends Component
$this->application->parseHealthcheckFromDockerfile($this->application->dockerfile);
}
$this->checkFqdns();
if (! $this->checkFqdns()) {
return; // Stop if there are conflicts and user hasn't confirmed
}
$this->application->save();
if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE' && ! $this->application->settings->is_container_label_readonly_enabled) {
@@ -588,7 +620,20 @@ class General extends Component
}
}
}
checkDomainUsage(resource: $this->application);
// Check for domain conflicts if not forcing save
if (! $this->forceSaveDomains) {
$result = checkDomainUsage(resource: $this->application);
if ($result['hasConflicts']) {
$this->domainConflicts = $result['conflicts'];
$this->showDomainConflictModal = true;
return;
}
} else {
// Reset the force flag after using it
$this->forceSaveDomains = false;
}
$this->application->save();
$this->resetDefaultLabels();
}
+32 -1
View File
@@ -25,6 +25,14 @@ class Previews extends Component
public int $rate_limit_remaining;
public $domainConflicts = [];
public $showDomainConflictModal = false;
public $forceSaveDomains = false;
public $pendingPreviewId = null;
protected $rules = [
'application.previews.*.fqdn' => 'string|nullable',
];
@@ -49,6 +57,16 @@ class Previews extends Component
}
}
public function confirmDomainUsage()
{
$this->forceSaveDomains = true;
$this->showDomainConflictModal = false;
if ($this->pendingPreviewId) {
$this->save_preview($this->pendingPreviewId);
$this->pendingPreviewId = null;
}
}
public function save_preview($preview_id)
{
try {
@@ -63,7 +81,20 @@ class Previews extends Component
$this->dispatch('error', 'Validating DNS failed.', "Make sure you have added the DNS records correctly.<br><br>$preview->fqdn->{$this->application->destination->server->ip}<br><br>Check this <a target='_blank' class='underline dark:text-white' href='https://coolify.io/docs/knowledge-base/dns-configuration'>documentation</a> for further help.");
$success = false;
}
checkDomainUsage(resource: $this->application, domain: $preview->fqdn);
// Check for domain conflicts if not forcing save
if (! $this->forceSaveDomains) {
$result = checkDomainUsage(resource: $this->application, domain: $preview->fqdn);
if ($result['hasConflicts']) {
$this->domainConflicts = $result['conflicts'];
$this->showDomainConflictModal = true;
$this->pendingPreviewId = $preview_id;
return;
}
} else {
// Reset the force flag after using it
$this->forceSaveDomains = false;
}
}
if (! $preview) {