Add icingadb as OR dependecy

Add only if the given module supports icingadb and has monitoring as a requirement
This commit is contained in:
Sukhwinder Dhillon 2021-11-03 12:41:57 +01:00 committed by Johannes Meyer
parent 703956c3da
commit 2c01f38dec
4 changed files with 85 additions and 2 deletions

View File

@ -11,7 +11,8 @@
$restrictions = $module->getProvidedRestrictions();
$permissions = $module->getProvidedPermissions();
$unmetDependencies = $moduleManager->hasUnmetDependencies($module->getName());
$state = $moduleData->enabled ? ($moduleData->loaded ? 'enabled' : 'failed') : 'disabled'
$isIcingadbSupported = isset($requiredMods['icingadb']);
$state = $moduleData->enabled ? ($moduleData->loaded ? 'enabled' : 'failed') : 'disabled';
?>
<table class="name-value-table">
<tr>
@ -82,13 +83,18 @@
<table class="name-value-table">
<caption><?= $this->translate('Modules') ?></caption>
<?php foreach ($requiredMods as $moduleName => $versionString): ?>
<?php if ($moduleName === 'monitoring' && $isIcingadbSupported && $moduleManager->has('icingadb', $requiredMods['icingadb'])) : ?>
<?php continue; ?>
<?php endif ?>
<tr>
<th><?= $this->escape($moduleName) ?></th>
<td>
<?php if ($moduleManager->has($moduleName, $versionString === true ? null : $versionString)): ?>
<?= $versionString === true ? '*' : $this->escape($versionString) ?>
<?php else: ?>
<span class="missing"><?= $versionString === true ? '*' : $this->escape($versionString) ?></span>
<span <?= ($moduleName === 'icingadb' && isset($requiredMods['monitoring']) && $moduleManager->has('monitoring', $requiredMods['monitoring'])) ? 'class="optional"' : 'class="missing"' ?>>
<?= $versionString === true ? '*' : $this->escape($versionString) ?>
</span>
<?php if (! $moduleManager->hasInstalled($moduleName)): ?>
(<?= $this->translate('not installed') ?>)
<?php else: ?>
@ -96,6 +102,9 @@
<?php endif ?>
<?php endif ?>
</td>
<?php if ($moduleName === 'monitoring' && $isIcingadbSupported) : ?>
<td class="or-separator"><?= $this->translate('or') ?></td>
<?php endif ?>
</tr>
<?php endforeach ?>
</table>

View File

@ -559,6 +559,17 @@ class Manager
$module = $this->getModule($name, false);
$requiredMods = $module->getRequiredModules();
if (isset($requiredMods['monitoring'], $requiredMods['icingadb'])) {
if (! $this->has('monitoring', $requiredMods['monitoring'])
&& ! $this->has('icingadb', $requiredMods['icingadb'])
) {
return true;
}
unset($requiredMods['monitoring'], $requiredMods['icingadb']);
}
foreach ($requiredMods as $moduleName => $moduleVersion) {
if (! $this->has($moduleName, $moduleVersion)) {
return true;

View File

@ -891,12 +891,51 @@ class Module
{
$requiredModules = $this->metadata()->modules ?: $this->metadata()->depends;
$hasIcingadb = isset($requiredModules['icingadb']);
if (isset($requiredModules['monitoring']) && ($this->isSupportingIcingadb() || $hasIcingadb)) {
$requiredMods = [];
$icingadbVersion = true;
if ($hasIcingadb) {
$icingadbVersion = isset($requiredModules['icingadb']) ? $requiredModules['icingadb'] : true;
unset($requiredModules['icingadb']);
}
foreach ($requiredModules as $name => $version) {
$requiredMods[$name] = $version;
if ($name === 'monitoring') {
$requiredMods['icingadb'] = $icingadbVersion;
}
}
$requiredModules = $requiredMods;
}
// Both modules are deprecated and their successors are now dependencies of web itself
unset($requiredModules['ipl'], $requiredModules['reactbundle']);
return $requiredModules;
}
/**
* Check whether module supports icingadb
*
* @return bool
*/
protected function isSupportingIcingadb()
{
$icingadbSupportingModules = [
'cube' => '1.2.0',
'jira' => '1.2.0',
'graphite' => '1.2.0',
'director' => '1.9.0',
'toplevelview' => '0.4.0',
'businessprocess' => '2.4.0'
];
return array_key_exists($this->getName(), $icingadbSupportingModules)
&& version_compare($this->getVersion(), $icingadbSupportingModules[$this->getName()], '>=');
}
/**
* Fetch module metadata
*

View File

@ -440,5 +440,29 @@ a:hover > .icon-cancel {
.var(color, color-critical);
font-weight: bold;
}
td {
white-space: nowrap;
&.or-separator {
width: 100%;
transform: translate(0, 50%);
padding-left: 3em;
&::before {
content: "";
position: absolute;
height: 1.5em;
width: 1.5em;
left: 0.5em;
border-top: 3px solid;
border-right: 3px solid;
.var(border-top-color, "gray");
.var(border-right-color, "gray");
border-top-right-radius: .50em;
transform: rotate(45deg);
}
}
}
}
}