Skip to content

Commit 3b0356a

Browse files
committed
Make cloning service sets possible in Director Branches
1 parent 428a49f commit 3b0356a

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

application/forms/IcingaCloneObjectForm.php

+16-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ 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+
if (
33+
$isBranch
34+
&& $this->object instanceof IcingaObject
35+
&& ($this->object->isTemplate() && ! $this->object instanceof IcingaServiceSet)
36+
) {
3337
$this->addHtml(Hint::error($this->translate(
3438
'Templates cannot be cloned in Configuration Branches'
3539
)));
@@ -146,7 +150,11 @@ public function onSuccess()
146150
$object->getObjectName()
147151
);
148152

149-
if ($object->isTemplate() && $this->branch && $this->branch->isBranch()) {
153+
if (
154+
$this->branch
155+
&& $this->branch->isBranch()
156+
&& ($object->isTemplate() && ! ($object instanceof IcingaServiceSet))
157+
) {
150158
throw new IcingaException('Cloning templates is not available for Branches');
151159
}
152160

@@ -211,8 +219,13 @@ public function onSuccess()
211219
if ($new instanceof IcingaHost) {
212220
$clone->set('host_id', $newId);
213221
} elseif ($new instanceof IcingaServiceSet) {
214-
$clone->set('service_set_id', $newId);
222+
if ($this->branch && $this->branch->isBranch()) {
223+
$clone->set('service_set', $newName);
224+
} else {
225+
$clone->set('service_set_id', $newId);
226+
}
215227
}
228+
216229
$store->store($clone);
217230
}
218231

library/Director/Web/Controller/ObjectController.php

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

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

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

228230
$form = IcingaCloneObjectForm::load()

0 commit comments

Comments
 (0)