mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 10:08:45 +02:00
N°9144 Small fixes
> Prevent verification when some dependencies are missing > Close unclosed div > Change progress bar title depending on step > Fix ignored "check uninstall check" flag > Added phpunit tests to cover "check uninstall check" flag > Progress bar appropriately reflect error status (red & not animated)
This commit is contained in:
@@ -69,7 +69,7 @@ class WizStepDataAudit extends WizStepInstall
|
||||
|
||||
$aInstallParams = $this->BuildConfig();
|
||||
|
||||
$this->AddProgressBar($oPage);
|
||||
$this->AddProgressBar($oPage, 'Progress of the verification');
|
||||
|
||||
$sJSONData = json_encode($aInstallParams);
|
||||
$oPage->add('<input type="hidden" id="installer_parameters" value="'.utils::EscapeHtml($sJSONData).'"/>');
|
||||
@@ -78,17 +78,19 @@ class WizStepDataAudit extends WizStepInstall
|
||||
$oPage->add('<input type="hidden" id="authent_token" value="'.$sAuthentToken.'"/>');
|
||||
$sApplicationUrl = $this->oWizard->GetParameter('application_url').'pages/exec.php?exec_module=combodo-data-feature-removal&exec_page=index.php';
|
||||
$oPage->add('<input type="hidden" id="application_url" value="'.$sApplicationUrl.'"/>');
|
||||
|
||||
if (!$this->CheckDependencies()) {
|
||||
$oPage->error($this->sDependencyIssue);
|
||||
}
|
||||
|
||||
$oPage->add_ready_script(
|
||||
<<<JS
|
||||
$oPage->add_ready_script(<<<JS
|
||||
$("#wiz_form").data("installation_status", "error");
|
||||
document.getElementById("setup_msg").innerText = "Unmet dependencies";
|
||||
JS);
|
||||
} else {
|
||||
$oPage->add_ready_script(<<<JS
|
||||
$("#wiz_form").data("installation_status", "not started");
|
||||
ExecuteStep("");
|
||||
JS
|
||||
);
|
||||
JS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function AddProgressErrorScript($oPage, $aRes)
|
||||
|
||||
@@ -58,9 +58,9 @@ class WizStepInstall extends AbstractWizStepInstall
|
||||
return new WizardState(WizStepDone::class);
|
||||
}
|
||||
|
||||
protected function AddProgressBar(WebPage $oPage)
|
||||
protected function AddProgressBar(WebPage $oPage, string $sTitle = 'Progress of the operations')
|
||||
{
|
||||
$oPage->add('<fieldset id="installation_progress"><legend>Progress of the installation</legend>');
|
||||
$oPage->add('<fieldset id="installation_progress"><legend>'.$sTitle.'</legend>');
|
||||
$oPage->add('<div id="progress_content">');
|
||||
$oPage->LinkScriptFromAppRoot('setup/jquery.progression.js');
|
||||
$oPage->add('<p class="center"><span id="setup_msg">Ready to start...</span></p><div style="display:block;margin-left: auto; margin-right:auto;" id="progress">0%</div>');
|
||||
@@ -74,7 +74,7 @@ class WizStepInstall extends AbstractWizStepInstall
|
||||
{
|
||||
|
||||
$aInstallParams = $this->BuildConfig();
|
||||
$this->AddProgressBar($oPage);
|
||||
$this->AddProgressBar($oPage, 'Progress of the installation');
|
||||
|
||||
$sJSONData = json_encode($aInstallParams);
|
||||
$oPage->add('<input type="hidden" id="installer_parameters" value="'.utils::EscapeHtml($sJSONData).'"/>');
|
||||
@@ -136,6 +136,7 @@ EOF
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
$("#wiz_form").data("installation_status", "error");
|
||||
$("#progress .progress").addClass('progress-error');
|
||||
WizardUpdateButtons();
|
||||
$('#setup_error').html('$sMessage').show();
|
||||
EOF
|
||||
|
||||
@@ -126,6 +126,7 @@ HTML
|
||||
);
|
||||
|
||||
$sAuthentToken = $this->oWizard->GetParameter('authent', '');
|
||||
$oPage->add('</div>');
|
||||
$oPage->add('<input type="hidden" id="authent_token" value="'.$sAuthentToken.'"/>');
|
||||
//$oPage->add('</fieldset>');
|
||||
$oPage->add_ready_script(
|
||||
|
||||
@@ -680,10 +680,14 @@ EOF
|
||||
if ($bMissingFromDisk) {
|
||||
$bDisabled = true;
|
||||
$bChecked = false;
|
||||
} elseif ($bMandatory || $bInstalled && !$bCanBeUninstalled) {
|
||||
} elseif ($bMandatory) {
|
||||
$bDisabled = true;
|
||||
$bChecked = true;
|
||||
} elseif ($bInstalled && !$bCanBeUninstalled && !$bDisableUninstallCheck) {
|
||||
$bChecked = true;
|
||||
$bDisabled = true;
|
||||
}
|
||||
|
||||
if ($bAllDisabled) {
|
||||
$bDisabled = true;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
'uninstallable' => true,
|
||||
],
|
||||
'bCurrentSelected' => false,
|
||||
'bDisableUninstallChecks' => false,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => true,
|
||||
'missing' => false,
|
||||
@@ -59,6 +60,7 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
'uninstallable' => true,
|
||||
],
|
||||
'bCurrentSelected' => true,
|
||||
'bDisableUninstallChecks' => false,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => true,
|
||||
'missing' => false,
|
||||
@@ -77,6 +79,7 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
'uninstallable' => true,
|
||||
],
|
||||
'bCurrentSelected' => false,
|
||||
'bDisableUninstallChecks' => false,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => true,
|
||||
'missing' => true,
|
||||
@@ -95,6 +98,7 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
'uninstallable' => true,
|
||||
],
|
||||
'bCurrentSelected' => false,
|
||||
'bDisableUninstallChecks' => false,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => true,
|
||||
'missing' => true,
|
||||
@@ -113,6 +117,7 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
'uninstallable' => false,
|
||||
],
|
||||
'bCurrentSelected' => false,
|
||||
'bDisableUninstallChecks' => false,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => false,
|
||||
'missing' => true,
|
||||
@@ -133,6 +138,7 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
'uninstallable' => true,
|
||||
],
|
||||
'bCurrentSelected' => false,
|
||||
'bDisableUninstallChecks' => false,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => true,
|
||||
'missing' => false,
|
||||
@@ -153,6 +159,7 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
'uninstallable' => false,
|
||||
],
|
||||
'bCurrentSelected' => false,
|
||||
'bDisableUninstallChecks' => false,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => false,
|
||||
'missing' => false,
|
||||
@@ -161,6 +168,27 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
'checked' => true,
|
||||
],
|
||||
],
|
||||
'An installed non uninstallable extension should be enabled if the "disable uninstallation check" flag is set' => [
|
||||
'aExtensionsOnDiskOrDb' => [
|
||||
'itop-ext1' => [
|
||||
'installed' => true,
|
||||
],
|
||||
],
|
||||
'aWizardStepDefinition' => [
|
||||
'extension_code' => 'itop-ext1',
|
||||
'mandatory' => false,
|
||||
'uninstallable' => false,
|
||||
],
|
||||
'bCurrentSelected' => true,
|
||||
'bDisableUninstallChecks' => true,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => false,
|
||||
'missing' => false,
|
||||
'installed' => true,
|
||||
'disabled' => false,
|
||||
'checked' => true,
|
||||
],
|
||||
],
|
||||
'A mandatory extension should be checked and disabled' => [
|
||||
'aExtensionsOnDiskOrDb' => [
|
||||
'itop-ext1' => [
|
||||
@@ -173,6 +201,28 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
'uninstallable' => true,
|
||||
],
|
||||
'bCurrentSelected' => false,
|
||||
'bDisableUninstallChecks' => false,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => true,
|
||||
'missing' => false,
|
||||
'installed' => false,
|
||||
'disabled' => true,
|
||||
'checked' => true,
|
||||
],
|
||||
],
|
||||
'A mandatory extension should be checked and disabled even if the "disable uninstallation check" flag is set' => [
|
||||
'aExtensionsOnDiskOrDb' => [
|
||||
'itop-ext1' => [
|
||||
'installed' => false,
|
||||
],
|
||||
],
|
||||
'aWizardStepDefinition' => [
|
||||
'extension_code' => 'itop-ext1',
|
||||
'mandatory' => true,
|
||||
'uninstallable' => true,
|
||||
],
|
||||
'bCurrentSelected' => false,
|
||||
'bDisableUninstallChecks' => true,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => true,
|
||||
'missing' => false,
|
||||
@@ -205,6 +255,7 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
],
|
||||
],
|
||||
'bCurrentSelected' => false,
|
||||
'bDisableUninstallChecks' => false,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => true,
|
||||
'missing' => false,
|
||||
@@ -237,6 +288,7 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
],
|
||||
],
|
||||
'bCurrentSelected' => false,
|
||||
'bDisableUninstallChecks' => false,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => true,
|
||||
'missing' => false,
|
||||
@@ -269,6 +321,7 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
],
|
||||
],
|
||||
'bCurrentSelected' => false,
|
||||
'bDisableUninstallChecks' => false,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => true,
|
||||
'missing' => false,
|
||||
@@ -301,6 +354,7 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
],
|
||||
],
|
||||
'bCurrentSelected' => false,
|
||||
'bDisableUninstallChecks' => false,
|
||||
'aExpectedFlags' => [
|
||||
'uninstallable' => true,
|
||||
'missing' => false,
|
||||
@@ -315,10 +369,10 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
/**
|
||||
* @dataProvider ProviderComputeChoiceFlags
|
||||
*/
|
||||
public function testComputeChoiceFlags($aExtensionsOnDiskOrDb, $aWizardStepDefinition, $bIsCurrentSelected, $aExpectedFlags)
|
||||
public function testComputeChoiceFlags($aExtensionsOnDiskOrDb, $aWizardStepDefinition, $bIsCurrentSelected, $bDisableUninstallChecks, $aExpectedFlags)
|
||||
{
|
||||
$this->oStep->setExtensionMap(iTopExtensionsMapFake::createFromArray($aExtensionsOnDiskOrDb));
|
||||
$aFlags = $this->oStep->ComputeChoiceFlags($aWizardStepDefinition, '_0', $bIsCurrentSelected ? ['_0' => '_0'] : [], false, false, true);
|
||||
$aFlags = $this->oStep->ComputeChoiceFlags($aWizardStepDefinition, '_0', $bIsCurrentSelected ? ['_0' => '_0'] : [], false, $bDisableUninstallChecks, true);
|
||||
$this->assertEquals($aExpectedFlags, $aFlags);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user