Merge pull request #4410 from Icinga/fix/wizard

Fix wizard
This commit is contained in:
Johannes Meyer 2021-06-30 18:59:34 +02:00 committed by GitHub
commit 858d3ddfc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 77 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Web; namespace Icinga\Web;
use Icinga\Forms\ConfigForm;
use LogicException; use LogicException;
use InvalidArgumentException; use InvalidArgumentException;
use Icinga\Web\Session\SessionNamespace; use Icinga\Web\Session\SessionNamespace;
@ -286,7 +287,7 @@ class Wizard
if ($isValid) { if ($isValid) {
$pageData = & $this->getPageData(); $pageData = & $this->getPageData();
$pageData[$page->getName()] = $page->getValues(); $pageData[$page->getName()] = ConfigForm::transformEmptyValuesToNull($page->getValues());
$this->setCurrentPage($this->getNewPage($requestedPage, $page)); $this->setCurrentPage($this->getNewPage($requestedPage, $page));
$page->getResponse()->redirectAndExit($page->getRedirectUrl()); $page->getResponse()->redirectAndExit($page->getRedirectUrl());
} }

View File

@ -11,11 +11,9 @@ use Icinga\Module\Setup\SetupWizard;
use Icinga\Module\Setup\RequirementSet; use Icinga\Module\Setup\RequirementSet;
use Icinga\Module\Setup\Forms\SummaryPage; use Icinga\Module\Setup\Forms\SummaryPage;
use Icinga\Module\Monitoring\Forms\Setup\WelcomePage; use Icinga\Module\Monitoring\Forms\Setup\WelcomePage;
use Icinga\Module\Monitoring\Forms\Setup\BackendPage;
use Icinga\Module\Monitoring\Forms\Setup\SecurityPage; use Icinga\Module\Monitoring\Forms\Setup\SecurityPage;
use Icinga\Module\Monitoring\Forms\Setup\TransportPage; use Icinga\Module\Monitoring\Forms\Setup\TransportPage;
use Icinga\Module\Monitoring\Forms\Setup\IdoResourcePage; use Icinga\Module\Monitoring\Forms\Setup\IdoResourcePage;
use Icinga\Module\Setup\Requirement\ClassRequirement;
use Icinga\Module\Setup\Requirement\PhpModuleRequirement; use Icinga\Module\Setup\Requirement\PhpModuleRequirement;
/** /**
@ -29,7 +27,6 @@ class MonitoringWizard extends Wizard implements SetupWizard
public function init() public function init()
{ {
$this->addPage(new WelcomePage()); $this->addPage(new WelcomePage());
$this->addPage(new BackendPage());
$this->addPage(new IdoResourcePage()); $this->addPage(new IdoResourcePage());
$this->addPage(new TransportPage()); $this->addPage(new TransportPage());
$this->addPage(new SecurityPage()); $this->addPage(new SecurityPage());
@ -64,30 +61,6 @@ class MonitoringWizard extends Wizard implements SetupWizard
} }
} }
/**
* Return the new page to set as current page
*
* {@inheritdoc} Runs additional checks related to some registered pages.
*
* @param string $requestedPage The name of the requested page
* @param Form $originPage The origin page
*
* @return Form The new page
*
* @throws InvalidArgumentException In case the requested page does not exist or is not permitted yet
*/
protected function getNewPage($requestedPage, Form $originPage)
{
$skip = false;
$newPage = parent::getNewPage($requestedPage, $originPage);
if ($newPage->getName() === 'setup_monitoring_ido') {
$backendData = $this->getPageData('setup_monitoring_backend');
$skip = $backendData['type'] !== 'ido';
}
return $skip ? $this->skipPage($newPage) : $newPage;
}
/** /**
* Add buttons to the given page based on its position in the page-chain * Add buttons to the given page based on its position in the page-chain
* *
@ -140,7 +113,7 @@ class MonitoringWizard extends Wizard implements SetupWizard
$setup->addStep( $setup->addStep(
new BackendStep(array( new BackendStep(array(
'backendConfig' => $pageData['setup_monitoring_backend'], 'backendConfig' => ['name' => 'icinga', 'type' => 'ido'],
'resourceConfig' => array_diff_key( 'resourceConfig' => array_diff_key(
$pageData['setup_monitoring_ido'], //TODO: Prefer a new backend once implemented. $pageData['setup_monitoring_ido'], //TODO: Prefer a new backend once implemented.
array('skip_validation' => null) array('skip_validation' => null)
@ -171,48 +144,6 @@ class MonitoringWizard extends Wizard implements SetupWizard
public function getRequirements() public function getRequirements()
{ {
$set = new RequirementSet(); $set = new RequirementSet();
$backendSet = new RequirementSet(false, RequirementSet::MODE_OR);
$mysqlSet = new RequirementSet(true);
$mysqlSet->add(new PhpModuleRequirement(array(
'optional' => true,
'condition' => 'pdo_mysql',
'alias' => 'PDO-MySQL',
'description' => mt(
'monitoring',
'To access the IDO stored in a MySQL database the PDO-MySQL module for PHP is required.'
)
)));
$mysqlSet->add(new ClassRequirement(array(
'optional' => true,
'condition' => 'Zend_Db_Adapter_Pdo_Mysql',
'alias' => mt('monitoring', 'Zend database adapter for MySQL'),
'description' => mt(
'monitoring',
'The Zend database adapter for MySQL is required to access a MySQL database.'
)
)));
$backendSet->merge($mysqlSet);
$pgsqlSet = new RequirementSet(true);
$pgsqlSet->add(new PhpModuleRequirement(array(
'optional' => true,
'condition' => 'pdo_pgsql',
'alias' => 'PDO-PostgreSQL',
'description' => mt(
'monitoring',
'To access the IDO stored in a PostgreSQL database the PDO-PostgreSQL module for PHP is required.'
)
)));
$pgsqlSet->add(new ClassRequirement(array(
'optional' => true,
'condition' => 'Zend_Db_Adapter_Pdo_Pgsql',
'alias' => mt('monitoring', 'Zend database adapter for PostgreSQL'),
'description' => mt(
'monitoring',
'The Zend database adapter for PostgreSQL is required to access a PostgreSQL database.'
)
)));
$backendSet->merge($pgsqlSet);
$set->merge($backendSet);
$set->add(new PhpModuleRequirement(array( $set->add(new PhpModuleRequirement(array(
'optional' => true, 'optional' => true,
'condition' => 'curl', 'condition' => 'curl',

View File

@ -8,10 +8,11 @@
<?php if ($success): ?> <?php if ($success): ?>
<?= $this->qlink( <?= $this->qlink(
$this->translate('Login to Icinga Web 2'), $this->translate('Login to Icinga Web 2'),
'authentication/login?renderLayout', 'authentication/login',
null, null,
array( array(
'class' => 'button-link login', 'class' => 'button-link login',
'data-no-icinga-ajax' => true,
'title' => $this->translate('Show the login page of Icinga Web 2') 'title' => $this->translate('Show the login page of Icinga Web 2')
) )
); ?> ); ?>

View File

@ -121,6 +121,12 @@ class DbTool
*/ */
public function __construct(array $config) public function __construct(array $config)
{ {
if (! isset($config['port'])) {
// TODO: This is not quite correct, but works as it previously did. Previously empty values were not
// transformed no NULL (now they are) so if the port is now null, it's been the empty string.
$config['port'] = '';
}
$this->config = $config; $this->config = $config;
} }

View File

@ -17,7 +17,6 @@
width: 100%; width: 100%;
height: 5.5em; height: 5.5em;
.var(background-color, icinga-blue); .var(background-color, icinga-blue);
border-bottom: 1px solid #d9d9d9;
text-align: center; text-align: center;
img { img {
@ -129,7 +128,7 @@
} }
} }
.setup-content .control-group > * { .setup-content .control-group > :not([hidden]) {
display: inline-block; display: inline-block;
margin-right: 1em; margin-right: 1em;
} }
@ -370,15 +369,17 @@ form#setup_requirements {
margin: 3em auto 0; margin: 3em auto 0;
text-align: left; text-align: left;
font-size: 0.9em; font-size: 0.9em;
border: 1px solid lightgrey; border: 1px solid;
.var(border-color, gray-light);
h3 { h3 {
padding: 0.2em; padding: 0.2em;
margin: -1em -1em 1em; margin: -1em -1em 1em;
text-align: center; text-align: center;
.var(color, text-color); .var(color, text-color);
background-color: #f6fafa; .var(background-color, gray-lightest);
border: 1px solid lightgrey; border: 1px solid;
.var(border-color, gray-light);
} }
img { img {