feat(domains): implement domain conflict detection and user confirmation modal across application components
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user