diff --git a/application/controllers/DashboardsController.php b/application/controllers/DashboardsController.php index e0285ddc2..01f3586ac 100644 --- a/application/controllers/DashboardsController.php +++ b/application/controllers/DashboardsController.php @@ -97,7 +97,9 @@ class DashboardsController extends CompatController $homeForm->on(HomeForm::ON_SUCCESS, function () use ($homeForm) { $this->getResponse()->setHeader('X-Icinga-Extra-Updates', '#menu'); - $this->redirectNow($homeForm->getRedirectUrl()); + $params = ['home' => $homeForm->getPopulatedValue('title')]; + + $this->redirectNow(Url::fromPath(Dashboard::BASE_ROUTE . '/settings')->setParams($params)); })->handleRequest($this->getServerRequest()); $this->setTitle(t('Add new Dashboard Home')); diff --git a/application/forms/Dashboard/DashletForm.php b/application/forms/Dashboard/DashletForm.php index 544a4125c..e5943d783 100644 --- a/application/forms/Dashboard/DashletForm.php +++ b/application/forms/Dashboard/DashletForm.php @@ -133,16 +133,19 @@ class DashletForm extends SetupNewDashboardForm $removeButton = $this->createRemoveButton($targetUrl, t('Remove Dashlet')); $formControls = $this->createFormControls(); - $formControls->addHtml( + $formControls->add([ + $this->registerSubmitButton(t('Add to Dashboard')), $removeButton, - $this->createCancelButton(), - $this->registerSubmitButton(t('Add to Dashboard')) - ); + $this->createCancelButton() + ]); $this->addHtml($formControls); } else { $formControls = $this->createFormControls(); - $formControls->addHtml($this->createCancelButton(), $this->registerSubmitButton(t('Add to Dashboard'))); + $formControls->add([ + $this->registerSubmitButton(t('Add to Dashboard')), + $this->createCancelButton() + ]); $this->addHtml($formControls); } diff --git a/application/forms/Dashboard/HomeForm.php b/application/forms/Dashboard/HomeForm.php index b497ac34c..aebd1be42 100644 --- a/application/forms/Dashboard/HomeForm.php +++ b/application/forms/Dashboard/HomeForm.php @@ -8,17 +8,9 @@ use Icinga\Web\Dashboard\Common\BaseDashboard; use Icinga\Web\Dashboard\Dashboard; use Icinga\Web\Dashboard\DashboardHome; use Icinga\Web\Notification; -use ipl\Web\Url; class HomeForm extends BaseDashboardForm { - protected function init() - { - parent::init(); - - $this->setRedirectUrl((string) Url::fromPath(Dashboard::BASE_ROUTE . '/settings')); - } - public function load(BaseDashboard $dashboard) { $this->populate(['title' => $dashboard->getTitle()]); @@ -34,16 +26,14 @@ class HomeForm extends BaseDashboardForm ]); $formControls = $this->createFormControls(); + $formControls->addHtml($this->registerSubmitButton($this->isUpdating() ? t('Update Home') : t('Add Home'))); + if ($this->isUpdating()) { $removeTargetUrl = (clone $this->requestUrl)->setPath(Dashboard::BASE_ROUTE . '/remove-home'); $formControls->addHtml($this->createRemoveButton($removeTargetUrl, t('Remove Home'))); } - $formControls->addHtml( - $this->createCancelButton(), - $this->registerSubmitButton($this->isUpdating() ? t('Update Home') : t('Add Home')) - ); - + $formControls->addHtml($this->createCancelButton()); $this->addHtml($formControls); } @@ -63,9 +53,6 @@ class HomeForm extends BaseDashboardForm return; } - $redirect = Url::fromPath(Dashboard::BASE_ROUTE . '/settings')->setParams(['home' => $home->getName()]); - $this->setRedirectUrl((string) $redirect); - $this->dashboard->manageEntry($home); Notification::success(sprintf(t('Added dashboard home "%s" successfully'), $home->getName())); diff --git a/application/forms/Dashboard/PaneForm.php b/application/forms/Dashboard/PaneForm.php index 64ab3ff1a..c5fb0fe04 100644 --- a/application/forms/Dashboard/PaneForm.php +++ b/application/forms/Dashboard/PaneForm.php @@ -54,16 +54,16 @@ class PaneForm extends BaseDashboardForm } $formControls = $this->createFormControls(); + $formControls->addHtml( + $this->registerSubmitButton($this->isUpdating() ? t('Update Pane') : t('Add Dashboard')) + ); + if ($this->isUpdating()) { $removeTargetUrl = (clone $this->requestUrl)->setPath(Dashboard::BASE_ROUTE . '/remove-pane'); $formControls->addHtml($this->createRemoveButton($removeTargetUrl, t('Remove Pane'))); } - $formControls->addHtml( - $this->createCancelButton(), - $this->registerSubmitButton($this->isUpdating() ? t('Update Pane') : t('Add Dashboard')) - ); - + $formControls->addHtml($this->createCancelButton()); $this->addHtml($formControls); } diff --git a/application/forms/Dashboard/SetupNewDashboardForm.php b/application/forms/Dashboard/SetupNewDashboardForm.php index f5d4652ee..1a66bd497 100644 --- a/application/forms/Dashboard/SetupNewDashboardForm.php +++ b/application/forms/Dashboard/SetupNewDashboardForm.php @@ -243,7 +243,7 @@ class SetupNewDashboardForm extends BaseDashboardForm } $formControls = $this->createFormControls(); - $formControls->addHtml($this->createCancelButton(), $submitButton); + $formControls->add([$submitButton, $this->createCancelButton()]); $this->addHtml($formControls); }