From 53c0d6de86e66c2327d1bee838c75151d66de5e0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 30 Jun 2021 18:53:41 +0200 Subject: [PATCH 1/4] Wizard: Transform emtpy page data values to null Previously the wizard wrote empty strings to config files. --- library/Icinga/Web/Wizard.php | 3 ++- modules/setup/library/Setup/Utils/DbTool.php | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Wizard.php b/library/Icinga/Web/Wizard.php index a0b27ce13..6ba90bc4d 100644 --- a/library/Icinga/Web/Wizard.php +++ b/library/Icinga/Web/Wizard.php @@ -3,6 +3,7 @@ namespace Icinga\Web; +use Icinga\Forms\ConfigForm; use LogicException; use InvalidArgumentException; use Icinga\Web\Session\SessionNamespace; @@ -286,7 +287,7 @@ class Wizard if ($isValid) { $pageData = & $this->getPageData(); - $pageData[$page->getName()] = $page->getValues(); + $pageData[$page->getName()] = ConfigForm::transformEmptyValuesToNull($page->getValues()); $this->setCurrentPage($this->getNewPage($requestedPage, $page)); $page->getResponse()->redirectAndExit($page->getRedirectUrl()); } diff --git a/modules/setup/library/Setup/Utils/DbTool.php b/modules/setup/library/Setup/Utils/DbTool.php index 0617065b8..5cf203e1b 100644 --- a/modules/setup/library/Setup/Utils/DbTool.php +++ b/modules/setup/library/Setup/Utils/DbTool.php @@ -121,6 +121,12 @@ class DbTool */ 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; } From 37c982a044f0965921b542959c40de2664713dd7 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 30 Jun 2021 18:54:47 +0200 Subject: [PATCH 2/4] MonitoringWizard: Remove redundant requirements and steps --- .../library/Monitoring/MonitoringWizard.php | 71 +------------------ 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index 17e6266e8..51ead8a4b 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -11,11 +11,9 @@ use Icinga\Module\Setup\SetupWizard; use Icinga\Module\Setup\RequirementSet; use Icinga\Module\Setup\Forms\SummaryPage; 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\TransportPage; use Icinga\Module\Monitoring\Forms\Setup\IdoResourcePage; -use Icinga\Module\Setup\Requirement\ClassRequirement; use Icinga\Module\Setup\Requirement\PhpModuleRequirement; /** @@ -29,7 +27,6 @@ class MonitoringWizard extends Wizard implements SetupWizard public function init() { $this->addPage(new WelcomePage()); - $this->addPage(new BackendPage()); $this->addPage(new IdoResourcePage()); $this->addPage(new TransportPage()); $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 * @@ -140,7 +113,7 @@ class MonitoringWizard extends Wizard implements SetupWizard $setup->addStep( new BackendStep(array( - 'backendConfig' => $pageData['setup_monitoring_backend'], + 'backendConfig' => ['name' => 'icinga', 'type' => 'ido'], 'resourceConfig' => array_diff_key( $pageData['setup_monitoring_ido'], //TODO: Prefer a new backend once implemented. array('skip_validation' => null) @@ -171,48 +144,6 @@ class MonitoringWizard extends Wizard implements SetupWizard public function getRequirements() { $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( 'optional' => true, 'condition' => 'curl', From 0ac92a44ce4fb40df92c2a7812bdb0a4377946a0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 30 Jun 2021 18:55:21 +0200 Subject: [PATCH 3/4] setup: Make sure CSS and JS is being reloaded prior first login --- .../setup/application/views/scripts/index/parts/finish.phtml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/setup/application/views/scripts/index/parts/finish.phtml b/modules/setup/application/views/scripts/index/parts/finish.phtml index 25ef1ba8f..dc5ba1c05 100644 --- a/modules/setup/application/views/scripts/index/parts/finish.phtml +++ b/modules/setup/application/views/scripts/index/parts/finish.phtml @@ -8,10 +8,11 @@ qlink( $this->translate('Login to Icinga Web 2'), - 'authentication/login?renderLayout', + 'authentication/login', null, array( 'class' => 'button-link login', + 'data-no-icinga-ajax' => true, 'title' => $this->translate('Show the login page of Icinga Web 2') ) ); ?> From a8c6ae8055a4fe78b22245eb8d2b5fe23f840bb6 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 30 Jun 2021 18:56:01 +0200 Subject: [PATCH 4/4] css: Fix wizard styles --- public/css/icinga/setup.less | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less index 7d77880d3..cf001220c 100644 --- a/public/css/icinga/setup.less +++ b/public/css/icinga/setup.less @@ -17,7 +17,6 @@ width: 100%; height: 5.5em; .var(background-color, icinga-blue); - border-bottom: 1px solid #d9d9d9; text-align: center; img { @@ -129,7 +128,7 @@ } } -.setup-content .control-group > * { +.setup-content .control-group > :not([hidden]) { display: inline-block; margin-right: 1em; } @@ -370,15 +369,17 @@ form#setup_requirements { margin: 3em auto 0; text-align: left; font-size: 0.9em; - border: 1px solid lightgrey; + border: 1px solid; + .var(border-color, gray-light); h3 { padding: 0.2em; margin: -1em -1em 1em; text-align: center; .var(color, text-color); - background-color: #f6fafa; - border: 1px solid lightgrey; + .var(background-color, gray-lightest); + border: 1px solid; + .var(border-color, gray-light); } img {