Merge pull request #2755 from Icinga/feature/keep-quick-actions-in-action-form-2675

Preserve quick actions in a command form view
This commit is contained in:
Eric Lippmann 2017-03-28 10:15:37 +02:00
commit 0fc45ea953
2 changed files with 26 additions and 18 deletions

View File

@ -11,6 +11,7 @@
} else {
echo $this->render('partials/object/service-header.phtml');
} ?>
<?= $this->render('partials/object/quick-actions.phtml') ?>
</div>
<div class="content object-command">
<?= $form ?>

View File

@ -56,25 +56,8 @@ abstract class MonitoredObjectController extends Controller
public function showAction()
{
$this->setAutorefreshInterval(10);
$this->setupQuickActionForms();
$auth = $this->Auth();
if ($auth->hasPermission('monitoring/command/schedule-check')) {
$checkNowForm = new CheckNowCommandForm();
$checkNowForm
->setObjects($this->object)
->handleRequest();
$this->view->checkNowForm = $checkNowForm;
}
if (! in_array((int) $this->object->state, array(0, 99))) {
if ((bool) $this->object->acknowledged) {
if ($auth->hasPermission('monitoring/command/remove-acknowledgement')) {
$removeAckForm = new RemoveAcknowledgementCommandForm();
$removeAckForm
->setObjects($this->object)
->handleRequest();
$this->view->removeAckForm = $removeAckForm;
}
}
}
$this->object->populate();
$this->handleFormatRequest();
$toggleFeaturesForm = new ToggleObjectFeaturesCommandForm(array(
@ -139,6 +122,7 @@ abstract class MonitoredObjectController extends Controller
$this->view->tabs->remove('dashboard');
$this->view->tabs->remove('menu-entry');
$this->_helper->viewRenderer('partials/command/object-command-form', null, true);
$this->setupQuickActionForms();
return $form;
}
@ -263,4 +247,27 @@ abstract class MonitoredObjectController extends Controller
}
$tabs->extend(new DashboardAction())->extend(new MenuAction());
}
/**
* Create quick action forms and pass them to the view
*/
protected function setupQuickActionForms()
{
$auth = $this->Auth();
if ($auth->hasPermission('monitoring/command/schedule-check')) {
$this->view->checkNowForm = $checkNowForm = new CheckNowCommandForm();
$checkNowForm
->setObjects($this->object)
->handleRequest();
}
if (! in_array((int) $this->object->state, array(0, 99))
&& $this->object->acknowledged
&& $auth->hasPermission('monitoring/command/remove-acknowledgement')
) {
$this->view->removeAckForm = $removeAckForm = new RemoveAcknowledgementCommandForm();
$removeAckForm
->setObjects($this->object)
->handleRequest();
}
}
}