Setup: Only allow to validate the API transport configuration

refs #3101
This commit is contained in:
Johannes Meyer 2017-11-21 13:46:29 +01:00
parent 22c6bf75e7
commit e4fd8d5124
3 changed files with 22 additions and 16 deletions

View File

@ -355,7 +355,9 @@ class TransportConfigForm extends ConfigForm
}
if ($this->getSubForm('transport_form') instanceof ApiTransportForm) {
if (isset($formData['force_creation']) && $formData['force_creation']) {
if (! isset($formData['transport_validation'])
&& isset($formData['force_creation']) && $formData['force_creation']
) {
// ignore any validation result
return true;
}
@ -372,10 +374,10 @@ class TransportConfigForm extends ConfigForm
'checkbox',
'force_creation',
array(
'order' => 0,
'ignore' => true,
'label' => $this->translate('Force Changes'),
'description' => $this->translate(
'order' => 0,
'ignore' => true,
'label' => $this->translate('Force Changes'),
'description' => $this->translate(
'Check this box to enforce changes without connectivity validation'
)
)

View File

@ -94,6 +94,7 @@ class MonitoringWizard extends Wizard implements SetupWizard
* @param Form $page The page to add the buttons to
*
* @todo This is never called, because its a sub-wizard only
* @todo This is missing the ´transport_validation´ case
* @see WebWizard::addButtons which does some of the needed work
*/
protected function addButtons(Form $page)

View File

@ -36,6 +36,7 @@ use Icinga\Module\Setup\Requirement\PhpConfigRequirement;
use Icinga\Module\Setup\Requirement\PhpModuleRequirement;
use Icinga\Module\Setup\Requirement\PhpVersionRequirement;
use Icinga\Module\Setup\Requirement\ConfigDirectoryRequirement;
use Icinga\Module\Monitoring\Forms\Config\Transport\ApiTransportForm;
/**
* Icinga Web 2 Setup Wizard
@ -383,17 +384,19 @@ class WebWizard extends Wizard implements SetupWizard
// TODO(mf): This should be handled by MonitoringWizard
if ($page->getName() === 'setup_command_transport') {
$page->addElement(
'submit',
'transport_validation',
array(
'ignore' => true,
'label' => t('Validate Configuration'),
'data-progress-label' => t('Validation In Progress'),
'decorators' => array('ViewHelper')
)
);
$page->getDisplayGroup('buttons')->addElement($page->getElement('transport_validation'));
if ($page->getSubForm('transport_form')->getSubForm('transport_form') instanceof ApiTransportForm) {
$page->addElement(
'submit',
'transport_validation',
array(
'ignore' => true,
'label' => t('Validate Configuration'),
'data-progress-label' => t('Validation In Progress'),
'decorators' => array('ViewHelper')
)
);
$page->getDisplayGroup('buttons')->addElement($page->getElement('transport_validation'));
}
}
}