IcingaCloneObjectForm: explicit baseUrl

fixes #1894
This commit is contained in:
Thomas Gelf 2020-11-30 10:17:44 +01:00
parent aa0980e168
commit a2f294fea2
4 changed files with 24 additions and 4 deletions

View File

@ -9,6 +9,8 @@ use Icinga\Module\Director\Web\Table\IcingaScheduledDowntimeRangeTable;
class ScheduledDowntimeController extends ObjectController class ScheduledDowntimeController extends ObjectController
{ {
protected $objectBaseUrl = 'director/scheduled-downtime';
public function rangesAction() public function rangesAction()
{ {
/** @var IcingaScheduledDowntime $object */ /** @var IcingaScheduledDowntime $object */

View File

@ -15,6 +15,8 @@ class IcingaCloneObjectForm extends DirectorForm
/** @var IcingaObject */ /** @var IcingaObject */
protected $object; protected $object;
protected $baseObjectUrl;
public function setup() public function setup()
{ {
$name = $this->object->getObjectName(); $name = $this->object->getObjectName();
@ -93,6 +95,13 @@ class IcingaCloneObjectForm extends DirectorForm
); );
} }
public function setObjectBaseUrl($url)
{
$this->baseObjectUrl = $url;
return $this;
}
public function onSuccess() public function onSuccess()
{ {
$object = $this->object; $object = $this->object;
@ -195,7 +204,7 @@ class IcingaCloneObjectForm extends DirectorForm
); );
} else { } else {
$this->setSuccessUrl( $this->setSuccessUrl(
'director/' . strtolower($type), $this->baseObjectUrl ?: 'director/' . strtolower($type),
$new->getUrlParams() $new->getUrlParams()
); );
} }

View File

@ -18,6 +18,7 @@ next (will be 1.8.0)
* FIX: Inherited values in sets (arrays) are now shown (#1310) * FIX: Inherited values in sets (arrays) are now shown (#1310)
* FIX: Column layout broke with Web 2.8, has been fixed (#2065) * FIX: Column layout broke with Web 2.8, has been fixed (#2065)
* FIX: filter suggestion gave wrong values for DataList fields (#1918) * FIX: filter suggestion gave wrong values for DataList fields (#1918)
* FIX: clone-related scheduled downtime links have been fixes (#1894)
* FEATURE: Data Fields can now be grouped into categories (#1969) * FEATURE: Data Fields can now be grouped into categories (#1969)
* FEATURE: Inspect is now available for Packages, Stages and Files (#1995) * FEATURE: Inspect is now available for Packages, Stages and Files (#1995)
* FEATURE: Allow to disable the Director frontend / UI (#2007) * FEATURE: Allow to disable the Director frontend / UI (#2007)

View File

@ -3,7 +3,6 @@
namespace Icinga\Module\Director\Web\Controller; namespace Icinga\Module\Director\Web\Controller;
use gipfl\Web\Widget\Hint; use gipfl\Web\Widget\Hint;
use ipl\Html\Html;
use Icinga\Exception\IcingaException; use Icinga\Exception\IcingaException;
use Icinga\Exception\InvalidPropertyException; use Icinga\Exception\InvalidPropertyException;
use Icinga\Exception\NotFoundError; use Icinga\Exception\NotFoundError;
@ -46,6 +45,9 @@ abstract class ObjectController extends ActionController
protected $type; protected $type;
/** @var string|null */
protected $objectBaseUrl;
public function init() public function init()
{ {
parent::init(); parent::init();
@ -165,6 +167,7 @@ abstract class ObjectController extends ActionController
$object = $this->requireObject(); $object = $this->requireObject();
$form = IcingaCloneObjectForm::load() $form = IcingaCloneObjectForm::load()
->setObject($object) ->setObject($object)
->setObjectBaseUrl($this->getObjectBaseUrl())
->handleRequest(); ->handleRequest();
if ($object->isExternal()) { if ($object->isExternal()) {
@ -315,7 +318,7 @@ abstract class ObjectController extends ActionController
{ {
$this->actions()->add(Link::create( $this->actions()->add(Link::create(
$this->translate('Clone'), $this->translate('Clone'),
'director/' . $this->getType() .'/clone', $this->getObjectBaseUrl() . '/clone',
$this->object->getUrlParams(), $this->object->getUrlParams(),
array('class' => 'icon-paste') array('class' => 'icon-paste')
)); ));
@ -518,7 +521,7 @@ abstract class ObjectController extends ActionController
$this->actions()->add(Link::create( $this->actions()->add(Link::create(
$this->translate('back'), $this->translate('back'),
'director/' . strtolower($this->getType()), $this->getObjectBaseUrl(),
$params, $params,
['class' => 'icon-left-big'] ['class' => 'icon-left-big']
)); ));
@ -555,6 +558,11 @@ abstract class ObjectController extends ActionController
return $form; return $form;
} }
protected function getObjectBaseUrl()
{
return $this->objectBaseUrl ?: 'director/' . strtolower($this->getType());
}
protected function hasBasketSupport() protected function hasBasketSupport()
{ {
return $this->object->isTemplate() || $this->object->isGroup(); return $this->object->isTemplate() || $this->object->isGroup();