-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
present column lineage of a dataset (#2293)
* display column lineage JSON Signed-off-by: Pawel Leszczynski <[email protected]> * refactoring for display column lineage JSON (#2294) Signed-off-by: tito1212 <[email protected]> Signed-off-by: tito1212 <[email protected]> Co-authored-by: tito1212 <[email protected]> * Refactoring for display column lineage JSON (#2301) * refactoring for display column lineage JSON Signed-off-by: tito1212 <[email protected]> * request api after click Signed-off-by: tito1212 <[email protected]> Signed-off-by: tito1212 <[email protected]> Co-authored-by: tito1212 <[email protected]> * call backend on tab switch Signed-off-by: Pawel Leszczynski <[email protected]> * changes after review. refactoring. fix type and name of file Signed-off-by: tito12 <[email protected]> * Changes after review. Separate fetching data in child component Signed-off-by: tito12 <[email protected]> * eslint fix changes Signed-off-by: tito12 <[email protected]> Signed-off-by: Pawel Leszczynski <[email protected]> Signed-off-by: tito1212 <[email protected]> Signed-off-by: tito12 <[email protected]> Co-authored-by: tito12 <[email protected]> Co-authored-by: tito1212 <[email protected]> Co-authored-by: Pawel Leszczynski <[email protected]>
- Loading branch information
1 parent
65669ca
commit 39bcd3a
Showing
13 changed files
with
230 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import * as Redux from 'redux' | ||
import { Box, Button } from '@material-ui/core' | ||
import { Dataset } from '../../types/api' | ||
import { IState } from '../../store/reducers' | ||
import { LineageDataset } from '../lineage/types' | ||
import { bindActionCreators } from 'redux' | ||
import { connect } from 'react-redux' | ||
import { fetchDataset, resetDataset } from '../../store/actionCreators' | ||
import { fileSize } from '../../helpers' | ||
import { saveAs } from 'file-saver' | ||
import MqEmpty from '../core/empty/MqEmpty' | ||
import MqJson from '../core/code/MqJson' | ||
import MqText from '../core/text/MqText' | ||
import React, { FunctionComponent, useEffect } from 'react' | ||
|
||
interface DatasetColumnLineageProps { | ||
lineageDataset: LineageDataset | ||
} | ||
|
||
interface StateProps { | ||
dataset: Dataset | ||
} | ||
|
||
interface DispatchProps { | ||
fetchDataset: typeof fetchDataset | ||
resetDataset: typeof resetDataset | ||
} | ||
|
||
type IProps = DatasetColumnLineageProps & DispatchProps & StateProps | ||
|
||
const DatasetColumnLineage: FunctionComponent<IProps> = props => { | ||
const { dataset, lineageDataset, fetchDataset, resetDataset } = props | ||
const columnLineage = dataset.columnLineage | ||
|
||
useEffect(() => { | ||
fetchDataset(lineageDataset.namespace, lineageDataset.name) | ||
}, [lineageDataset.name]) | ||
|
||
// unmounting | ||
useEffect( | ||
() => () => { | ||
resetDataset() | ||
}, | ||
[] | ||
) | ||
|
||
const handleDownloadPayload = (data: object) => { | ||
const title = `${lineageDataset.name}-${lineageDataset.namespace}-columnLineage` | ||
const blob = new Blob([JSON.stringify(data)], { type: 'application/json' }) | ||
saveAs(blob, `${title}.json`) | ||
} | ||
|
||
return ( | ||
<> | ||
{columnLineage ? ( | ||
<> | ||
{fileSize(JSON.stringify(columnLineage)).kiloBytes > 500 ? ( | ||
<Box p={2}> | ||
<MqEmpty title={'Payload is too big for render'}> | ||
<div> | ||
<MqText subdued>Please click on button and download payload as file</MqText> | ||
<br /> | ||
<Button | ||
variant='outlined' | ||
color='primary' | ||
onClick={() => handleDownloadPayload(columnLineage)} | ||
> | ||
Download payload | ||
</Button> | ||
</div> | ||
</MqEmpty> | ||
</Box> | ||
) : ( | ||
<MqJson code={columnLineage} wrapLongLines={true} showLineNumbers={true} /> | ||
)} | ||
</> | ||
) : ( | ||
<MqEmpty | ||
title={'No column lineage'} | ||
body={'Column lineage not available for the specified dataset.'} | ||
/> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
const mapStateToProps = (state: IState) => ({ | ||
dataset: state.dataset.result | ||
}) | ||
|
||
const mapDispatchToProps = (dispatch: Redux.Dispatch) => | ||
bindActionCreators( | ||
{ | ||
fetchDataset: fetchDataset, | ||
resetDataset: resetDataset | ||
}, | ||
dispatch | ||
) | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(DatasetColumnLineage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { Dataset } from '../../types/api' | ||
import { FETCH_DATASET, FETCH_DATASET_SUCCESS, RESET_DATASET } from '../actionCreators/actionTypes' | ||
import { fetchDatasetSuccess } from '../actionCreators' | ||
|
||
export type IDatasetState = { isLoading: boolean; result: Dataset; init: boolean } | ||
|
||
export const initialState: IDatasetState = { isLoading: false, init: false, result: {} as Dataset } | ||
|
||
type IDatasetAction = ReturnType<typeof fetchDatasetSuccess> | ||
|
||
export default (state: IDatasetState = initialState, action: IDatasetAction): IDatasetState => { | ||
const { type, payload } = action | ||
|
||
switch (type) { | ||
case FETCH_DATASET: | ||
return { ...state, isLoading: true } | ||
case FETCH_DATASET_SUCCESS: | ||
return { ...state, isLoading: false, init: true, result: payload.dataset } | ||
case RESET_DATASET: | ||
return initialState | ||
default: | ||
return state | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.