diff --git a/frontend/packages/ceph-storage-plugin/src/components/dashboard-page/storage-dashboard/details-card.tsx b/frontend/packages/ceph-storage-plugin/src/components/dashboard-page/storage-dashboard/details-card.tsx index 816873d90a5..567e1f5eb22 100644 --- a/frontend/packages/ceph-storage-plugin/src/components/dashboard-page/storage-dashboard/details-card.tsx +++ b/frontend/packages/ceph-storage-plugin/src/components/dashboard-page/storage-dashboard/details-card.tsx @@ -11,12 +11,13 @@ import { withDashboardResources, } from '@console/internal/components/dashboards-page/with-dashboard-resources'; import { DetailsBody } from '@console/internal/components/dashboard/details-card/details-body'; -import { FirehoseResource } from '@console/internal/components/utils/index'; +import { FirehoseResource, FirehoseResult } from '@console/internal/components/utils/index'; import { InfrastructureModel, SubscriptionModel } from '@console/internal/models/index'; import { K8sResourceKind } from '@console/internal/module/k8s/index'; import { getName } from '@console/shared/src/selectors/common'; import { referenceForModel } from '@console/internal/module/k8s/k8s'; import { CephClusterModel } from '../../../models'; +import { getOCSVersion } from '../../../selectors'; const infrastructureResource: FirehoseResource = { kind: referenceForModel(InfrastructureModel), @@ -37,8 +38,7 @@ const SubscriptionResource: FirehoseResource = { kind: referenceForModel(SubscriptionModel), namespaced: false, prop: 'subscription', - name: 'ocs-subscription', - isList: false, + isList: true, }; const DetailsCard: React.FC = ({ @@ -67,9 +67,9 @@ const DetailsCard: React.FC = ({ const cephClusterData = _.get(cephCluster, 'data') as K8sResourceKind[]; const cephClusterName = getName(_.get(cephClusterData, 0)); - const subscription = _.get(resources, 'subscription'); + const subscription = _.get(resources, 'subscription') as FirehoseResult; const subscriptionLoaded = _.get(subscription, 'loaded'); - const ocsVersion = _.get(subscription, 'data.status.currentCSV'); + const ocsVersion = getOCSVersion(subscription); return ( diff --git a/frontend/packages/ceph-storage-plugin/src/constants/index.ts b/frontend/packages/ceph-storage-plugin/src/constants/index.ts index 2dda56f4022..6c95bec256f 100644 --- a/frontend/packages/ceph-storage-plugin/src/constants/index.ts +++ b/frontend/packages/ceph-storage-plugin/src/constants/index.ts @@ -11,3 +11,4 @@ export const STORAGE_CLASSES = 'Storage Classes'; export const PODS = 'Pods'; export const BY_USED = 'By Used Capacity'; export const BY_REQUESTED = 'By Requested Capacity'; +export const OCS_OPERATOR = 'ocs-operator'; diff --git a/frontend/packages/ceph-storage-plugin/src/selectors/index.ts b/frontend/packages/ceph-storage-plugin/src/selectors/index.ts index e24a1014bb4..da7a5864362 100644 --- a/frontend/packages/ceph-storage-plugin/src/selectors/index.ts +++ b/frontend/packages/ceph-storage-plugin/src/selectors/index.ts @@ -1,6 +1,8 @@ import * as _ from 'lodash'; import { Alert } from '@console/internal/components/monitoring'; import { K8sResourceKind } from '@console/internal/module/k8s'; +import { FirehoseResult } from '@console/internal/components/utils'; +import { OCS_OPERATOR } from '../constants'; const cephStorageProvisioners = ['ceph.rook.io/block', 'cephfs.csi.ceph.com', 'rbd.csi.ceph.com']; const cephStorageLabel = 'cluster.ocs.openshift.io/openshift-storage'; @@ -32,3 +34,12 @@ export const getCephSC = (scData: K8sResourceKind[]): K8sResourceKind[] => _.get(sc, 'provisioner', '').includes(provisioner), ); }); + +export const getOCSVersion = (items: FirehoseResult): string => { + const itemsData: K8sResourceKind[] = _.get(items, 'data'); + const operator: K8sResourceKind = _.find( + itemsData, + (item) => _.get(item, 'spec.name') === OCS_OPERATOR, + ); + return _.get(operator, 'status.currentCSV'); +}; diff --git a/frontend/packages/noobaa-storage-plugin/src/components/details-card/details-card.tsx b/frontend/packages/noobaa-storage-plugin/src/components/details-card/details-card.tsx index 65bed644be3..9c3784da187 100644 --- a/frontend/packages/noobaa-storage-plugin/src/components/details-card/details-card.tsx +++ b/frontend/packages/noobaa-storage-plugin/src/components/details-card/details-card.tsx @@ -12,9 +12,10 @@ import { DashboardItemProps, withDashboardResources, } from '@console/internal/components/dashboards-page/with-dashboard-resources'; -import { FirehoseResource, ExternalLink } from '@console/internal/components/utils'; +import { FirehoseResource, ExternalLink, FirehoseResult } from '@console/internal/components/utils'; import { InfrastructureModel, SubscriptionModel } from '@console/internal/models/index'; import { referenceForModel, K8sResourceKind } from '@console/internal/module/k8s'; +import { getOCSVersion } from '@console/ceph-storage-plugin/src/selectors'; import { getMetric } from '../../utils'; const NOOBAA_SYSTEM_NAME_QUERY = 'NooBaa_system_info'; @@ -31,8 +32,7 @@ const SubscriptionResource: FirehoseResource = { kind: referenceForModel(SubscriptionModel), namespaced: false, prop: 'subscription', - name: 'ocs-subscription', - isList: false, + isList: true, }; export const ObjectServiceDetailsCard: React.FC = ({ @@ -66,9 +66,9 @@ export const ObjectServiceDetailsCard: React.FC = ({ const infrastructureData = _.get(infrastructure, 'data') as K8sResourceKind; const infrastructurePlatform = getInfrastructurePlatform(infrastructureData); - const subscription = _.get(resources, 'subscription'); + const subscription = _.get(resources, 'subscription') as FirehoseResult; const subscriptionLoaded = _.get(subscription, 'loaded'); - const ocsVersion = _.get(subscription, 'data.status.currentCSV'); + const ocsVersion = getOCSVersion(subscription); return (