@@ -30,6 +30,10 @@ import {
3030 type SchemaAnalysisError ,
3131} from '../../schema-analysis-types' ;
3232import { MAX_COLLECTION_NESTING_DEPTH } from '../mock-data-generator-modal/utils' ;
33+ import {
34+ buildChartsUrl ,
35+ buildMonitoringUrl ,
36+ } from '@mongodb-js/atlas-service/provider' ;
3337
3438const collectionHeaderActionsStyles = css ( {
3539 display : 'flex' ,
@@ -46,20 +50,6 @@ const tooltipMessageStyles = css({
4650 } ,
4751} ) ;
4852
49- function buildChartsUrl (
50- groupId : string ,
51- clusterName : string ,
52- namespace : string
53- ) {
54- const { database, collection } = toNS ( namespace ) ;
55- const url = new URL ( `/charts/${ groupId } ` , window . location . origin ) ;
56- url . searchParams . set ( 'sourceType' , 'cluster' ) ;
57- url . searchParams . set ( 'name' , clusterName ) ;
58- url . searchParams . set ( 'database' , database ) ;
59- url . searchParams . set ( 'collection' , collection ) ;
60- return url . toString ( ) ;
61- }
62-
6353type CollectionHeaderActionsProps = {
6454 namespace : string ;
6555 isReadonly : boolean ;
@@ -234,15 +224,23 @@ const CollectionHeaderActions: React.FunctionComponent<
234224 </ >
235225 </ Tooltip >
236226 ) }
227+ { atlasMetadata && (
228+ < Button
229+ data-testid = "collection-header-view-monitoring"
230+ size = { ButtonSize . Small }
231+ href = { buildMonitoringUrl ( atlasMetadata ) }
232+ target = "_blank"
233+ rel = "noopener noreferrer"
234+ leftGlyph = { < Icon glyph = "TimeSeries" /> }
235+ >
236+ View monitoring
237+ </ Button >
238+ ) }
237239 { atlasMetadata && (
238240 < Button
239241 data-testid = "collection-header-visualize-your-data"
240242 size = { ButtonSize . Small }
241- href = { buildChartsUrl (
242- atlasMetadata . projectId ,
243- atlasMetadata . clusterName ,
244- namespace
245- ) }
243+ href = { buildChartsUrl ( atlasMetadata , namespace ) }
246244 target = "_self"
247245 rel = "noopener noreferrer"
248246 leftGlyph = { < Icon glyph = "Charts" /> }
0 commit comments