Skip to content

Commit 6dc0bb2

Browse files
authored
Allow cloning of service sets in branches (#2896)
fixes #2890 Blocked by #2895
2 parents d56ca2c + 6c766df commit 6dc0bb2

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

application/forms/IcingaCloneObjectForm.php

+18-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ public function setup()
2929
{
3030
$isBranch = $this->branch && $this->branch->isBranch();
3131
$branchOnly = $this->object->get('id') === null;
32-
if ($isBranch && $this->object instanceof IcingaObject && $this->object->isTemplate()) {
32+
33+
if (
34+
$isBranch
35+
&& $this->object->isTemplate()
36+
&& ! $this->object instanceof IcingaServiceSet
37+
) {
3338
$this->addHtml(Hint::error($this->translate(
3439
'Templates cannot be cloned in Configuration Branches'
3540
)));
@@ -149,7 +154,12 @@ public function onSuccess()
149154
);
150155

151156
$isBranch = $this->branch && $this->branch->isBranch();
152-
if ($object->isTemplate() && $isBranch) {
157+
158+
if (
159+
$isBranch
160+
&& $this->object->isTemplate()
161+
&& ! $this->object instanceof IcingaServiceSet
162+
) {
153163
throw new IcingaException('Cloning templates is not available for Branches');
154164
}
155165

@@ -218,8 +228,13 @@ public function onSuccess()
218228
$clone->set('host_id', $newId);
219229
}
220230
} elseif ($new instanceof IcingaServiceSet) {
221-
$clone->set('service_set_id', $newId);
231+
if ($isBranch) {
232+
$clone->set('service_set', $newName);
233+
} else {
234+
$clone->set('service_set_id', $newId);
235+
}
222236
}
237+
223238
$store->store($clone);
224239
}
225240

library/Director/Web/Controller/ObjectController.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,14 @@ public function cloneAction()
218218
$this->addTitle($this->translate('Clone: %s'), $object->getObjectName())
219219
->addBackToObjectLink();
220220

221-
if ($object->isTemplate() && $this->showNotInBranch($this->translate('Cloning Templates'))) {
222-
return;
223-
}
221+
if (! $object instanceof IcingaServiceSet) {
222+
if ($object->isTemplate() && $this->showNotInBranch($this->translate('Cloning Templates'))) {
223+
return;
224+
}
224225

225-
if ($object->isTemplate() && $this->showNotInBranch($this->translate('Cloning Apply Rules'))) {
226-
return;
226+
if ($object->isTemplate() && $this->showNotInBranch($this->translate('Cloning Apply Rules'))) {
227+
return;
228+
}
227229
}
228230

229231
$form = IcingaCloneObjectForm::load()

0 commit comments

Comments
 (0)