11// SPDX-License-Identifier: Apache-2.0
22
3- import React , { ChangeEvent , FunctionComponent , SetStateAction , useEffect } from 'react'
4-
53import * as Redux from 'redux'
64import { Box , Chip , Tab , Tabs } from '@material-ui/core'
75import { DatasetVersion } from '../../types/api'
@@ -15,14 +13,20 @@ import {
1513import { LineageDataset } from '../lineage/types'
1614import { bindActionCreators } from 'redux'
1715import { connect } from 'react-redux'
18- import { fetchDatasetVersions , resetDatasetVersions } from '../../store/actionCreators'
16+ import {
17+ fetchDatasetVersions ,
18+ resetDataset ,
19+ resetDatasetVersions
20+ } from '../../store/actionCreators'
1921import { useHistory } from 'react-router-dom'
2022import CircularProgress from '@material-ui/core/CircularProgress/CircularProgress'
2123import CloseIcon from '@material-ui/icons/Close'
24+ import DatasetColumnLineage from './DatasetColumnLineage'
2225import DatasetInfo from './DatasetInfo'
2326import DatasetVersions from './DatasetVersions'
2427import IconButton from '@material-ui/core/IconButton'
2528import MqText from '../core/text/MqText'
29+ import React , { ChangeEvent , FunctionComponent , SetStateAction , useEffect } from 'react'
2630
2731const styles = ( { spacing } : ITheme ) => {
2832 return createStyles ( {
@@ -40,29 +44,20 @@ const styles = ({ spacing }: ITheme) => {
4044 '&:not(:last-of-type)' : {
4145 marginRight : spacing ( 1 )
4246 }
43- } ,
44- noData : {
45- padding : '125px 0 0 0'
46- } ,
47- infoIcon : {
48- paddingLeft : '3px' ,
49- paddingTop : '3px'
50- } ,
51- updated : {
52- marginTop : '10px'
5347 }
5448 } )
5549}
5650
5751interface StateProps {
58- dataset : LineageDataset
52+ lineageDataset : LineageDataset
5953 versions : DatasetVersion [ ]
6054 versionsLoading : boolean
6155}
6256
6357interface DispatchProps {
6458 fetchDatasetVersions : typeof fetchDatasetVersions
6559 resetDatasetVersions : typeof resetDatasetVersions
60+ resetDataset : typeof resetDataset
6661}
6762
6863type IProps = IWithStyles < typeof styles > & StateProps & DispatchProps
@@ -75,21 +70,30 @@ function a11yProps(index: number) {
7570}
7671
7772const DatasetDetailPage : FunctionComponent < IProps > = props => {
78- const { classes, fetchDatasetVersions, resetDatasetVersions, versions, versionsLoading } = props
73+ const {
74+ classes,
75+ fetchDatasetVersions,
76+ resetDataset,
77+ resetDatasetVersions,
78+ versions,
79+ versionsLoading
80+ } = props
7981 const { root } = classes
8082 const history = useHistory ( )
8183 const i18next = require ( 'i18next' )
8284
8385 useEffect ( ( ) => {
84- fetchDatasetVersions ( props . dataset . namespace , props . dataset . name )
85- } , [ props . dataset . name ] )
86+ fetchDatasetVersions ( props . lineageDataset . namespace , props . lineageDataset . name )
87+ } , [ props . lineageDataset . name ] )
8688
8789 // unmounting
88- useEffect ( ( ) => {
89- return ( ) => {
90+ useEffect (
91+ ( ) => ( ) => {
92+ resetDataset ( )
9093 resetDatasetVersions ( )
91- }
92- } , [ ] )
94+ } ,
95+ [ ]
96+ )
9397
9498 const [ tab , setTab ] = React . useState ( 0 )
9599 const handleChange = ( event : ChangeEvent , newValue : SetStateAction < number > ) => {
@@ -108,8 +112,8 @@ const DatasetDetailPage: FunctionComponent<IProps> = props => {
108112 return null
109113 }
110114
111- const dataset = versions [ 0 ]
112- const { name, tags, description } = dataset
115+ const firstVersion = versions [ 0 ]
116+ const { name, tags, description } = firstVersion
113117
114118 return (
115119 < Box my = { 2 } className = { root } >
@@ -136,6 +140,11 @@ const DatasetDetailPage: FunctionComponent<IProps> = props => {
136140 { ...a11yProps ( 1 ) }
137141 disableRipple = { true }
138142 />
143+ < Tab
144+ label = { i18next . t ( 'datasets.column_lineage' ) }
145+ { ...a11yProps ( 1 ) }
146+ disableRipple = { true }
147+ />
139148 </ Tabs >
140149 </ Box >
141150 < IconButton onClick = { ( ) => history . push ( '/datasets' ) } >
@@ -151,12 +160,13 @@ const DatasetDetailPage: FunctionComponent<IProps> = props => {
151160 </ Box >
152161 { tab === 0 && (
153162 < DatasetInfo
154- datasetFields = { dataset . fields }
155- facets = { dataset . facets }
156- run = { dataset . createdByRun }
163+ datasetFields = { firstVersion . fields }
164+ facets = { firstVersion . facets }
165+ run = { firstVersion . createdByRun }
157166 />
158167 ) }
159168 { tab === 1 && < DatasetVersions versions = { props . versions } /> }
169+ { tab === 2 && < DatasetColumnLineage lineageDataset = { props . lineageDataset } /> }
160170 </ Box >
161171 )
162172}
@@ -171,7 +181,8 @@ const mapDispatchToProps = (dispatch: Redux.Dispatch) =>
171181 bindActionCreators (
172182 {
173183 fetchDatasetVersions : fetchDatasetVersions ,
174- resetDatasetVersions : resetDatasetVersions
184+ resetDatasetVersions : resetDatasetVersions ,
185+ resetDataset : resetDataset
175186 } ,
176187 dispatch
177188 )
0 commit comments