mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
parent
bd32f09407
commit
3dc26e2dbe
@ -6,9 +6,11 @@ namespace Icinga\Controllers;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Exception\NotFoundError;
|
use Icinga\Exception\NotFoundError;
|
||||||
|
use Icinga\Forms\ConfirmRemovalForm;
|
||||||
use Icinga\Forms\Navigation\NavigationConfigForm;
|
use Icinga\Forms\Navigation\NavigationConfigForm;
|
||||||
use Icinga\Web\Controller;
|
use Icinga\Web\Controller;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,7 +168,32 @@ class NavigationController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function removeAction()
|
public function removeAction()
|
||||||
{
|
{
|
||||||
|
$itemName = $this->params->getRequired('name');
|
||||||
|
|
||||||
|
$navigationConfigForm = new NavigationConfigForm();
|
||||||
|
$navigationConfigForm->setIniConfig($this->Auth()->getUser()->loadNavigationConfig());
|
||||||
|
$form = new ConfirmRemovalForm();
|
||||||
|
$form->setRedirectUrl('navigation');
|
||||||
|
$form->setTitle(sprintf($this->translate('Remove Navigation Item %s'), $itemName));
|
||||||
|
$form->setOnSuccess(function (ConfirmRemovalForm $form) use ($itemName, $navigationConfigForm) {
|
||||||
|
try {
|
||||||
|
$navigationConfigForm->delete($itemName);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$form->error($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($navigationConfigForm->save()) {
|
||||||
|
Notification::success(sprintf(t('Navigation Item "%s" successfully removed'), $itemName));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$form->handleRequest();
|
||||||
|
|
||||||
|
$this->view->form = $form;
|
||||||
|
$this->render('form');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
6
application/views/scripts/navigation/form.phtml
Normal file
6
application/views/scripts/navigation/form.phtml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<div class="controls">
|
||||||
|
<?= $tabs->showOnlyCloseButton(); ?>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<?= $form; ?>
|
||||||
|
</div>
|
Loading…
x
Reference in New Issue
Block a user