-
Notifications
You must be signed in to change notification settings - Fork 403
Adding tag descriptions to tooltips #2612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
63d0763
c044d58
7f1ffda
23e6473
6950f59
236d1d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,10 +3,10 @@ | |
|
|
||
| import * as Redux from 'redux' | ||
| import { Box, Table, TableBody, TableCell, TableHead, TableRow } from '@mui/material' | ||
| import { Field, Run } from '../../types/api' | ||
| import { Field, Run, Tag } from '../../types/api' | ||
| import { IState } from '../../store/reducers' | ||
| import { connect } from 'react-redux' | ||
| import { fetchJobFacets, resetFacets } from '../../store/actionCreators' | ||
| import { connect, useSelector } from 'react-redux' | ||
| import { fetchJobFacets, resetFacets, fetchTags } from '../../store/actionCreators' | ||
| import { stopWatchDuration } from '../../helpers/time' | ||
| import MqCode from '../core/code/MqCode' | ||
| import MqEmpty from '../core/empty/MqEmpty' | ||
|
|
@@ -17,6 +17,7 @@ import RunStatus from '../jobs/RunStatus' | |
| import { Chip } from '@mui/material' | ||
| import { createTheme } from '@mui/material/styles' | ||
| import { useTheme } from '@emotion/react' | ||
| import MQTooltip from '../core/tooltip/MQTooltip' | ||
|
|
||
| export interface DispatchProps { | ||
| fetchJobFacets: typeof fetchJobFacets | ||
|
|
@@ -42,28 +43,35 @@ type DatasetInfoProps = { | |
| } & JobFacetsProps & | ||
| DispatchProps | ||
|
|
||
| const formatColumnTags = (tags: string[]) => { | ||
| const theme = createTheme(useTheme()) | ||
| return ( | ||
| <> | ||
| {tags.map((tag, index) => ( | ||
| <Chip | ||
| key={tag} | ||
| label={tag} | ||
| size="small" | ||
| style={{display: 'inline', marginRight: index < tags.length - 1 ? theme.spacing(1) : 0}} | ||
| /> | ||
| ))} | ||
| </> | ||
| ) | ||
| } | ||
| const formatColumnTags = (tags: string[], tag_desc: Tag[]) => { | ||
| const theme = createTheme(useTheme()) | ||
| return ( | ||
| <> | ||
| {tags.map((tag, index) => { | ||
| const tagDescription = tag_desc.find((tagItem) => tagItem.name === tag) | ||
| const tooltipTitle = tagDescription ? (tagDescription.description || 'No Tag Description') : 'No Tag Description' | ||
| return ( | ||
| <MQTooltip title={tooltipTitle} key={tag}> | ||
| <Chip | ||
| label={tag} | ||
| size="small" | ||
| style={{ display: 'inline', marginRight: index < tags.length - 1 ? theme.spacing(1) : 0 }} | ||
| /> | ||
| </MQTooltip> | ||
| ); | ||
| })} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
| const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => { | ||
| const { datasetFields, facets, run, jobFacets, fetchJobFacets, resetFacets } = props | ||
| const i18next = require('i18next') | ||
|
|
||
| useEffect(() => { | ||
| run && fetchJobFacets(run.id) | ||
| fetchTags() | ||
| }, []) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This depends on the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you would need to add
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah sorry misunderstood what you were saying - rookie error! |
||
|
|
||
| // unmounting | ||
|
|
@@ -73,6 +81,8 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => { | |
| }, | ||
| [] | ||
| ) | ||
|
|
||
| const tagData = useSelector((state: IState) => state.tags.tags) | ||
|
|
||
| return ( | ||
| <Box> | ||
|
|
@@ -115,7 +125,7 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => { | |
| <TableCell align='left'>{field.name}</TableCell> | ||
| <TableCell align='left'>{field.type}</TableCell> | ||
| <TableCell align='left'>{field.description || 'no description'}</TableCell> | ||
| <TableCell align='left'>{formatColumnTags(field.tags)}</TableCell> | ||
| <TableCell align='left'>{formatColumnTags(field.tags, tagData)}</TableCell> | ||
| </TableRow> | ||
| ) | ||
| })} | ||
|
|
@@ -153,14 +163,15 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => { | |
| } | ||
|
|
||
| const mapStateToProps = (state: IState) => ({ | ||
| jobFacets: state.facets.result, | ||
| jobFacets: state.facets.result | ||
| }) | ||
|
|
||
| const mapDispatchToProps = (dispatch: Redux.Dispatch) => | ||
| Redux.bindActionCreators( | ||
| { | ||
| fetchJobFacets: fetchJobFacets, | ||
| resetFacets: resetFacets, | ||
| fetchTags: fetchTags, | ||
| }, | ||
| dispatch | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,3 +57,7 @@ export const FETCH_RUN_FACETS = 'FETCH_RUN_FACETS' | |
| export const FETCH_JOB_FACETS = 'FETCH_JOB_FACETS' | ||
| export const FETCH_FACETS_SUCCESS = 'FETCH_FACETS_SUCCESS' | ||
| export const RESET_FACETS = 'RESET_FACETS' | ||
|
|
||
| // tags | ||
| export const FETCH_TAGS = 'FETCH_TAGS' | ||
| export const FETCH_TAGS_SUCCESS = 'FETCH_TAGS_SUCCESS' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you've got a few newline issues. The project has a formatter that should help you in your IDE. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Copyright 2018-2023 contributors to the Marquez project | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import { Tag } from '../../types/api' | ||
| import { | ||
| FETCH_TAGS, | ||
| FETCH_TAGS_SUCCESS | ||
| } from '../actionCreators/actionTypes' | ||
| import { fetchTagsSuccess } from '../actionCreators' | ||
|
|
||
| export type ITagsState = { isLoading: boolean; tags: Tag[]; init: boolean } | ||
|
|
||
| export const initialState: ITagsState = { | ||
| isLoading: false, | ||
| init: false, | ||
| tags: [], | ||
| } | ||
|
|
||
| type ITagsAction = ReturnType<typeof fetchTagsSuccess> | ||
|
|
||
| export default ( | ||
| state: ITagsState = initialState, | ||
| action: ITagsAction | ||
| ): ITagsState => { | ||
| const { type, payload } = action | ||
| switch (type) { | ||
| case FETCH_TAGS: | ||
| return { ...state, isLoading: true } | ||
| case FETCH_TAGS_SUCCESS: | ||
| return { ...state, isLoading: false, init: true, tags: payload.tags } | ||
| default: | ||
| return state | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright 2018-2023 contributors to the Marquez project | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { API_URL } from '../../globals' | ||
| import { genericFetchWrapper } from './index' | ||
|
|
||
| export const getTags = async () => { | ||
| const url = `${API_URL}/tags` | ||
| return genericFetchWrapper(url, { method: 'GET' }, 'fetchTags') | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to clean up this ternary to not have the same false clause twice here. You can use the
?syntax at the end of object properties.