-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ui] Implement new asset Automation page
- Loading branch information
1 parent
942e7a0
commit 958bf49
Showing
39 changed files
with
808 additions
and
130 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
83 changes: 83 additions & 0 deletions
83
.../dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/AssetAutomationRoot.tsx
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,83 @@ | ||
import { | ||
Box, | ||
CursorHistoryControls, | ||
NonIdealState, | ||
SpinnerWithText, | ||
} from '@dagster-io/ui-components'; | ||
import {useEffect, useMemo, useRef} from 'react'; | ||
|
||
import {useEvaluationsQueryResult} from './useEvaluationsQueryResult'; | ||
import {FIFTEEN_SECONDS, useQueryRefreshAtInterval} from '../../app/QueryRefresh'; | ||
import {AssetKey} from '../types'; | ||
import {EvaluationList} from './EvaluationList'; | ||
import {AssetViewDefinitionNodeFragment} from '../types/AssetView.types'; | ||
|
||
interface Props { | ||
assetKey: AssetKey; | ||
definition: AssetViewDefinitionNodeFragment | null; | ||
} | ||
|
||
export const AssetAutomationRoot = ({assetKey, definition}: Props) => { | ||
const {queryResult, paginationProps} = useEvaluationsQueryResult({assetKey}); | ||
const {data, loading} = queryResult; | ||
|
||
const scrollRef = useRef<HTMLDivElement>(null); | ||
|
||
// When paginating, reset scroll to top. | ||
useEffect(() => { | ||
if (scrollRef.current) { | ||
scrollRef.current.scrollTo({top: 0, behavior: 'instant'}); | ||
} | ||
}, [paginationProps.cursor]); | ||
|
||
useQueryRefreshAtInterval(queryResult, FIFTEEN_SECONDS); | ||
|
||
const evaluations = useMemo(() => { | ||
if ( | ||
data?.assetConditionEvaluationRecordsOrError?.__typename === | ||
'AssetConditionEvaluationRecords' && | ||
data?.assetNodeOrError?.__typename === 'AssetNode' | ||
) { | ||
return data.assetConditionEvaluationRecordsOrError.records; | ||
} | ||
return []; | ||
}, [data]); | ||
|
||
if (loading && !data) { | ||
return ( | ||
<Box padding={64} flex={{direction: 'column', alignItems: 'center'}}> | ||
<SpinnerWithText label="Loading evaluations…" /> | ||
</Box> | ||
); | ||
} | ||
|
||
if (!definition) { | ||
return ( | ||
<Box padding={64}> | ||
<NonIdealState | ||
icon="asset" | ||
title="Asset evaluations not found" | ||
description="This asset does not have any automation evaluations." | ||
/> | ||
</Box> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<Box | ||
padding={{vertical: 12, horizontal: 20}} | ||
flex={{direction: 'row', justifyContent: 'flex-end'}} | ||
> | ||
<CursorHistoryControls {...paginationProps} style={{marginTop: 0}} /> | ||
</Box> | ||
<div style={{overflowY: 'auto'}} ref={scrollRef}> | ||
<EvaluationList | ||
evaluations={evaluations} | ||
assetKey={assetKey} | ||
isPartitioned={definition.partitionDefinition !== null} | ||
/> | ||
</div> | ||
</> | ||
); | ||
}; |
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
Oops, something went wrong.