Skip to content

Commit e0839e1

Browse files
jlukenoffXavier-Cliquennois
authored andcommitted
Lineage UI: Add a graph depth config option (MarquezProject#2525)
* stuff Signed-off-by: John Lukenoff <johnlukenoff@asana.com> * Add headers Signed-off-by: John Lukenoff <johnlukenoff@asana.com> * Fix zindex Signed-off-by: John Lukenoff <johnlukenoff@asana.com> * Add minimum Signed-off-by: John Lukenoff <johnlukenoff@asana.com> * hmm Signed-off-by: John Lukenoff <johnlukenoff@asana.com> * retry Signed-off-by: John Lukenoff <johnlukenoff@asana.com> * Update default depth Signed-off-by: John Lukenoff <johnlukenoff@asana.com> * Add an entry to the Changlog Signed-off-by: John Lukenoff <johnlukenoff@asana.com> * Dont reformat everything Signed-off-by: John Lukenoff <johnlukenoff@asana.com> --------- Signed-off-by: John Lukenoff <johnlukenoff@asana.com> Signed-off-by: Xavier-Cliquennois <Xavier-Cliquennois@users.noreply.github.com>
1 parent 67b1135 commit e0839e1

10 files changed

Lines changed: 139 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22

33
## [Unreleased](https://github.com/MarquezProject/marquez/compare/0.35.0...HEAD)
4+
### Added
5+
* UI: add an option for configuring the depth of the lineage graph [`#2525`](https://github.com/MarquezProject/marquez/pull/2525) [@jlukenoff](https://github.com/jlukenoff)
6+
*Makes the lineage UI a bit easier to navigate especially for larger lineage graphs*
47

58
## [0.35.0](https://github.com/MarquezProject/marquez/compare/0.34.0...0.35.0) - 2023-06-13
69
### Added

web/src/components/bottom-bar/BottomBar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ const BottomBar: React.FC<BottomBarProps> = ({ bottomBarHeight, selectedNodeData
4040
right: 0,
4141
width: `calc(100% - ${DRAWER_WIDTH}px)`,
4242
bottom: 0,
43-
position: 'fixed'
43+
position: 'fixed',
44+
zIndex: theme.zIndex.appBar + 1
4445
}}>
4546
<DragBar />
4647
<Box sx={{

web/src/components/lineage/Lineage.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ import { LineageGraph } from '../../types/api'
1515
import { Zoom } from '@visx/zoom'
1616
import { bindActionCreators } from 'redux'
1717
import { connect } from 'react-redux'
18-
import { fetchLineage, resetLineage, setSelectedNode } from '../../store/actionCreators'
18+
import {
19+
fetchLineage,
20+
resetLineage,
21+
setLineageGraphDepth,
22+
setSelectedNode
23+
} from '../../store/actionCreators'
1924
import { generateNodeId } from '../../helpers/nodes'
2025
import { localPoint } from '@visx/event'
2126
import { useParams } from 'react-router-dom'
27+
import DepthConfig from './components/depth-config/DepthConfig'
2228
import Edge from './components/edge/Edge'
2329
import MqEmpty from '../core/empty/MqEmpty'
2430
import MqText from '../core/text/MqText'
@@ -33,6 +39,7 @@ const DOUBLE_CLICK_MAGNIFICATION = 1.1
3339
interface StateProps {
3440
lineage: LineageGraph
3541
selectedNode: string
42+
depth: number
3643
}
3744

3845
interface LineageState {
@@ -85,7 +92,6 @@ export function buildGraphAll(g: graphlib.Graph<MqNode>, graph: LineageNode[], c
8592
callBack(g)
8693
}
8794

88-
8995
export function getSelectedPaths(g: graphlib.Graph<MqNode>, selectedNode: string) {
9096
const paths = [] as Array<[string, string]>
9197

@@ -165,7 +171,8 @@ const Lineage: React.FC<LineageProps> = (props: LineageProps) => {
165171
props.fetchLineage(
166172
nodeType.toUpperCase() as JobOrDataset,
167173
namespace,
168-
nodeName
174+
nodeName,
175+
props.depth
169176
)
170177
}
171178
mounted.current = true
@@ -188,7 +195,8 @@ const Lineage: React.FC<LineageProps> = (props: LineageProps) => {
188195
props.fetchLineage(
189196
nodeType?.toUpperCase() as JobOrDataset,
190197
namespace || '',
191-
nodeName || ''
198+
nodeName || '',
199+
props.depth
192200
)
193201
getEdges()
194202
}
@@ -228,6 +236,7 @@ const Lineage: React.FC<LineageProps> = (props: LineageProps) => {
228236
</MqEmpty>
229237
</Box>
230238
)}
239+
<DepthConfig depth={props.depth} />
231240
{state?.graph && (
232241
<ParentSize>
233242
{parent => (
@@ -306,15 +315,17 @@ const Lineage: React.FC<LineageProps> = (props: LineageProps) => {
306315

307316
const mapStateToProps = (state: IState) => ({
308317
lineage: state.lineage.lineage,
309-
selectedNode: state.lineage.selectedNode
318+
selectedNode: state.lineage.selectedNode,
319+
depth: state.lineage.depth
310320
})
311321

312322
const mapDispatchToProps = (dispatch: Redux.Dispatch) =>
313323
bindActionCreators(
314324
{
315325
setSelectedNode: setSelectedNode,
316326
fetchLineage: fetchLineage,
317-
resetLineage: resetLineage
327+
resetLineage: resetLineage,
328+
setDepth: setLineageGraphDepth
318329
},
319330
dispatch
320331
)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2018-2023 contributors to the Marquez project
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import * as Redux from 'redux'
5+
import { Box, Typography } from '@material-ui/core'
6+
import { Theme, WithStyles, createStyles, withStyles } from '@material-ui/core/styles'
7+
import { bindActionCreators } from 'redux'
8+
import { connect } from 'react-redux'
9+
import { setLineageGraphDepth } from '../../../../store/actionCreators'
10+
import React from 'react'
11+
import TextField from '@material-ui/core/TextField'
12+
13+
const styles = (theme: Theme) =>
14+
createStyles({
15+
root: {
16+
position: 'absolute',
17+
display: 'flex',
18+
justifyContent: 'space-evenly',
19+
alignItems: 'center',
20+
right: 0,
21+
marginRight: '3rem',
22+
padding: '1rem',
23+
zIndex: theme.zIndex.appBar
24+
},
25+
title: {
26+
textAlign: 'center'
27+
},
28+
textField: {
29+
width: '4rem',
30+
marginLeft: '0.5rem'
31+
}
32+
})
33+
34+
interface DepthConfigProps extends WithStyles<typeof styles> {
35+
depth: number
36+
setDepth: (depth: number) => void
37+
}
38+
39+
const DepthConfig: React.FC<DepthConfigProps> = ({ classes, setDepth, depth }) => {
40+
const i18next = require('i18next')
41+
const GRAPH_TITLE = i18next.t('lineage.graph_depth_title')
42+
return (
43+
<Box className={classes.root}>
44+
<Typography>{GRAPH_TITLE}</Typography>
45+
<TextField
46+
type='number'
47+
value={depth}
48+
onChange={e => setDepth(isNaN(parseInt(e.target.value)) ? 0 : parseInt(e.target.value))}
49+
variant='outlined'
50+
size='small'
51+
aria-label={GRAPH_TITLE}
52+
className={classes.textField}
53+
inputProps={{
54+
min: 0,
55+
max: 100
56+
}}
57+
/>
58+
</Box>
59+
)
60+
}
61+
62+
const mapDispatchToProps = (dispatch: Redux.Dispatch) =>
63+
bindActionCreators(
64+
{
65+
setDepth: setLineageGraphDepth
66+
},
67+
dispatch
68+
)
69+
70+
export default connect(null, mapDispatchToProps)(withStyles(styles)(DepthConfig))

web/src/i18n/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ i18next
4444
},
4545
lineage: {
4646
empty_title: 'No node selected',
47-
empty_body: 'Try selecting a node through search or the jobs or datasets page.'
47+
empty_body: 'Try selecting a node through search or the jobs or datasets page.',
48+
graph_depth_title: 'Graph Depth'
4849
},
4950
sidenav: {
5051
jobs: 'JOBS',

web/src/store/actionCreators/actionTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const RESET_EVENTS = 'RESET_EVENTS'
4545
export const FETCH_LINEAGE = 'FETCH_LINEAGE'
4646
export const FETCH_LINEAGE_SUCCESS = 'FETCH_LINEAGE_SUCCESS'
4747
export const RESET_LINEAGE = 'RESET_LINEAGE'
48+
export const SET_LINEAGE_GRAPH_DEPTH = 'SET_LINEAGE_GRAPH_DEPTH'
4849

4950
// search
5051
export const FETCH_SEARCH = 'FETCH_SEARCH'

web/src/store/actionCreators/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,18 @@ export const setBottomBarHeight = (height: number) => ({
216216
payload: height
217217
})
218218

219-
export const fetchLineage = (nodeType: JobOrDataset, namespace: string, name: string) => ({
219+
export const fetchLineage = (
220+
nodeType: JobOrDataset,
221+
namespace: string,
222+
name: string,
223+
depth: number
224+
) => ({
220225
type: actionTypes.FETCH_LINEAGE,
221226
payload: {
222227
nodeType,
223228
namespace,
224-
name
229+
name,
230+
depth
225231
}
226232
})
227233

@@ -234,6 +240,11 @@ export const resetLineage = () => ({
234240
type: actionTypes.RESET_LINEAGE
235241
})
236242

243+
export const setLineageGraphDepth = (depth: number) => ({
244+
type: actionTypes.SET_LINEAGE_GRAPH_DEPTH,
245+
payload: depth
246+
})
247+
237248
export const selectNamespace = (namespace: string) => ({
238249
type: actionTypes.SELECT_NAMESPACE,
239250
payload: namespace

web/src/store/reducers/lineage.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,31 @@ import {
55
FETCH_LINEAGE_SUCCESS,
66
RESET_LINEAGE,
77
SET_BOTTOM_BAR_HEIGHT,
8+
SET_LINEAGE_GRAPH_DEPTH,
89
SET_SELECTED_NODE
910
} from '../actionCreators/actionTypes'
1011
import { HEADER_HEIGHT } from '../../helpers/theme'
1112
import { LineageGraph } from '../../types/api'
1213
import { Nullable } from '../../types/util/Nullable'
13-
import { setBottomBarHeight, setSelectedNode } from '../actionCreators'
14+
import { setBottomBarHeight, setLineageGraphDepth, setSelectedNode } from '../actionCreators'
1415

1516
export interface ILineageState {
1617
lineage: LineageGraph
1718
selectedNode: Nullable<string>
1819
bottomBarHeight: number
20+
depth: number
1921
}
2022

2123
const initialState: ILineageState = {
2224
lineage: { graph: [] },
2325
selectedNode: null,
24-
bottomBarHeight: (window.innerHeight - HEADER_HEIGHT) / 3
26+
bottomBarHeight: (window.innerHeight - HEADER_HEIGHT) / 3,
27+
depth: 5
2528
}
2629

27-
type ILineageActions = ReturnType<typeof setSelectedNode> & ReturnType<typeof setBottomBarHeight>
30+
type ILineageActions = ReturnType<typeof setSelectedNode> &
31+
ReturnType<typeof setBottomBarHeight> &
32+
ReturnType<typeof setLineageGraphDepth>
2833

2934
const DRAG_BAR_HEIGHT = 8
3035

@@ -42,6 +47,11 @@ export default (state = initialState, action: ILineageActions) => {
4247
Math.max(2, action.payload)
4348
)
4449
}
50+
case SET_LINEAGE_GRAPH_DEPTH:
51+
return {
52+
...state,
53+
depth: action.payload
54+
}
4555
case RESET_LINEAGE: {
4656
return { ...state, lineage: { graph: [] } }
4757
}

web/src/store/requests/lineage.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ import { JobOrDataset } from '../../components/lineage/types'
66
import { generateNodeId } from '../../helpers/nodes'
77
import { genericFetchWrapper } from './index'
88

9-
export const getLineage = async (nodeType: JobOrDataset, namespace: string, name: string) => {
10-
const url = `${API_URL}/lineage?nodeId=${generateNodeId(nodeType, namespace, name)}`
9+
export const getLineage = async (
10+
nodeType: JobOrDataset,
11+
namespace: string,
12+
name: string,
13+
depth: number
14+
) => {
15+
const params = new URLSearchParams({
16+
nodeId: generateNodeId(nodeType, namespace, name),
17+
depth: depth.toString()
18+
})
19+
const url = `${API_URL}/lineage/?${params.toString()}`
1120
return genericFetchWrapper(url, { method: 'GET' }, 'fetchLineage')
1221
}

web/src/store/sagas/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ export function* fetchLineage() {
6868
while (true) {
6969
try {
7070
const { payload } = yield take(FETCH_LINEAGE)
71-
const result: LineageGraph = yield call(getLineage, payload.nodeType, payload.namespace, payload.name)
71+
const result: LineageGraph = yield call(
72+
getLineage,
73+
payload.nodeType,
74+
payload.namespace,
75+
payload.name,
76+
payload.depth
77+
)
7278
yield put(fetchLineageSuccess(result))
7379
} catch (e) {
7480
yield put(applicationError('Something went wrong while fetching lineage'))

0 commit comments

Comments
 (0)