33
44import * as Redux from 'redux'
55import { Box , Table , TableBody , TableCell , TableHead , TableRow } from '@mui/material'
6- import { Field , Run } from '../../types/api'
6+ import { Chip } from '@mui/material'
7+ import { Field , Run , Tag } from '../../types/api'
78import { IState } from '../../store/reducers'
8- import { connect } from 'react-redux'
9- import { fetchJobFacets , resetFacets } from '../../store/actionCreators'
9+ import { connect , useSelector } from 'react-redux'
10+ import { createTheme } from '@mui/material/styles'
11+ import { fetchJobFacets , fetchTags , resetFacets } from '../../store/actionCreators'
1012import { stopWatchDuration } from '../../helpers/time'
13+ import { useTheme } from '@emotion/react'
14+ import MQTooltip from '../core/tooltip/MQTooltip'
1115import MqCode from '../core/code/MqCode'
1216import MqEmpty from '../core/empty/MqEmpty'
1317import MqJsonView from '../core/json-view/MqJsonView'
1418import MqText from '../core/text/MqText'
1519import React , { FunctionComponent , useEffect } from 'react'
1620import RunStatus from '../jobs/RunStatus'
17- import { Chip } from '@mui/material'
18- import { createTheme } from '@mui/material/styles'
19- import { useTheme } from '@emotion/react'
2021
2122export interface DispatchProps {
2223 fetchJobFacets : typeof fetchJobFacets
@@ -42,18 +43,26 @@ type DatasetInfoProps = {
4243} & JobFacetsProps &
4344 DispatchProps
4445
45- const formatColumnTags = ( tags : string [ ] ) => {
46+ const formatColumnTags = ( tags : string [ ] , tag_desc : Tag [ ] ) => {
4647 const theme = createTheme ( useTheme ( ) )
4748 return (
4849 < >
49- { tags . map ( ( tag , index ) => (
50- < Chip
51- key = { tag }
52- label = { tag }
53- size = "small"
54- style = { { display : 'inline' , marginRight : index < tags . length - 1 ? theme . spacing ( 1 ) : 0 } }
55- />
56- ) ) }
50+ { tags . map ( ( tag , index ) => {
51+ const tagDescription = tag_desc . find ( ( tagItem ) => tagItem . name === tag )
52+ const tooltipTitle = tagDescription ?. description || 'No Tag Description'
53+ return (
54+ < MQTooltip title = { tooltipTitle } key = { tag } >
55+ < Chip
56+ label = { tag }
57+ size = 'small'
58+ style = { {
59+ display : 'inline' ,
60+ marginRight : index < tags . length - 1 ? theme . spacing ( 1 ) : 0 ,
61+ } }
62+ />
63+ </ MQTooltip >
64+ )
65+ } ) }
5766 </ >
5867 )
5968}
@@ -64,7 +73,8 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => {
6473
6574 useEffect ( ( ) => {
6675 run && fetchJobFacets ( run . id )
67- } , [ ] )
76+ run && fetchTags ( )
77+ } , [ run ] )
6878
6979 // unmounting
7080 useEffect (
@@ -74,6 +84,8 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => {
7484 [ ]
7585 )
7686
87+ const tagData = useSelector ( ( state : IState ) => state . tags . tags )
88+
7789 return (
7890 < Box >
7991 { datasetFields . length === 0 && (
@@ -103,7 +115,7 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => {
103115 </ TableCell >
104116 < TableCell align = 'left' >
105117 < MqText subheading inline >
106- { i18next . t ( 'dataset_info_columns.tags' ) }
118+ { i18next . t ( 'dataset_info_columns.tags' ) }
107119 </ MqText >
108120 </ TableCell >
109121 </ TableRow >
@@ -115,7 +127,7 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => {
115127 < TableCell align = 'left' > { field . name } </ TableCell >
116128 < TableCell align = 'left' > { field . type } </ TableCell >
117129 < TableCell align = 'left' > { field . description || 'no description' } </ TableCell >
118- < TableCell align = 'left' > { formatColumnTags ( field . tags ) } </ TableCell >
130+ < TableCell align = 'left' > { formatColumnTags ( field . tags , tagData ) } </ TableCell >
119131 </ TableRow >
120132 )
121133 } ) }
@@ -127,7 +139,13 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => {
127139 < Box mb = { 1 } >
128140 < MqText subheading > { i18next . t ( 'dataset_info.facets_subhead' ) } </ MqText >
129141 </ Box >
130- < MqJsonView data = { facets } searchable = { true } aria-label = { i18next . t ( 'dataset_info.facets_subhead_aria' ) } aria-required = 'True' placeholder = 'Search' />
142+ < MqJsonView
143+ data = { facets }
144+ searchable = { true }
145+ aria-label = { i18next . t ( 'dataset_info.facets_subhead_aria' ) }
146+ aria-required = 'True'
147+ placeholder = 'Search'
148+ />
131149 </ Box >
132150 ) }
133151 { run && (
@@ -161,6 +179,7 @@ const mapDispatchToProps = (dispatch: Redux.Dispatch) =>
161179 {
162180 fetchJobFacets : fetchJobFacets ,
163181 resetFacets : resetFacets ,
182+ fetchTags : fetchTags ,
164183 } ,
165184 dispatch
166185 )
0 commit comments