Skip to content

Commit

Permalink
Adjust removebackend-action to suit the new backend form interface
Browse files Browse the repository at this point in the history
Drops additionally the ConfirmRemovalForm of the monitoring module
as there is already one in icingaweb2's form-set.

refs #5525
  • Loading branch information
Johannes Meyer committed Jul 25, 2014
1 parent a78d113 commit d7ed6bd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 91 deletions.
27 changes: 12 additions & 15 deletions modules/monitoring/application/controllers/ConfigController.php
Expand Up @@ -7,8 +7,8 @@
use Icinga\Config\PreservingIniWriter;
use Icinga\Web\Controller\ModuleActionController;
use Icinga\Web\Notification;
use Icinga\Form\Config\ConfirmRemovalForm;
use Icinga\Module\Monitoring\Form\Config\BackendForm;
use Icinga\Module\Monitoring\Form\Config\ConfirmRemovalForm;
use Icinga\Module\Monitoring\Form\Config\Instance\EditInstanceForm;
use Icinga\Module\Monitoring\Form\Config\Instance\CreateInstanceForm;
use Icinga\Exception\NotReadableError;
Expand Down Expand Up @@ -107,29 +107,26 @@ public function createbackendAction()
public function removebackendAction()
{
$backend = $this->getParam('backend');
if (!$this->isExistingBackend($backend)) {
$this->view->error = 'Unknown backend ' . $backend;
return;
$backendsConfig = $this->Config('backends')->toArray();
if (false === array_key_exists($backend, $backendsConfig)) {
// TODO: Should behave as in the app's config controller (Specific redirect to an error action)
Notification::error(sprintf($this->translate('Cannot remove "%s". Backend not found.'), $backend));
$this->redirectNow('monitoring/config');
}
$form = new ConfirmRemovalForm();
$form->setRequest($this->getRequest());
$form->setRemoveTarget('backend', $backend);

if ($form->isSubmittedAndValid()) {
$configArray = $this->Config('backends')->toArray();
unset($configArray[$backend]);

if ($this->writeConfiguration(new Zend_Config($configArray), 'backends')) {
Notification::success('Backend "' . $backend . '" Removed');
$form = new ConfirmRemovalForm();
$request = $this->getRequest();
if ($request->isPost() && $form->isValid($request->getPost())) {
unset($backendsConfig[$backend]);
if ($this->writeConfiguration($backendsConfig, 'backends')) {
Notification::success(sprintf($this->translate('Backend "%s" successfully removed.'), $backend));
$this->redirectNow('monitoring/config');
} else {
$this->render('show-configuration');
}
return;
}

$this->view->form = $form;
$this->view->name = $backend;
}

/**
Expand Down
68 changes: 0 additions & 68 deletions modules/monitoring/application/forms/Config/ConfirmRemovalForm.php

This file was deleted.

@@ -1,8 +1,2 @@

<h4><i class="icinga-icon-remove"></i> Remove Backend "<?= $this->escape($this->name) ?>"</h4>

<p>
Are you sure you want to remove the backend <?= $this->escape($this->name) ?>?
</p>

<?= $this->form; ?>
<h4><?= $this->translate('Remove Existing Backend'); ?></h4>
<?= $form; ?>

0 comments on commit d7ed6bd

Please sign in to comment.