Skip to content

Commit 3280c41

Browse files
author
phix
committed
Merge branch 'main' into feature/paging-jobs-datasets
# Conflicts: # web/src/store/sagas/index.ts
2 parents 1139351 + d1d47e2 commit 3280c41

9 files changed

Lines changed: 115 additions & 21 deletions

File tree

web/src/components/datasets/DatasetInfo.tsx

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33

44
import * as Redux from 'redux'
55
import { 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'
78
import { 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'
1012
import { stopWatchDuration } from '../../helpers/time'
13+
import { useTheme } from '@emotion/react'
14+
import MQTooltip from '../core/tooltip/MQTooltip'
1115
import MqCode from '../core/code/MqCode'
1216
import MqEmpty from '../core/empty/MqEmpty'
1317
import MqJsonView from '../core/json-view/MqJsonView'
1418
import MqText from '../core/text/MqText'
1519
import React, { FunctionComponent, useEffect } from 'react'
1620
import RunStatus from '../jobs/RunStatus'
17-
import { Chip } from '@mui/material'
18-
import { createTheme } from '@mui/material/styles'
19-
import { useTheme } from '@emotion/react'
2021

2122
export 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
)

web/src/store/actionCreators/actionTypes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ export const FETCH_RUN_FACETS = 'FETCH_RUN_FACETS'
5757
export const FETCH_JOB_FACETS = 'FETCH_JOB_FACETS'
5858
export const FETCH_FACETS_SUCCESS = 'FETCH_FACETS_SUCCESS'
5959
export const RESET_FACETS = 'RESET_FACETS'
60+
61+
// tags
62+
export const FETCH_TAGS = 'FETCH_TAGS'
63+
export const FETCH_TAGS_SUCCESS = 'FETCH_TAGS_SUCCESS'

web/src/store/actionCreators/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
Namespace,
1414
Run,
1515
Search,
16+
Tag,
1617
} from '../../types/api'
1718
import { JobOrDataset } from '../../components/lineage/types'
1819

@@ -199,6 +200,17 @@ export const fetchNamespacesSuccess = (namespaces: Namespace[]) => ({
199200
},
200201
})
201202

203+
export const fetchTags = () => ({
204+
type: actionTypes.FETCH_TAGS,
205+
})
206+
207+
export const fetchTagsSuccess = (tags: Tag[]) => ({
208+
type: actionTypes.FETCH_TAGS_SUCCESS,
209+
payload: {
210+
tags,
211+
},
212+
})
213+
202214
export const applicationError = (message: string) => ({
203215
type: actionTypes.APPLICATION_ERROR,
204216
payload: {

web/src/store/reducers/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import lineage, { ILineageState } from './lineage'
1515
import namespaces, { INamespacesState } from './namespaces'
1616
import runs, { IRunsState } from './runs'
1717
import search, { ISearchState } from './search'
18+
import tags, { ITagsState } from './tags'
1819

1920
export interface IState {
21+
tags: ITagsState
2022
datasets: IDatasetsState
2123
dataset: IDatasetState
2224
datasetVersions: IDatasetVersionsState
@@ -44,5 +46,6 @@ export default (history: History): Reducer =>
4446
display,
4547
lineage,
4648
search,
47-
facets
49+
facets,
50+
tags,
4851
})

web/src/store/reducers/tags.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2018-2023 contributors to the Marquez project
2+
// SPDX-License-Identifier: Apache-2.0
3+
import { FETCH_TAGS, FETCH_TAGS_SUCCESS } from '../actionCreators/actionTypes'
4+
import { Tag } from '../../types/api'
5+
import { fetchTagsSuccess } from '../actionCreators'
6+
7+
export type ITagsState = { isLoading: boolean; tags: Tag[]; init: boolean }
8+
9+
export const initialState: ITagsState = {
10+
isLoading: false,
11+
init: false,
12+
tags: [],
13+
}
14+
15+
type ITagsAction = ReturnType<typeof fetchTagsSuccess>
16+
17+
export default (state: ITagsState = initialState, action: ITagsAction): ITagsState => {
18+
const { type, payload } = action
19+
switch (type) {
20+
case FETCH_TAGS:
21+
return { ...state, isLoading: true }
22+
case FETCH_TAGS_SUCCESS:
23+
return { ...state, isLoading: false, init: true, tags: payload.tags }
24+
default:
25+
return state
26+
}
27+
}

web/src/store/requests/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ export * from './events'
4545
export * from './facets'
4646
export * from './namespaces'
4747
export * from './jobs'
48+
export * from './tags'

web/src/store/requests/tags.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2018-2023 contributors to the Marquez project
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { API_URL } from '../../globals'
5+
import { genericFetchWrapper } from './index'
6+
7+
export const getTags = async () => {
8+
const url = `${API_URL}/tags`
9+
return genericFetchWrapper(url, { method: 'GET' }, 'fetchTags')
10+
}

web/src/store/sagas/index.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
Jobs,
2626
LineageGraph,
2727
Namespaces,
28+
Tags,
2829
} from '../../types/api'
2930
import { all, put, take } from 'redux-saga/effects'
3031

@@ -46,6 +47,7 @@ import {
4647
fetchNamespacesSuccess,
4748
fetchRunsSuccess,
4849
fetchSearchSuccess,
50+
fetchTagsSuccess,
4951
} from '../actionCreators'
5052
import {
5153
deleteDataset,
@@ -59,10 +61,21 @@ import {
5961
getNamespaces,
6062
getRunFacets,
6163
getRuns,
64+
getTags,
6265
} from '../requests'
6366
import { getLineage } from '../requests/lineage'
6467
import { getSearch } from '../requests/search'
6568

69+
export function* fetchTags() {
70+
try {
71+
const response: Tags = yield call(getTags)
72+
const { tags } = response
73+
yield put(fetchTagsSuccess(tags))
74+
} catch (e) {
75+
yield put(applicationError('Something went wrong while fetching initial data.'))
76+
}
77+
}
78+
6679
export function* fetchNamespaces() {
6780
try {
6881
const response: Namespaces = yield call(getNamespaces)
@@ -235,7 +248,7 @@ export function* fetchRunFacetsSaga() {
235248
}
236249

237250
export default function* rootSaga(): Generator {
238-
const sagasThatAreKickedOffImmediately = [fetchNamespaces()]
251+
const sagasThatAreKickedOffImmediately = [fetchNamespaces(), fetchTags()]
239252
const sagasThatWatchForAction = [
240253
fetchJobsSaga(),
241254
fetchRunsSaga(),

web/src/types/api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ export interface Tag {
77
name: string
88
description: string
99
}
10+
11+
export interface Tags {
12+
tags: Tag[]
13+
}
14+
1015
export interface Runs {
1116
runs: Run[]
1217
}

0 commit comments

Comments
 (0)