Revert "Add form controls in the correct order"

This reverts commit 61c3469fc63e559164016784034bcae18b3a2e04.
This commit is contained in:
raviks789 2022-06-10 14:44:39 +02:00 committed by Yonas Habteab
parent 122505ced4
commit 533d329810
5 changed files with 20 additions and 28 deletions

View File

@ -97,7 +97,9 @@ class DashboardsController extends CompatController
$homeForm->on(HomeForm::ON_SUCCESS, function () use ($homeForm) { $homeForm->on(HomeForm::ON_SUCCESS, function () use ($homeForm) {
$this->getResponse()->setHeader('X-Icinga-Extra-Updates', '#menu'); $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()); })->handleRequest($this->getServerRequest());
$this->setTitle(t('Add new Dashboard Home')); $this->setTitle(t('Add new Dashboard Home'));

View File

@ -133,16 +133,19 @@ class DashletForm extends SetupNewDashboardForm
$removeButton = $this->createRemoveButton($targetUrl, t('Remove Dashlet')); $removeButton = $this->createRemoveButton($targetUrl, t('Remove Dashlet'));
$formControls = $this->createFormControls(); $formControls = $this->createFormControls();
$formControls->addHtml( $formControls->add([
$this->registerSubmitButton(t('Add to Dashboard')),
$removeButton, $removeButton,
$this->createCancelButton(), $this->createCancelButton()
$this->registerSubmitButton(t('Add to Dashboard')) ]);
);
$this->addHtml($formControls); $this->addHtml($formControls);
} else { } else {
$formControls = $this->createFormControls(); $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); $this->addHtml($formControls);
} }

View File

@ -8,17 +8,9 @@ use Icinga\Web\Dashboard\Common\BaseDashboard;
use Icinga\Web\Dashboard\Dashboard; use Icinga\Web\Dashboard\Dashboard;
use Icinga\Web\Dashboard\DashboardHome; use Icinga\Web\Dashboard\DashboardHome;
use Icinga\Web\Notification; use Icinga\Web\Notification;
use ipl\Web\Url;
class HomeForm extends BaseDashboardForm class HomeForm extends BaseDashboardForm
{ {
protected function init()
{
parent::init();
$this->setRedirectUrl((string) Url::fromPath(Dashboard::BASE_ROUTE . '/settings'));
}
public function load(BaseDashboard $dashboard) public function load(BaseDashboard $dashboard)
{ {
$this->populate(['title' => $dashboard->getTitle()]); $this->populate(['title' => $dashboard->getTitle()]);
@ -34,16 +26,14 @@ class HomeForm extends BaseDashboardForm
]); ]);
$formControls = $this->createFormControls(); $formControls = $this->createFormControls();
$formControls->addHtml($this->registerSubmitButton($this->isUpdating() ? t('Update Home') : t('Add Home')));
if ($this->isUpdating()) { if ($this->isUpdating()) {
$removeTargetUrl = (clone $this->requestUrl)->setPath(Dashboard::BASE_ROUTE . '/remove-home'); $removeTargetUrl = (clone $this->requestUrl)->setPath(Dashboard::BASE_ROUTE . '/remove-home');
$formControls->addHtml($this->createRemoveButton($removeTargetUrl, t('Remove Home'))); $formControls->addHtml($this->createRemoveButton($removeTargetUrl, t('Remove Home')));
} }
$formControls->addHtml( $formControls->addHtml($this->createCancelButton());
$this->createCancelButton(),
$this->registerSubmitButton($this->isUpdating() ? t('Update Home') : t('Add Home'))
);
$this->addHtml($formControls); $this->addHtml($formControls);
} }
@ -63,9 +53,6 @@ class HomeForm extends BaseDashboardForm
return; return;
} }
$redirect = Url::fromPath(Dashboard::BASE_ROUTE . '/settings')->setParams(['home' => $home->getName()]);
$this->setRedirectUrl((string) $redirect);
$this->dashboard->manageEntry($home); $this->dashboard->manageEntry($home);
Notification::success(sprintf(t('Added dashboard home "%s" successfully'), $home->getName())); Notification::success(sprintf(t('Added dashboard home "%s" successfully'), $home->getName()));

View File

@ -54,16 +54,16 @@ class PaneForm extends BaseDashboardForm
} }
$formControls = $this->createFormControls(); $formControls = $this->createFormControls();
$formControls->addHtml(
$this->registerSubmitButton($this->isUpdating() ? t('Update Pane') : t('Add Dashboard'))
);
if ($this->isUpdating()) { if ($this->isUpdating()) {
$removeTargetUrl = (clone $this->requestUrl)->setPath(Dashboard::BASE_ROUTE . '/remove-pane'); $removeTargetUrl = (clone $this->requestUrl)->setPath(Dashboard::BASE_ROUTE . '/remove-pane');
$formControls->addHtml($this->createRemoveButton($removeTargetUrl, t('Remove Pane'))); $formControls->addHtml($this->createRemoveButton($removeTargetUrl, t('Remove Pane')));
} }
$formControls->addHtml( $formControls->addHtml($this->createCancelButton());
$this->createCancelButton(),
$this->registerSubmitButton($this->isUpdating() ? t('Update Pane') : t('Add Dashboard'))
);
$this->addHtml($formControls); $this->addHtml($formControls);
} }

View File

@ -243,7 +243,7 @@ class SetupNewDashboardForm extends BaseDashboardForm
} }
$formControls = $this->createFormControls(); $formControls = $this->createFormControls();
$formControls->addHtml($this->createCancelButton(), $submitButton); $formControls->add([$submitButton, $this->createCancelButton()]);
$this->addHtml($formControls); $this->addHtml($formControls);
} }