Skip to content

Commit

Permalink
Allow cloning of service sets in branches (#2896)
Browse files Browse the repository at this point in the history
fixes #2890 

Blocked by #2895
  • Loading branch information
lippserd authored Nov 19, 2024
2 parents d56ca2c + 6c766df commit 6dc0bb2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
21 changes: 18 additions & 3 deletions application/forms/IcingaCloneObjectForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ public function setup()
{
$isBranch = $this->branch && $this->branch->isBranch();
$branchOnly = $this->object->get('id') === null;
if ($isBranch && $this->object instanceof IcingaObject && $this->object->isTemplate()) {

if (
$isBranch
&& $this->object->isTemplate()
&& ! $this->object instanceof IcingaServiceSet
) {
$this->addHtml(Hint::error($this->translate(
'Templates cannot be cloned in Configuration Branches'
)));
Expand Down Expand Up @@ -149,7 +154,12 @@ public function onSuccess()
);

$isBranch = $this->branch && $this->branch->isBranch();
if ($object->isTemplate() && $isBranch) {

if (
$isBranch
&& $this->object->isTemplate()
&& ! $this->object instanceof IcingaServiceSet
) {
throw new IcingaException('Cloning templates is not available for Branches');
}

Expand Down Expand Up @@ -218,8 +228,13 @@ public function onSuccess()
$clone->set('host_id', $newId);
}
} elseif ($new instanceof IcingaServiceSet) {
$clone->set('service_set_id', $newId);
if ($isBranch) {
$clone->set('service_set', $newName);
} else {
$clone->set('service_set_id', $newId);
}
}

$store->store($clone);
}

Expand Down
12 changes: 7 additions & 5 deletions library/Director/Web/Controller/ObjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,14 @@ public function cloneAction()
$this->addTitle($this->translate('Clone: %s'), $object->getObjectName())
->addBackToObjectLink();

if ($object->isTemplate() && $this->showNotInBranch($this->translate('Cloning Templates'))) {
return;
}
if (! $object instanceof IcingaServiceSet) {
if ($object->isTemplate() && $this->showNotInBranch($this->translate('Cloning Templates'))) {
return;
}

if ($object->isTemplate() && $this->showNotInBranch($this->translate('Cloning Apply Rules'))) {
return;
if ($object->isTemplate() && $this->showNotInBranch($this->translate('Cloning Apply Rules'))) {
return;
}
}

$form = IcingaCloneObjectForm::load()
Expand Down

0 comments on commit 6dc0bb2

Please sign in to comment.