@@ -4,7 +4,7 @@ import React, { ChangeEvent, FunctionComponent, SetStateAction, useEffect } from
44
55import * as Redux from 'redux'
66import { Box , Chip , Tab , Tabs } from '@material-ui/core'
7- import { DatasetVersion } from '../../types/api'
7+ import { Dataset , DatasetVersion } from '../../types/api' ;
88import { IState } from '../../store/reducers'
99import {
1010 Theme as ITheme ,
@@ -15,10 +15,15 @@ import {
1515import { LineageDataset } from '../lineage/types'
1616import { bindActionCreators } from 'redux'
1717import { connect } from 'react-redux'
18- import { fetchDatasetVersions , resetDatasetVersions } from '../../store/actionCreators'
18+ import {
19+ fetchDataset ,
20+ fetchDatasetVersions ,
21+ resetDatasetVersions
22+ } from '../../store/actionCreators'
1923import { useHistory } from 'react-router-dom'
2024import CircularProgress from '@material-ui/core/CircularProgress/CircularProgress'
2125import CloseIcon from '@material-ui/icons/Close'
26+ import DatasetColumnLineage from './DatasetColumnLineage'
2227import DatasetInfo from './DatasetInfo'
2328import DatasetVersions from './DatasetVersions'
2429import IconButton from '@material-ui/core/IconButton'
@@ -55,13 +60,15 @@ const styles = ({ spacing }: ITheme) => {
5560}
5661
5762interface StateProps {
58- dataset : LineageDataset
63+ lineageDataset : LineageDataset
5964 versions : DatasetVersion [ ]
65+ dataset : Dataset
6066 versionsLoading : boolean
6167}
6268
6369interface DispatchProps {
6470 fetchDatasetVersions : typeof fetchDatasetVersions
71+ fetchDataset : typeof fetchDataset
6572 resetDatasetVersions : typeof resetDatasetVersions
6673}
6774
@@ -75,13 +82,13 @@ function a11yProps(index: number) {
7582}
7683
7784const DatasetDetailPage : FunctionComponent < IProps > = props => {
78- const { classes, fetchDatasetVersions, resetDatasetVersions, versions, versionsLoading } = props
85+ const { classes, fetchDatasetVersions, fetchDataset , resetDatasetVersions, versions, versionsLoading } = props
7986 const { root } = classes
8087 const history = useHistory ( )
8188
8289 useEffect ( ( ) => {
83- fetchDatasetVersions ( props . dataset . namespace , props . dataset . name )
84- } , [ props . dataset . name ] )
90+ fetchDatasetVersions ( props . lineageDataset . namespace , props . lineageDataset . name )
91+ } , [ props . lineageDataset . name ] )
8592
8693 // unmounting
8794 useEffect ( ( ) => {
@@ -90,6 +97,10 @@ const DatasetDetailPage: FunctionComponent<IProps> = props => {
9097 }
9198 } , [ ] )
9299
100+ // useEffect(() => {
101+ // fetchDataset(props.lineageDataset.namespace, props.lineageDataset.name)
102+ // }, [props.lineageDataset.name])
103+
93104 const [ tab , setTab ] = React . useState ( 0 )
94105 const handleChange = ( event : ChangeEvent , newValue : SetStateAction < number > ) => {
95106 setTab ( newValue )
@@ -107,8 +118,8 @@ const DatasetDetailPage: FunctionComponent<IProps> = props => {
107118 return null
108119 }
109120
110- const dataset = versions [ 0 ]
111- const { name, tags, description } = dataset
121+ const firstVersion = versions [ 0 ]
122+ const { name, tags, description } = firstVersion
112123
113124 return (
114125 < Box my = { 2 } className = { root } >
@@ -127,6 +138,7 @@ const DatasetDetailPage: FunctionComponent<IProps> = props => {
127138 < Tabs value = { tab } onChange = { handleChange } textColor = 'primary' indicatorColor = 'primary' >
128139 < Tab label = 'LATEST SCHEMA' { ...a11yProps ( 0 ) } disableRipple = { true } />
129140 < Tab label = 'VERSION HISTORY' { ...a11yProps ( 1 ) } disableRipple = { true } />
141+ < Tab label = 'COLUMN LINEAGE' { ...a11yProps ( 2 ) } disableRipple = { true } />
130142 </ Tabs >
131143 </ Box >
132144 < IconButton onClick = { ( ) => history . push ( '/datasets' ) } >
@@ -142,26 +154,29 @@ const DatasetDetailPage: FunctionComponent<IProps> = props => {
142154 </ Box >
143155 { tab === 0 && (
144156 < DatasetInfo
145- datasetFields = { dataset . fields }
146- facets = { dataset . facets }
147- run = { dataset . createdByRun }
157+ datasetFields = { firstVersion . fields }
158+ facets = { firstVersion . facets }
159+ run = { firstVersion . createdByRun }
148160 />
149161 ) }
150162 { tab === 1 && < DatasetVersions versions = { props . versions } /> }
163+ { tab === 2 && ( props . dataset . name !== undefined || fetchDataset ( props . lineageDataset . namespace , props . lineageDataset . name ) ) && < DatasetColumnLineage columnLineage = { props . dataset . columnLineage } /> }
151164 </ Box >
152165 )
153166}
154167
155168const mapStateToProps = ( state : IState ) => ( {
156169 datasets : state . datasets . result ,
157170 versions : state . datasetVersions . result . versions ,
171+ dataset : state . dataset . result ,
158172 versionsLoading : state . datasetVersions . isLoading
159173} )
160174
161175const mapDispatchToProps = ( dispatch : Redux . Dispatch ) =>
162176 bindActionCreators (
163177 {
164178 fetchDatasetVersions : fetchDatasetVersions ,
179+ fetchDataset : fetchDataset ,
165180 resetDatasetVersions : resetDatasetVersions
166181 } ,
167182 dispatch
0 commit comments