-
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] Add Automation History to asset checks (#26766)
## Summary & Motivation For asset checks that use automation conditions, show an "Automation history" tab with the list of relevant evaluations, much like the Automations tab on assets. With automation condition: <img width="1238" alt="Screenshot 2024-12-31 at 09 47 49" src="https://github.com/user-attachments/assets/8a6a320e-8281-46ca-8eca-201815e4df08" /> Without automation condition, hovering on tab: <img width="1238" alt="Screenshot 2024-12-31 at 09 47 58" src="https://github.com/user-attachments/assets/9c37ce97-e46d-4b6a-9ddd-50ca4be89069" /> ## How I Tested These Changes Load app with sample repo provided by @OwenKephart, enable automation sensor. Navigate to asset checks, verify that they render correctly, and that the evaluation dialog renders properly. ## Changelog [ui] Add Automation history to asset checks.
- Loading branch information
Showing
9 changed files
with
614 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
121 changes: 121 additions & 0 deletions
121
js_modules/dagster-ui/packages/ui-core/src/assets/asset-checks/AssetCheckAutomationList.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,121 @@ | ||
import {Box, CursorHistoryControls} from '@dagster-io/ui-components'; | ||
import {useMemo} from 'react'; | ||
|
||
import {FIFTEEN_SECONDS, useQueryRefreshAtInterval} from '../../app/QueryRefresh'; | ||
import {EvaluationList} from '../AutoMaterializePolicyPage/EvaluationList'; | ||
import {AssetKey} from '../types'; | ||
import { | ||
AssetCheckAutomationListQuery, | ||
AssetCheckAutomationListQueryVariables, | ||
} from './types/AssetCheckAutomationList.types'; | ||
import {gql} from '../../apollo-client'; | ||
import {useCursorPaginatedQuery} from '../../runs/useCursorPaginatedQuery'; | ||
import {ASSET_CONDITION_EVALUATION_RECORD_FRAGMENT} from '../AutoMaterializePolicyPage/GetEvaluationsQuery'; | ||
import {AssetCheckKeyFragment} from './types/AssetChecksQuery.types'; | ||
|
||
interface Props { | ||
assetCheck: AssetCheckKeyFragment; | ||
checkName: string; | ||
} | ||
|
||
export const AssetCheckAutomationList = ({assetCheck, checkName}: Props) => { | ||
const {queryResult, evaluations, paginationProps} = useAssetCheckEvaluationsQueryResult({ | ||
assetKey: assetCheck.assetKey, | ||
checkName, | ||
}); | ||
|
||
useQueryRefreshAtInterval(queryResult, FIFTEEN_SECONDS); | ||
|
||
return ( | ||
<> | ||
<Box | ||
padding={{vertical: 12, horizontal: 20}} | ||
flex={{direction: 'row', justifyContent: 'flex-end'}} | ||
> | ||
<CursorHistoryControls {...paginationProps} style={{marginTop: 0}} /> | ||
</Box> | ||
<EvaluationList | ||
assetKey={assetCheck.assetKey} | ||
isPartitioned={false} | ||
assetCheckName={checkName} | ||
evaluations={evaluations} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export const PAGE_SIZE = 30; | ||
|
||
export function useAssetCheckEvaluationsQueryResult({ | ||
assetKey, | ||
checkName, | ||
}: { | ||
assetKey: AssetKey; | ||
checkName: string; | ||
}) { | ||
const {queryResult, paginationProps} = useCursorPaginatedQuery< | ||
AssetCheckAutomationListQuery, | ||
AssetCheckAutomationListQueryVariables | ||
>({ | ||
nextCursorForResult: (data) => { | ||
if ( | ||
data.assetConditionEvaluationRecordsOrError?.__typename === | ||
'AssetConditionEvaluationRecords' | ||
) { | ||
return data.assetConditionEvaluationRecordsOrError.records[PAGE_SIZE - 1]?.evaluationId; | ||
} | ||
return undefined; | ||
}, | ||
getResultArray: (data) => { | ||
if ( | ||
data?.assetConditionEvaluationRecordsOrError?.__typename === | ||
'AssetConditionEvaluationRecords' | ||
) { | ||
return data.assetConditionEvaluationRecordsOrError.records; | ||
} | ||
return []; | ||
}, | ||
variables: { | ||
assetCheckKey: { | ||
assetKey: {path: assetKey.path}, | ||
name: checkName, | ||
}, | ||
}, | ||
query: ASSET_CHECK_AUTOMATION_LIST_QUERY, | ||
pageSize: PAGE_SIZE, | ||
}); | ||
|
||
const {data} = queryResult; | ||
const evaluations = useMemo(() => { | ||
if ( | ||
data?.assetConditionEvaluationRecordsOrError?.__typename === 'AssetConditionEvaluationRecords' | ||
) { | ||
return data.assetConditionEvaluationRecordsOrError.records; | ||
} | ||
return []; | ||
}, [data]); | ||
|
||
return {queryResult, evaluations, paginationProps}; | ||
} | ||
|
||
const ASSET_CHECK_AUTOMATION_LIST_QUERY = gql` | ||
query AssetCheckAutomationListQuery( | ||
$assetCheckKey: AssetCheckHandleInput! | ||
$limit: Int! | ||
$cursor: String | ||
) { | ||
assetConditionEvaluationRecordsOrError( | ||
assetKey: null | ||
assetCheckKey: $assetCheckKey | ||
limit: $limit | ||
cursor: $cursor | ||
) { | ||
... on AssetConditionEvaluationRecords { | ||
records { | ||
...AssetConditionEvaluationRecordFragment | ||
} | ||
} | ||
} | ||
} | ||
${ASSET_CONDITION_EVALUATION_RECORD_FRAGMENT} | ||
`; |
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
20 changes: 17 additions & 3 deletions
20
js_modules/dagster-ui/packages/ui-core/src/assets/asset-checks/AssetChecksTabs.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 |
---|---|---|
@@ -1,17 +1,31 @@ | ||
import {Tab, Tabs} from '@dagster-io/ui-components'; | ||
import {Tab, Tabs, Tooltip} from '@dagster-io/ui-components'; | ||
|
||
export type AssetChecksTabType = 'overview' | 'execution-history'; | ||
export type AssetChecksTabType = 'overview' | 'execution-history' | 'automation-history'; | ||
|
||
interface Props { | ||
activeTab: AssetChecksTabType; | ||
enableAutomationHistory: boolean; | ||
onChange: (tabId: AssetChecksTabType) => void; | ||
} | ||
|
||
export const AssetChecksTabs = ({activeTab, onChange}: Props) => { | ||
export const AssetChecksTabs = ({activeTab, enableAutomationHistory, onChange}: Props) => { | ||
return ( | ||
<Tabs selectedTabId={activeTab} onChange={onChange}> | ||
<Tab id="overview" title="Overview" /> | ||
<Tab id="execution-history" title="Execution history" /> | ||
<Tab | ||
id="automation-history" | ||
title={ | ||
<Tooltip | ||
content="This asset check does not have an automation condition configured." | ||
canShow={!enableAutomationHistory} | ||
placement="top" | ||
> | ||
Automation history | ||
</Tooltip> | ||
} | ||
disabled={!enableAutomationHistory} | ||
/> | ||
</Tabs> | ||
); | ||
}; |
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.
844b0d3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for dagit-core-storybook ready!
✅ Preview
https://dagit-core-storybook-ktrcdg3q4-elementl.vercel.app
Built with commit 844b0d3.
This pull request is being automatically deployed with vercel-action