Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataset Version call simplification #2938

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 3 additions & 20 deletions web/src/components/datasets/DatasetDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@mui/material'
import { CalendarIcon } from '@mui/x-date-pickers'
import { CircularProgress } from '@mui/material'
import { Dataset, DatasetVersion } from '../../types/api'
import { Dataset } from '../../types/api'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { IState } from '../../store/reducers'
import { LineageDataset } from '../../types/lineage'
Expand All @@ -28,7 +28,6 @@ import {
deleteDataset,
dialogToggle,
fetchDataset,
fetchInitialDatasetVersions,
resetDataset,
resetDatasetVersions,
setTabIndex,
Expand Down Expand Up @@ -57,15 +56,12 @@ interface StateProps {
lineageDataset: LineageDataset
dataset: Dataset
isDatasetLoading: boolean
initVersions: DatasetVersion[]
initVersionsLoading: boolean
datasets: IState['datasets']
display: IState['display']
tabIndex: IState['lineage']['tabIndex']
}

interface DispatchProps {
fetchInitialDatasetVersions: typeof fetchInitialDatasetVersions
fetchDataset: typeof fetchDataset
resetDatasetVersions: typeof resetDatasetVersions
resetDataset: typeof resetDataset
Expand All @@ -92,11 +88,8 @@ const DatasetDetailPage: FunctionComponent<IProps> = (props) => {
fetchDataset,
resetDataset,
resetDatasetVersions,
fetchInitialDatasetVersions,
deleteDataset,
dialogToggle,
initVersions,
initVersionsLoading,
lineageDataset,
tabIndex,
setTabIndex,
Expand All @@ -118,7 +111,6 @@ const DatasetDetailPage: FunctionComponent<IProps> = (props) => {

// might need to map first version to its own state
useEffect(() => {
fetchInitialDatasetVersions(lineageDataset.namespace, lineageDataset.name)
fetchDataset(lineageDataset.namespace, lineageDataset.name)
}, [lineageDataset.name])

Expand All @@ -133,19 +125,14 @@ const DatasetDetailPage: FunctionComponent<IProps> = (props) => {
setTabIndex(newValue)
}

if (!dataset || isDatasetLoading || (initVersionsLoading && initVersions.length === 0)) {
if (!dataset || isDatasetLoading) {
return (
<Box display={'flex'} justifyContent={'center'} mt={2}>
<CircularProgress color='primary' />
</Box>
)
}

if (initVersions.length === 0) {
return null
}

const firstVersion = initVersions[0]
const { name, tags, description } = dataset
const facetsStatus = datasetFacetsStatus(dataset.facets)
const assertions = datasetFacetsQualityAssertions(dataset.facets)
Expand Down Expand Up @@ -328,7 +315,7 @@ const DatasetDetailPage: FunctionComponent<IProps> = (props) => {
checked={showTags}
onChange={() => setShowTags(!showTags)}
inputProps={{ 'aria-label': 'toggle show tags' }}
disabled={initVersionsLoading}
disabled={isDatasetLoading}
/>
}
label={i18next.t('datasets.show_field_tags')}
Expand All @@ -341,7 +328,6 @@ const DatasetDetailPage: FunctionComponent<IProps> = (props) => {
dataset={dataset}
datasetFields={dataset.fields}
facets={dataset.facets}
run={firstVersion.createdByRun}
showTags={showTags}
isCurrentVersion
/>
Expand All @@ -356,15 +342,12 @@ const mapStateToProps = (state: IState) => ({
dataset: state.dataset.result,
isDatasetLoading: state.dataset.isLoading,
display: state.display,
initVersions: state.datasetVersions.initDsVersion.versions,
initVersionsLoading: state.datasetVersions.isInitDsVerLoading,
tabIndex: state.lineage.tabIndex,
})

const mapDispatchToProps = (dispatch: Redux.Dispatch) =>
bindActionCreators(
{
fetchInitialDatasetVersions: fetchInitialDatasetVersions,
fetchDataset: fetchDataset,
resetDatasetVersions: resetDatasetVersions,
resetDataset: resetDataset,
Expand Down
60 changes: 7 additions & 53 deletions web/src/components/datasets/DatasetInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,65 +1,32 @@
// Copyright 2018-2024 contributors to the Marquez project
// SPDX-License-Identifier: Apache-2.0
import * as Redux from 'redux'
import { Box, Chip, Table, TableBody, TableCell, TableHead, TableRow } from '@mui/material'
import { Dataset, Field, Run } from '../../types/api'
import { IState } from '../../store/reducers'
import { Dataset, Field } from '../../types/api'
import { Link } from 'react-router-dom'
import { connect, useSelector } from 'react-redux'
import { encodeQueryString } from '../../routes/column-level/ColumnLineageColumnNode'
import { fetchJobFacets, resetFacets } from '../../store/actionCreators'
import DatasetTags from './DatasetTags'
import IconButton from '@mui/material/IconButton'
import MQTooltip from '../core/tooltip/MQTooltip'
import MqEmpty from '../core/empty/MqEmpty'
import MqJsonView from '../core/json-view/MqJsonView'
import MqText from '../core/text/MqText'
import React, { FunctionComponent, useEffect } from 'react'
import React, { FunctionComponent } from 'react'
import SplitscreenIcon from '@mui/icons-material/Splitscreen'

export interface DispatchProps {
fetchJobFacets: typeof fetchJobFacets
resetFacets: typeof resetFacets
}

interface JobFacets {
[key: string]: object
}

export interface JobFacetsProps {
jobFacets: JobFacets
isCurrentVersion?: boolean
dataset: Dataset
}

type DatasetInfoProps = {
datasetFields: Field[]
facets?: object
run?: Run
showTags?: boolean
} & JobFacetsProps &
DispatchProps
} & JobFacetsProps

const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => {
const { datasetFields, facets, run, dataset, fetchJobFacets, resetFacets, showTags } = props
const { datasetFields, facets, dataset, showTags } = props
const i18next = require('i18next')
const dsNamespace = useSelector(
(state: IState) => state.datasetVersions.initDsVersion.versions[0].namespace
)
const dsName = useSelector(
(state: IState) => state.datasetVersions.initDsVersion.versions[0].name
)

useEffect(() => {
run && fetchJobFacets(run.id)
}, [run])

useEffect(
() => () => {
resetFacets()
},
[]
)

return (
<Box>
Expand Down Expand Up @@ -159,8 +126,8 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => {
{showTags && (
<TableCell align='left'>
<DatasetTags
namespace={dsNamespace}
datasetName={dsName}
namespace={dataset.namespace}
datasetName={dataset.name}
datasetTags={field.tags}
datasetField={field.name}
/>
Expand All @@ -186,17 +153,4 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => {
)
}

const mapStateToProps = (state: IState) => ({
jobFacets: state.facets.result,
})

const mapDispatchToProps = (dispatch: Redux.Dispatch) =>
Redux.bindActionCreators(
{
fetchJobFacets: fetchJobFacets,
resetFacets: resetFacets,
},
dispatch
)

export default connect(mapStateToProps, mapDispatchToProps)(DatasetInfo)
export default DatasetInfo
1 change: 0 additions & 1 deletion web/src/components/datasets/DatasetVersions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const DatasetVersions: FunctionComponent<DatasetVersionsProps & DispatchProps> =
dataset={dataset}
datasetFields={infoView.fields}
facets={infoView.facets}
run={infoView.createdByRun}
/>
</>
)
Expand Down
Loading