Skip to content

Commit

Permalink
Show module requirements as a separate table
Browse files Browse the repository at this point in the history
refs #8508
  • Loading branch information
Johannes Meyer committed Mar 10, 2015
1 parent c44d5d2 commit 59f43a0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 58 deletions.
28 changes: 14 additions & 14 deletions modules/setup/application/forms/RequirementsPage.php
Expand Up @@ -4,19 +4,19 @@
namespace Icinga\Module\Setup\Forms;

use Icinga\Web\Form;
use Icinga\Module\Setup\RequirementSet;
use Icinga\Module\Setup\SetupWizard;

/**
* Wizard page to list setup requirements
*/
class RequirementsPage extends Form
{
/**
* The requirements to list
* The wizard
*
* @var RequirementSet
* @var SetupWizard
*/
protected $set;
protected $wizard;

/**
* Initialize this page
Expand All @@ -28,30 +28,30 @@ public function init()
}

/**
* Set the requirements to list
* Set the wizard
*
* @param RequirementSet $set
* @param SetupWizard $wizard
*
* @return self
*/
public function setRequirements(RequirementSet $set)
public function setWizard(SetupWizard $wizard)
{
$this->set = $set;
$this->wizard = $wizard;
return $this;
}

/**
* Return the requirements to list
* Return the wizard
*
* @return RequirementSet
* @return SetupWizard
*/
public function getRequirements()
public function getWizard()
{
return $this->set;
return $this->wizard;
}

/**
* Validate the given form data and check whether the requirements are fulfilled
* Validate the given form data and check whether the wizard's requirements are fulfilled
*
* @param array $data The data to validate
*
Expand All @@ -63,6 +63,6 @@ public function isValid($data)
return false;
}

return $this->set->fulfilled();
return $this->wizard->getRequirements()->fulfilled();
}
}
Expand Up @@ -2,34 +2,37 @@

use Icinga\Web\Wizard;

$requirements = $form->getRequirements();
echo $requirements;

?>
<div class="buttons requirements-refresh">
<?php $title = $this->translate('You may also need to restart the web-server for the changes to take effect!'); ?>
<?= $this->qlink(
$this->translate('Refresh'),
null,
null,
array(
'class' => 'button-like',
'title' => $title,
'aria-label' => sprintf($this->translate('Refresh the page; %s'), $title)
)
); ?>
</div>
<h1>Icinga Web 2</h1>
<?= $form->getWizard()->getRequirements(true); ?>
<?php foreach ($form->getWizard()->getPage('setup_modules')->getModuleWizards() as $moduleName => $wizard): ?>
<h1><?= ucwords($moduleName) . ' ' . $this->translate('Module'); ?></h1>
<?= $wizard->getRequirements(); ?>
<?php endforeach ?>
<form id="<?= $form->getName(); ?>" name="<?= $form->getName(); ?>" enctype="<?= $form->getEncType(); ?>" method="<?= $form->getMethod(); ?>" action="<?= $form->getAction(); ?>">
<?= $form->getElement($form->getTokenElementName()); ?>
<?= $form->getElement($form->getUidElementName()); ?>
<div class="buttons">
<?= $form->getElement(Wizard::BTN_PREV); ?>
<?php
$btn = $form->getElement(Wizard::BTN_NEXT);
if (! $requirements->fulfilled()) {
if (! $form->getWizard()->getRequirements()->fulfilled()) {
$btn->setAttrib('disabled', 1);
}
echo $btn;
?>
<div class="requirements-refresh">
<?php $title = $this->translate('You may also need to restart the web-server for the changes to take effect!'); ?>
<?= $this->qlink(
$this->translate('Refresh'),
null,
null,
array(
'class' => 'button-like',
'title' => $title,
'aria-label' => sprintf($this->translate('Refresh the page; %s'), $title)
)
); ?>
</div>
</div>
</form>
10 changes: 6 additions & 4 deletions modules/setup/library/Setup/WebWizard.php
Expand Up @@ -115,7 +115,7 @@ protected function init()
public function setupPage(Form $page, Request $request)
{
if ($page->getName() === 'setup_requirements') {
$page->setRequirements($this->getRequirements());
$page->setWizard($this);
} elseif ($page->getName() === 'setup_preferences_type') {
$authData = $this->getPageData('setup_authentication_type');
if ($authData['type'] === 'db') {
Expand Down Expand Up @@ -355,7 +355,7 @@ public function getSetup()
/**
* @see SetupWizard::getRequirements()
*/
public function getRequirements()
public function getRequirements($skipModules = false)
{
$set = new RequirementSet();

Expand Down Expand Up @@ -502,8 +502,10 @@ public function getRequirements()
)
)));

foreach ($this->getWizards() as $wizard) {
$set->merge($wizard->getRequirements());
if (! $skipModules) {
foreach ($this->getWizards() as $wizard) {
$set->merge($wizard->getRequirements());
}
}

return $set;
Expand Down
33 changes: 10 additions & 23 deletions public/css/icinga/setup.less
Expand Up @@ -168,14 +168,19 @@
}

form#setup_requirements {
margin-top: 2em;
padding-top: 0.5em;
border-top: 2px solid @colorPetrol;
}

div.requirements-refresh {
width: 25%;
margin-left: 75%;
text-align: center;
div.buttons div.requirements-refresh {
width: 25%;
float: right;
text-align: center;

a.button-like {
padding: 0.1em 0.4em;
}
}
}

#setup > table.requirements {
Expand Down Expand Up @@ -230,24 +235,6 @@ div.requirements-refresh {
background-color: @colorCritical;
}
}

&.btn-update {
padding-top: 0.3em;
text-align: center;

div.buttons {
margin: 0;

a.button-like {
padding: 0.2em 0.5em;
background-color: @colorPetro;

&:hover, &:focus {
background-color: #666;
}
}
}
}
}
}

Expand Down

0 comments on commit 59f43a0

Please sign in to comment.