-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ui] Open evaluation detail dialog from automaterialize tag (#26963)
## Summary & Motivation Fix "View evaluation" links from `AutomaterializeTagWithEvaluation`, which shows asset keys and evaluation links in a popover, e.g. on a Run. When clicking the link, open the evaluation detail dialog. Additionally: - Added the asset (or asset check) information in a tag in the dialog header, because otherwise it's not clear what asset you're looking at. - Added a footer button to link to the asset's Automation tab, cursored to the currently viewed evaluation ID. This is to allow a look at recent history. ## How I Tested These Changes View a run that has this tag. Verify that the popover link opens the dialog correctly, and that the asset tag renders in the header. ## Changelog [ui] Open the evaluation detail dialog from the "Automation condition" tag popover on Runs.
- Loading branch information
Showing
2 changed files
with
143 additions
and
65 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
114 changes: 66 additions & 48 deletions
114
js_modules/dagster-ui/packages/ui-core/src/assets/AutomaterializeTagWithEvaluation.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,71 +1,89 @@ | ||
import {Box, Icon, MiddleTruncate, Popover, Tag} from '@dagster-io/ui-components'; | ||
import {useMemo} from 'react'; | ||
import {Link} from 'react-router-dom'; | ||
import {Box, ButtonLink, Icon, MiddleTruncate, Popover, Tag} from '@dagster-io/ui-components'; | ||
import {useMemo, useState} from 'react'; | ||
|
||
import {EvaluationDetailDialog} from './AutoMaterializePolicyPage/EvaluationDetailDialog'; | ||
import {assetDetailsPathForKey} from './assetDetailsPathForKey'; | ||
import {AssetKey} from './types'; | ||
|
||
const COLLATOR = new Intl.Collator(navigator.language, {sensitivity: 'base'}); | ||
|
||
type OpenEvaluation = { | ||
assetKeyPath: string[]; | ||
evaluationId: string; | ||
}; | ||
|
||
interface Props { | ||
assetKeys: AssetKey[]; | ||
evaluationId: string; | ||
} | ||
|
||
export const AutomaterializeTagWithEvaluation = ({assetKeys, evaluationId}: Props) => { | ||
const [openEvaluation, setOpenEvaluation] = useState<OpenEvaluation | null>(null); | ||
|
||
const sortedKeys = useMemo(() => { | ||
return [...assetKeys].sort((a, b) => COLLATOR.compare(a.path.join('/'), b.path.join('/'))); | ||
}, [assetKeys]); | ||
|
||
return ( | ||
<Popover | ||
placement="bottom" | ||
content={ | ||
<div style={{width: '340px'}}> | ||
<Box padding={{vertical: 8, horizontal: 12}} border="bottom" style={{fontWeight: 600}}> | ||
Automation condition | ||
</Box> | ||
<Box | ||
flex={{direction: 'column', gap: 12}} | ||
padding={{vertical: 12}} | ||
style={{maxHeight: '220px', overflowY: 'auto'}} | ||
> | ||
{sortedKeys.map((assetKey) => { | ||
const url = assetDetailsPathForKey(assetKey, { | ||
view: 'automation', | ||
evaluation: evaluationId, | ||
}); | ||
return ( | ||
<Box | ||
key={url} | ||
padding={{vertical: 8, left: 12, right: 16}} | ||
flex={{ | ||
direction: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
gap: 8, | ||
}} | ||
style={{overflow: 'hidden'}} | ||
> | ||
<> | ||
<Popover | ||
placement="bottom" | ||
content={ | ||
<div style={{width: '400px'}}> | ||
<Box padding={{vertical: 8, horizontal: 12}} border="bottom" style={{fontWeight: 600}}> | ||
Automation condition | ||
</Box> | ||
<Box | ||
flex={{direction: 'column', gap: 16}} | ||
padding={{vertical: 12}} | ||
style={{maxHeight: '220px', overflowY: 'auto'}} | ||
> | ||
{sortedKeys.map((assetKey) => { | ||
const url = assetDetailsPathForKey(assetKey, { | ||
view: 'automation', | ||
evaluation: evaluationId, | ||
}); | ||
return ( | ||
<Box | ||
flex={{direction: 'row', alignItems: 'center', gap: 8}} | ||
key={url} | ||
padding={{vertical: 8, left: 12, right: 16}} | ||
flex={{ | ||
direction: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
gap: 16, | ||
}} | ||
style={{overflow: 'hidden'}} | ||
> | ||
<Icon name="asset" /> | ||
<MiddleTruncate text={assetKey.path.join('/')} /> | ||
<Box | ||
flex={{direction: 'row', alignItems: 'center', gap: 8}} | ||
style={{overflow: 'hidden'}} | ||
> | ||
<Icon name="asset" /> | ||
<MiddleTruncate text={assetKey.path.join('/')} /> | ||
</Box> | ||
<ButtonLink | ||
onClick={() => setOpenEvaluation({assetKeyPath: assetKey.path, evaluationId})} | ||
style={{whiteSpace: 'nowrap'}} | ||
> | ||
View evaluation | ||
</ButtonLink> | ||
</Box> | ||
<Link to={url} style={{whiteSpace: 'nowrap'}}> | ||
View evaluation | ||
</Link> | ||
</Box> | ||
); | ||
})} | ||
</Box> | ||
</div> | ||
} | ||
interactionKind="hover" | ||
> | ||
<Tag icon="automation_condition">Automation condition</Tag> | ||
</Popover> | ||
); | ||
})} | ||
</Box> | ||
</div> | ||
} | ||
interactionKind="hover" | ||
> | ||
<Tag icon="automation_condition">Automation condition</Tag> | ||
</Popover> | ||
<EvaluationDetailDialog | ||
assetKeyPath={openEvaluation?.assetKeyPath ?? []} | ||
isOpen={!!openEvaluation} | ||
onClose={() => setOpenEvaluation(null)} | ||
evaluationID={openEvaluation?.evaluationId ?? ''} | ||
/> | ||
</> | ||
); | ||
}; |
9a8a7e9
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-j2cm30qdn-elementl.vercel.app
Built with commit 9a8a7e9.
This pull request is being automatically deployed with vercel-action