From e70d096325c960cceace50880e7dd8cec06156dd Mon Sep 17 00:00:00 2001 From: Montse Ortega Date: Fri, 29 Nov 2024 14:38:13 +0100 Subject: [PATCH] Disable CNV operator when user selects MTV operator --- .../clusterConfiguration/operators/CnvCheckbox.tsx | 8 +++++++- .../operators/MtvOperatorCheckbox.tsx | 3 ++- .../featureSupportLevels/featureStateUtils.ts | 10 ++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/CnvCheckbox.tsx b/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/CnvCheckbox.tsx index da450d1e0e..0cab41b568 100644 --- a/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/CnvCheckbox.tsx +++ b/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/CnvCheckbox.tsx @@ -10,7 +10,10 @@ import { PopoverIcon, } from '../../../../common'; import CnvHostRequirements from './CnvHostRequirements'; -import { getCnvIncompatibleWithLvmReason } from '../../featureSupportLevels/featureStateUtils'; +import { + getCnvDisabledWithMtvReason, + getCnvIncompatibleWithLvmReason, +} from '../../featureSupportLevels/featureStateUtils'; import { OcmCheckboxField } from '../../ui/OcmFormFields'; import { useNewFeatureSupportLevel } from '../../../../common/components/newFeatureSupportLevels'; import NewFeatureSupportLevelBadge from '../../../../common/components/newFeatureSupportLevels/NewFeatureSupportLevelBadge'; @@ -83,6 +86,9 @@ const CnvCheckbox = ({ const lvmSupport = featureSupportLevel.getFeatureSupportLevel('LVM'); reason = getCnvIncompatibleWithLvmReason(values, lvmSupport); } + if (!reason) { + reason = getCnvDisabledWithMtvReason(values); + } setDisabledReason(reason); }, [values, featureSupportLevel]); diff --git a/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/MtvOperatorCheckbox.tsx b/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/MtvOperatorCheckbox.tsx index f78e694147..3d8b21265c 100644 --- a/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/MtvOperatorCheckbox.tsx +++ b/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/MtvOperatorCheckbox.tsx @@ -55,8 +55,9 @@ const MtvCheckbox = ({ clusterId }: { clusterId: ClusterOperatorProps['clusterId const fieldId = getFieldId(Mtv_FIELD_NAME, 'input'); const [disabledReason, setDisabledReason] = useState(); - const selectCNVOperator = (checked: boolean) => + const selectCNVOperator = (checked: boolean) => { setFieldValue('useContainerNativeVirtualization', checked); + }; React.useEffect(() => { const disabledReason = featureSupportLevelContext.getFeatureDisabledReason('MTV'); diff --git a/libs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.ts b/libs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.ts index 6161a41b90..8bac5adc6e 100644 --- a/libs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.ts +++ b/libs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.ts @@ -19,6 +19,7 @@ const LVMS_OPERATOR_LABEL = 'Logical Volume Manager Storage'; const LVM_OPERATOR_LABEL = 'Logical Volume Manager'; const ODF_OPERATOR_LABEL = 'OpenShift Data Foundation'; const OPENSHIFT_AI_OPERATOR_LABEL = 'OpenShift AI'; +const MTV_OPERATOR_LABEL = 'Migration Toolkit for Virtualization'; export const clusterExistsReason = 'This option is not editable after the draft cluster is created'; @@ -280,3 +281,12 @@ const getOpenShiftAIDisabledReason = ( } return undefined; }; + +export const getCnvDisabledWithMtvReason = (operatorValues: OperatorsValues) => { + const mustDisableCnv = + operatorValues.useContainerNativeVirtualization && + operatorValues.useMigrationToolkitforVirtualization; + return mustDisableCnv + ? `Currently, you need to install ${CNV_OPERATOR_LABEL} operator at the same time as ${MTV_OPERATOR_LABEL} operator.` + : undefined; +};