Skip to content

Commit a14dfe5

Browse files
committed
changes after review. refactoring. fix type and name of file
Signed-off-by: tito12 <vladyslav.sedenko@gmail.com>
1 parent 6c6b329 commit a14dfe5

2 files changed

Lines changed: 45 additions & 8 deletions

File tree

web/src/components/datasets/DatasetColumnLineage.tsx

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,65 @@
11
// SPDX-License-Identifier: Apache-2.0
22

3-
import { Box } from '@material-ui/core'
3+
import { Box, Button } from '@material-ui/core'
44
import MqEmpty from '../core/empty/MqEmpty'
55
import MqJson from '../core/code/MqJson'
6+
import MqText from '../core/text/MqText'
67
import React, { FunctionComponent } from 'react'
8+
import { fileSize } from '../../helpers'
9+
import { LineageDataset } from '../lineage/types'
10+
import { saveAs } from 'file-saver'
711

812
interface DatasetColumnLineageProps {
913
columnLineage: object
14+
lineageDataset: LineageDataset
1015
}
1116

1217
const DatasetColumnLineage: FunctionComponent<DatasetColumnLineageProps> = props => {
13-
const { columnLineage } = props
18+
const { columnLineage, lineageDataset } = props
19+
20+
const handleDownloadPayload = (data: object) => {
21+
const title = `${lineageDataset.name}-${lineageDataset.namespace}-columnLineage`
22+
const blob = new Blob([JSON.stringify(data)], { type: 'application/json' })
23+
saveAs(blob, `${title}.json`)
24+
}
1425

1526
return (
16-
<Box>
27+
<>
1728
{columnLineage
1829
? (
19-
<Box mt={2}>
20-
<MqJson code={columnLineage} />
21-
</Box>
30+
<>
31+
{fileSize(JSON.stringify(columnLineage)).kiloBytes > 500 ? (
32+
<Box p={2}>
33+
<MqEmpty title={'Payload is too big for render'}>
34+
<div>
35+
<MqText subdued>
36+
Please click on button and download payload as file
37+
</MqText>
38+
<br />
39+
<Button
40+
variant='outlined'
41+
color='primary'
42+
onClick={() => handleDownloadPayload(columnLineage)}
43+
>
44+
Download payload
45+
</Button>
46+
</div>
47+
</MqEmpty>
48+
</Box>
49+
) : (
50+
<MqJson
51+
code={columnLineage}
52+
wrapLongLines={true}
53+
showLineNumbers={true}
54+
/>
55+
)}
56+
</>
2257
)
2358
: (
2459
<MqEmpty title={'No column lineage'} body={'Column lineage not available for the specified dataset.'} />
2560
)
2661
}
27-
</Box>
62+
</>
2863
)
2964
}
3065

web/src/components/datasets/DatasetDetailPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ const DatasetDetailPage: FunctionComponent<IProps> = props => {
168168
/>
169169
)}
170170
{tab === 1 && <DatasetVersions versions={props.versions} />}
171-
{tab === 2 && handleFetchDataset() && <DatasetColumnLineage columnLineage={props.dataset.columnLineage} />}
171+
{tab === 2 && handleFetchDataset() && (
172+
<DatasetColumnLineage lineageDataset={props.lineageDataset} columnLineage={props.dataset.columnLineage} />
173+
)}
172174
</Box>
173175
)
174176
}

0 commit comments

Comments
 (0)