From 5da314014fb1757e83faba3e34b57981fc24966f Mon Sep 17 00:00:00 2001
From: Montse Ortega <mortegag@redhat.com>
Date: Mon, 10 Mar 2025 16:25:06 +0100
Subject: [PATCH] AMD_GPU operator should follor BE feature support level

---
 .../operators/AmdGpuCheckbox.tsx              | 27 +++++++------------
 .../operators/SupportedOperators.tsx          |  2 ++
 .../featureSupportLevels/featureStateUtils.ts |  5 ++++
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/AmdGpuCheckbox.tsx b/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/AmdGpuCheckbox.tsx
index 300d110852..55effbd6a3 100644
--- a/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/AmdGpuCheckbox.tsx
+++ b/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/AmdGpuCheckbox.tsx
@@ -1,8 +1,7 @@
-import React, { useState } from 'react';
+import React from 'react';
 import { FormGroup, HelperText, HelperTextItem, Tooltip } from '@patternfly/react-core';
 import { getFieldId, PopoverIcon } from '../../../../common';
 import { OcmCheckboxField } from '../../ui/OcmFormFields';
-import { useNewFeatureSupportLevel } from '../../../../common/components/newFeatureSupportLevels';
 import NewFeatureSupportLevelBadge from '../../../../common/components/newFeatureSupportLevels/NewFeatureSupportLevelBadge';
 import { SupportLevel } from '@openshift-assisted/types/./assisted-installer-service';
 
@@ -40,28 +39,22 @@ const AmdGpuHelperText = () => {
   );
 };
 
-const AmdGpuCheckbox = ({ disabledReason }: { disabledReason?: string }) => {
+const AmdGpuCheckbox = ({
+  disabledReason,
+  supportLevel,
+}: {
+  disabledReason?: string;
+  supportLevel?: SupportLevel | undefined;
+}) => {
   const fieldId = getFieldId(AMDGPU_FIELD_NAME, 'input');
-  const featureSupportLevel = useNewFeatureSupportLevel();
-  const [disabledReasonAmdGpu, setDisabledReason] = useState<string | undefined>();
-
-  React.useEffect(() => {
-    const reason = featureSupportLevel.getFeatureDisabledReason('AMD_GPU');
-    setDisabledReason(reason);
-  }, [featureSupportLevel]);
 
   return (
     <FormGroup isInline fieldId={fieldId}>
       <OcmCheckboxField
         name={AMDGPU_FIELD_NAME}
-        label={
-          <AmdGpuLabel
-            disabledReason={disabledReason ? disabledReason : disabledReasonAmdGpu}
-            supportLevel={featureSupportLevel.getFeatureSupportLevel('AMD_GPU')}
-          />
-        }
+        label={<AmdGpuLabel disabledReason={disabledReason} supportLevel={supportLevel} />}
         helperText={<AmdGpuHelperText />}
-        isDisabled={!!disabledReason || !!disabledReasonAmdGpu}
+        isDisabled={!!disabledReason}
       />
     </FormGroup>
   );
diff --git a/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/SupportedOperators.tsx b/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/SupportedOperators.tsx
index 25ffb28ff2..a41606f0a6 100644
--- a/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/SupportedOperators.tsx
+++ b/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/SupportedOperators.tsx
@@ -110,4 +110,6 @@ export const mapOperatorIdToFeatureId: { [key: string]: FeatureId } = {
   [OPERATOR_NAME_PIPELINES]: 'PIPELINES',
   [OPERATOR_NAME_SERVICEMESH]: 'SERVICEMESH',
   [OPERATOR_NAME_NVIDIA_GPU]: 'NVIDIA_GPU',
+  [OPERATOR_NAME_AMD_GPU]: 'AMD_GPU',
+  [OPERATOR_NAME_KMM]: 'KMM',
 };
diff --git a/libs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.ts b/libs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.ts
index 0058aefc37..4878c44e5f 100644
--- a/libs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.ts
+++ b/libs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.ts
@@ -289,6 +289,11 @@ export const getNewFeatureDisabledReason = (
         return `Service mesh is not available with the selected CPU architecture.`;
       }
     }
+    case 'AMD_GPU': {
+      if (!isSupported) {
+        return `AMD GPU is not available with the selected CPU architecture.`;
+      }
+    }
     default: {
       return undefined;
     }