@@ -6,17 +6,20 @@ import type {InfoViewerItem} from '../../../components/InfoViewer/InfoViewer';
66import { LinkWithIcon } from '../../../components/LinkWithIcon/LinkWithIcon' ;
77import { ProgressViewer } from '../../../components/ProgressViewer/ProgressViewer' ;
88import { Tags } from '../../../components/Tags' ;
9+ import { useClusterBaseInfo } from '../../../store/reducers/cluster/cluster' ;
910import type { ClusterLink } from '../../../types/additionalProps' ;
1011import { isClusterInfoV2 } from '../../../types/api/cluster' ;
1112import type { TClusterInfo } from '../../../types/api/cluster' ;
1213import type { EFlag } from '../../../types/api/enums' ;
1314import type { TTabletStateInfo } from '../../../types/api/tablet' ;
1415import { EType } from '../../../types/api/tablet' ;
1516import { formatNumber } from '../../../utils/dataFormatters/dataFormatters' ;
17+ import { parseJson } from '../../../utils/utils' ;
1618import i18n from '../i18n' ;
1719
1820import { NodesState } from './components/NodesState/NodesState' ;
1921import { b } from './shared' ;
22+
2023const COLORS_PRIORITY : Record < EFlag , number > = {
2124 Green : 5 ,
2225 Blue : 4 ,
@@ -103,3 +106,50 @@ export const getInfo = (
103106
104107 return info ;
105108} ;
109+
110+ /**
111+ * parses stringified json in format {url: "href"}
112+ */
113+ function prepareClusterLink ( rawLink ?: string ) {
114+ try {
115+ const linkObject = parseJson ( rawLink ) as unknown ;
116+
117+ if (
118+ linkObject &&
119+ typeof linkObject === 'object' &&
120+ 'url' in linkObject &&
121+ typeof linkObject . url === 'string'
122+ ) {
123+ return linkObject . url ;
124+ }
125+ } catch { }
126+
127+ return undefined ;
128+ }
129+
130+ export function useClusterLinks ( ) {
131+ const { cores, logging} = useClusterBaseInfo ( ) ;
132+
133+ return React . useMemo ( ( ) => {
134+ const result : ClusterLink [ ] = [ ] ;
135+
136+ const coresLink = prepareClusterLink ( cores ) ;
137+ const loggingLink = prepareClusterLink ( logging ) ;
138+
139+ if ( coresLink ) {
140+ result . push ( {
141+ title : i18n ( 'link_cores' ) ,
142+ url : coresLink ,
143+ } ) ;
144+ }
145+
146+ if ( loggingLink ) {
147+ result . push ( {
148+ title : i18n ( 'link_logging' ) ,
149+ url : loggingLink ,
150+ } ) ;
151+ }
152+
153+ return result ;
154+ } , [ cores , logging ] ) ;
155+ }
0 commit comments