Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cloning of service sets in branches #2896

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions application/forms/IcingaCloneObjectForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ 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 instanceof IcingaObject
&& ($this->object->isTemplate() && ! $this->object instanceof IcingaServiceSet)
) {
$this->addHtml(Hint::error($this->translate(
'Templates cannot be cloned in Configuration Branches'
)));
Expand Down Expand Up @@ -148,7 +152,11 @@ public function onSuccess()
$object->getObjectName()
);

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

Expand Down Expand Up @@ -213,8 +221,13 @@ public function onSuccess()
if ($new instanceof IcingaHost) {
$clone->set('host_id', $newId);
} elseif ($new instanceof IcingaServiceSet) {
$clone->set('service_set_id', $newId);
if ($this->branch && $this->branch->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