@@ -3,19 +3,19 @@ import * as React from 'react';
33import { Button , Popover , PopoverPosition } from '@patternfly/react-core' ;
44import { useTranslation } from 'react-i18next' ;
55import { Link } from 'react-router-dom-v5-compat' ;
6- import { LIMIT_STATE , Humanize } from '@console/dynamic-plugin-sdk' ;
6+ import { Humanize , LIMIT_STATE , useActivePerspective } from '@console/dynamic-plugin-sdk' ;
77import { getPrometheusQueryResponse } from '@console/internal/actions/dashboards' ;
88import {
9- withDashboardResources ,
109 DashboardItemProps ,
10+ withDashboardResources ,
1111} from '@console/internal/components/dashboard/with-dashboard-resources' ;
1212import { DataPoint } from '@console/internal/components/graphs' ;
1313import { getInstantVectorStats } from '@console/internal/components/graphs/utils' ;
1414import { ConsoleSelect } from '@console/internal/components/utils/console-select' ;
1515import { useK8sWatchResource } from '@console/internal/components/utils/k8s-watch-hook' ;
1616import { resourcePathFromModel } from '@console/internal/components/utils/resource-link' ;
17- import { K8sKind , referenceForModel , K8sResourceCommon } from '@console/internal/module/k8s' ;
18- import { getName , getNamespace } from '../../..' ;
17+ import { K8sKind , K8sResourceCommon , referenceForModel } from '@console/internal/module/k8s' ;
18+ import { FLAGS , getName , getNamespace , useFlag } from '../../..' ;
1919import { RedExclamationCircleIcon , YellowExclamationTriangleIcon } from '../../status' ;
2020import Status from '../status-card/StatusPopup' ;
2121
@@ -130,6 +130,9 @@ export const PopoverBody = withDashboardResources<DashboardItemProps & PopoverBo
130130 } ) => {
131131 const { t } = useTranslation ( ) ;
132132 const [ currentConsumer , setCurrentConsumer ] = React . useState ( consumers [ 0 ] ) ;
133+ const [ activePerspective , setActivePerspective ] = useActivePerspective ( ) ;
134+ const canAccessMonitoring =
135+ useFlag ( FLAGS . CAN_GET_NS ) && ! ! window . SERVER_FLAGS . prometheusBaseURL ;
133136 const { query, model, metric, fieldSelector } = currentConsumer ;
134137 const k8sResource = React . useMemo (
135138 ( ) => ( isOpen ? getResourceToWatch ( model , namespace , fieldSelector ) : null ) ,
@@ -194,7 +197,10 @@ export const PopoverBody = withDashboardResources<DashboardItemProps & PopoverBo
194197 [ consumers ] ,
195198 ) ;
196199
197- const monitoringURL = `/monitoring/query-browser?${ monitoringParams . toString ( ) } ` ;
200+ const monitoringURL =
201+ canAccessMonitoring && activePerspective === 'admin'
202+ ? `/monitoring/query-browser?${ monitoringParams . toString ( ) } `
203+ : `/dev-monitoring/ns/${ namespace } /metrics?${ monitoringParams . toString ( ) } ` ;
198204
199205 let body : React . ReactNode ;
200206 if ( error || consumersLoadError ) {
@@ -231,7 +237,16 @@ export const PopoverBody = withDashboardResources<DashboardItemProps & PopoverBo
231237 ) ;
232238 } ) }
233239 </ ul >
234- < Link to = { monitoringURL } > { t ( 'console-shared~View more' ) } </ Link >
240+ < Link
241+ to = { monitoringURL }
242+ onClick = { ( ) => {
243+ if ( monitoringURL . startsWith ( '/dev-monitoring' ) && activePerspective !== 'dev' ) {
244+ setActivePerspective ( 'dev' ) ;
245+ }
246+ } }
247+ >
248+ { t ( 'console-shared~View more' ) }
249+ </ Link >
235250 </ >
236251 ) ;
237252 }
0 commit comments