Skip to content

Commit aedc81f

Browse files
committed
N°9010 Refactor ComputeChoiceFlags
1 parent c3cc073 commit aedc81f

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

setup/wizardsteps.class.inc.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,11 +1941,22 @@ public function ComputeChoiceFlags(array $aChoice, string $sChoiceId, array $aSe
19411941
$bCanBeUninstalled = isset($aChoice['uninstallable']) ? $aChoice['uninstallable'] === true || $aChoice['uninstallable'] === 'yes' : $oITopExtension->CanBeUninstalled();
19421942
$bSelected = isset($aSelectedComponents[$sChoiceId]) && ($aSelectedComponents[$sChoiceId] == $sChoiceId);
19431943
$bMissingFromDisk = isset($aChoice['missing']) && $aChoice['missing'] === true;
1944-
1945-
$bMandatory = (isset($aChoice['mandatory']) && $aChoice['mandatory']) || $bUpgradeMode && !$bMissingFromDisk && $oITopExtension->bInstalled && !$bCanBeUninstalled && !$bDisableUninstallCheck;
1944+
$bMandatory = (isset($aChoice['mandatory']) && $aChoice['mandatory']);
19461945
$bInstalled = $bMissingFromDisk || $oITopExtension->bInstalled;
1947-
$bDisabled = $bMandatory || $bAllDisabled || $bMissingFromDisk;
1948-
$bChecked = !$bMissingFromDisk && ($bMandatory || $bSelected);
1946+
1947+
$bChecked = $bSelected;
1948+
$bDisabled = false;
1949+
if ($bMissingFromDisk) {
1950+
$bDisabled = true;
1951+
$bChecked = false;
1952+
}
1953+
elseif($bMandatory || $bInstalled && !$bCanBeUninstalled){
1954+
$bDisabled = true;
1955+
$bChecked = true;
1956+
}
1957+
if($bAllDisabled){
1958+
$bDisabled = true;
1959+
}
19491960

19501961
if (isset($aChoice['sub_options'])) {
19511962
$aOptions = $aChoice['sub_options']['options'] ?? [];

tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ public function ProviderComputeChoiceFlags()
6969
],
7070
'A missing extension should be disabled and unchecked' => [
7171
'aExtensionsOnDiskOrDb' => [
72-
'itop-ext1' => [
73-
'installed' => true,
74-
],
7572
],
7673
'aWizardStepDefinition' => [
7774
'extension_code' => 'itop-ext1',
@@ -90,9 +87,6 @@ public function ProviderComputeChoiceFlags()
9087
],
9188
'A missing extension should always be disabled and unchecked, even when mandatory' => [
9289
'aExtensionsOnDiskOrDb' => [
93-
'itop-ext1' => [
94-
'installed' => true,
95-
],
9690
],
9791
'aWizardStepDefinition' => [
9892
'extension_code' => 'itop-ext1',
@@ -111,9 +105,6 @@ public function ProviderComputeChoiceFlags()
111105
],
112106
'A missing extension should always be disabled and unchecked, even when non-uninstallable' => [
113107
'aExtensionsOnDiskOrDb' => [
114-
'itop-ext1' => [
115-
'installed' => true,
116-
],
117108
],
118109
'aWizardStepDefinition' => [
119110
'extension_code' => 'itop-ext1',

0 commit comments

Comments
 (0)