@@ -17,9 +17,15 @@ import { WithStyles, createStyles, withStyles } from '@material-ui/core/styles'
17
17
import { Zoom } from '@visx/zoom'
18
18
import { bindActionCreators } from 'redux'
19
19
import { connect } from 'react-redux'
20
- import { fetchLineage , resetLineage , setSelectedNode } from '../../store/actionCreators'
20
+ import {
21
+ fetchLineage ,
22
+ resetLineage ,
23
+ setLineageGraphDepth ,
24
+ setSelectedNode
25
+ } from '../../store/actionCreators'
21
26
import { generateNodeId } from '../../helpers/nodes'
22
27
import { localPoint } from '@visx/event'
28
+ import DepthConfig from './components/depth-config/DepthConfig'
23
29
import Edge from './components/edge/Edge'
24
30
import MqEmpty from '../core/empty/MqEmpty'
25
31
import MqText from '../core/text/MqText'
@@ -44,6 +50,7 @@ const DOUBLE_CLICK_MAGNIFICATION = 1.1
44
50
interface StateProps {
45
51
lineage : LineageGraph
46
52
selectedNode : string
53
+ depth : number
47
54
}
48
55
49
56
interface LineageState {
@@ -96,24 +103,30 @@ export class Lineage extends React.Component<LineageProps, LineageState> {
96
103
this . props . fetchLineage (
97
104
this . props . match . params . nodeType . toUpperCase ( ) as JobOrDataset ,
98
105
this . props . match . params . namespace ,
99
- this . props . match . params . nodeName
106
+ this . props . match . params . nodeName ,
107
+ this . props . depth
100
108
)
101
109
}
102
110
}
103
111
104
112
componentDidUpdate ( prevProps : Readonly < LineageProps > ) {
105
113
if (
106
- JSON . stringify ( this . props . lineage ) !== JSON . stringify ( prevProps . lineage ) &&
114
+ ( JSON . stringify ( this . props . lineage ) !== JSON . stringify ( prevProps . lineage ) ||
115
+ this . props . depth !== prevProps . depth ) &&
107
116
this . props . selectedNode
108
117
) {
109
118
this . initGraph ( )
110
119
this . buildGraphAll ( this . props . lineage . graph )
111
120
}
112
- if ( this . props . selectedNode !== prevProps . selectedNode ) {
121
+ if (
122
+ this . props . selectedNode !== prevProps . selectedNode ||
123
+ this . props . depth !== prevProps . depth
124
+ ) {
113
125
this . props . fetchLineage (
114
126
this . props . match . params . nodeType . toUpperCase ( ) as JobOrDataset ,
115
127
this . props . match . params . namespace ,
116
- this . props . match . params . nodeName
128
+ this . props . match . params . nodeName ,
129
+ this . props . depth
117
130
)
118
131
this . getEdges ( )
119
132
}
@@ -224,6 +237,7 @@ export class Lineage extends React.Component<LineageProps, LineageState> {
224
237
</ MqEmpty >
225
238
</ Box >
226
239
) }
240
+ < DepthConfig depth = { this . props . depth } />
227
241
{ this . state . graph && (
228
242
< ParentSize >
229
243
{ parent => (
@@ -303,15 +317,17 @@ export class Lineage extends React.Component<LineageProps, LineageState> {
303
317
304
318
const mapStateToProps = ( state : IState ) => ( {
305
319
lineage : state . lineage . lineage ,
306
- selectedNode : state . lineage . selectedNode
320
+ selectedNode : state . lineage . selectedNode ,
321
+ depth : state . lineage . depth
307
322
} )
308
323
309
324
const mapDispatchToProps = ( dispatch : Redux . Dispatch ) =>
310
325
bindActionCreators (
311
326
{
312
327
setSelectedNode : setSelectedNode ,
313
328
fetchLineage : fetchLineage ,
314
- resetLineage : resetLineage
329
+ resetLineage : resetLineage ,
330
+ setDepth : setLineageGraphDepth
315
331
} ,
316
332
dispatch
317
333
)
0 commit comments