diff --git a/packages/ocs/dashboards/persistent-external/breakdown-card.tsx b/packages/ocs/dashboards/persistent-external/breakdown-card.tsx index a1160afab..1a3646d59 100644 --- a/packages/ocs/dashboards/persistent-external/breakdown-card.tsx +++ b/packages/ocs/dashboards/persistent-external/breakdown-card.tsx @@ -31,7 +31,7 @@ import { TitleWithHelp, } from '../persistent-internal/capacity-breakdown-card/capacity-breakdown-card'; import '../persistent-internal/capacity-breakdown-card/capacity-breakdown-card.scss'; -import useClientFallback from './fallback-hook'; +import getClientFallback from './client-fallback'; export const BreakdownCard: React.FC = () => { const { t } = useCustomTranslation(); @@ -47,7 +47,7 @@ export const BreakdownCard: React.FC = () => { // name of created StorageClasses are prefix by StorageCluster name const storageClassName = systemFlags?.[clusterNs]?.ocsClusterName; - const storageClassNamePrefix = useClientFallback(storageClassName); + const storageClassNamePrefix = getClientFallback(storageClassName); const { queries, model, metric } = getBreakdownMetricsQuery( metricType, diff --git a/packages/ocs/dashboards/persistent-external/client-fallback.ts b/packages/ocs/dashboards/persistent-external/client-fallback.ts new file mode 100644 index 000000000..f0a548d6f --- /dev/null +++ b/packages/ocs/dashboards/persistent-external/client-fallback.ts @@ -0,0 +1,13 @@ +/** + * This hooks is for ODF Client Mode use case only. + * ODF client mode doesn't deploy ODF StorageCluster hence we will use no storage class prefix. We will rely on provisioners + * + */ +const getClientFallback = (storageClusterName: string) => { + if (storageClusterName) { + return storageClusterName; + } + return ''; +}; + +export default getClientFallback; diff --git a/packages/ocs/dashboards/persistent-external/fallback-hook.ts b/packages/ocs/dashboards/persistent-external/fallback-hook.ts deleted file mode 100644 index 4d7ee41c3..000000000 --- a/packages/ocs/dashboards/persistent-external/fallback-hook.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { StorageClassModel } from '@odf/shared/models'; -import { StorageClassResourceKind } from '@odf/shared/types'; -import { referenceForModel } from '@odf/shared/utils'; -import { - WatchK8sResource, - useK8sWatchResource, -} from '@openshift-console/dynamic-plugin-sdk'; - -const scResource: WatchK8sResource = { - isList: true, - kind: referenceForModel(StorageClassModel), -}; - -const fsProvisionerPostFix = '.cephfs.csi.ceph.com'; - -/** - * This hooks is for ODF Client Mode use case only. - * ODF client mode doesn't deploy ODF StorageCluster hence falling back to StorageClases. - */ -const useClientFallback = (storageClusterName) => { - const [storageClasses, storageClassesLoaded, storageClassLoadError] = - useK8sWatchResource(scResource); - if (storageClusterName) { - return storageClusterName; - } - - const provisioners = storageClasses.map((sc) => sc.provisioner); - const fileSystemProvisioner = provisioners.find((item) => - item.includes(fsProvisionerPostFix) - ); - const clusterName = fileSystemProvisioner?.split(fsProvisionerPostFix)?.[0]; - return storageClassesLoaded && !storageClassLoadError - ? clusterName - : 'ocs-storagecluster'; -}; - -export default useClientFallback; diff --git a/packages/ocs/dashboards/persistent-external/utilization-card.tsx b/packages/ocs/dashboards/persistent-external/utilization-card.tsx index 915e630b9..1be19413a 100644 --- a/packages/ocs/dashboards/persistent-external/utilization-card.tsx +++ b/packages/ocs/dashboards/persistent-external/utilization-card.tsx @@ -15,7 +15,7 @@ import { INDEPENDENT_UTILIZATION_QUERIES, } from '../../queries'; import { ODFSystemParams } from '../../types'; -import useClientFallback from './fallback-hook'; +import getClientFallback from './client-fallback'; export const UtilizationContent: React.FC = () => { const { t } = useCustomTranslation(); @@ -25,7 +25,7 @@ export const UtilizationContent: React.FC = () => { // name of created StorageClasses are prefix by StorageCluster name const storageClassName = systemFlags?.[clusterNs]?.ocsClusterName; - const storageClassNamePrefix = useClientFallback(storageClassName); + const storageClassNamePrefix = getClientFallback(storageClassName); return (