-
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] Refactoring of partition wipe dialog (#23196)
## Summary & Motivation Preparations + improvements to the structure of the partition wipe modal, and a new injection site allowing it to be modified. Misc: - I updated the TagSelector padding slightly so that it doesn't change height when you put in the first tag (prev 32 => 36px). - I fixed a GraphQL query error when you wiped asset events and the asset catalog table tried to reload with no variables passed to it's GraphQL query. ## How I Tested These Changes Verified that OSS functionality is unchanged. Co-authored-by: bengotow <[email protected]>
- Loading branch information
Showing
24 changed files
with
1,275 additions
and
755 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
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
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
118 changes: 118 additions & 0 deletions
118
js_modules/dagster-ui/packages/ui-core/src/assets/AssetWipeDialog.oss.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,118 @@ | ||
import {RefetchQueriesFunction} from '@apollo/client'; | ||
// eslint-disable-next-line no-restricted-imports | ||
import {ProgressBar} from '@blueprintjs/core'; | ||
import { | ||
Body1, | ||
Box, | ||
Button, | ||
Dialog, | ||
DialogBody, | ||
DialogFooter, | ||
Group, | ||
ifPlural, | ||
} from '@dagster-io/ui-components'; | ||
import {memo, useMemo} from 'react'; | ||
|
||
import {VirtualizedSimpleAssetKeyList} from './VirtualizedSimpleAssetKeyList'; | ||
import {asAssetPartitionRangeInput} from './asInput'; | ||
import {useWipeAssets} from './useWipeAssets'; | ||
import {AssetKeyInput} from '../graphql/types'; | ||
import {NavigationBlock} from '../runs/NavigationBlock'; | ||
import {numberFormatter} from '../ui/formatters'; | ||
|
||
export const AssetWipeDialog = memo( | ||
(props: { | ||
assetKeys: AssetKeyInput[]; | ||
isOpen: boolean; | ||
onClose: () => void; | ||
onComplete?: () => void; | ||
requery?: RefetchQueriesFunction; | ||
}) => { | ||
return ( | ||
<Dialog | ||
isOpen={props.isOpen} | ||
title="Wipe materializations" | ||
onClose={props.onClose} | ||
style={{width: '80vw', maxWidth: '1200px', minWidth: '600px'}} | ||
> | ||
<AssetWipeDialogInner {...props} /> | ||
</Dialog> | ||
); | ||
}, | ||
); | ||
|
||
export const AssetWipeDialogInner = memo( | ||
({ | ||
assetKeys, | ||
onClose, | ||
onComplete, | ||
requery, | ||
}: { | ||
assetKeys: AssetKeyInput[]; | ||
onClose: () => void; | ||
onComplete?: () => void; | ||
requery?: RefetchQueriesFunction; | ||
}) => { | ||
const {wipeAssets, isWiping, isDone, wipedCount, failedCount} = useWipeAssets({ | ||
refetchQueries: requery, | ||
onClose, | ||
onComplete, | ||
}); | ||
|
||
const content = useMemo(() => { | ||
if (isDone) { | ||
return ( | ||
<Box flex={{direction: 'column'}}> | ||
{wipedCount ? <Body1>{numberFormatter.format(wipedCount)} Wiped</Body1> : null} | ||
{failedCount ? <Body1>{numberFormatter.format(failedCount)} Failed</Body1> : null} | ||
</Box> | ||
); | ||
} else if (!isWiping) { | ||
return ( | ||
<Group direction="column" spacing={16}> | ||
<div> | ||
Are you sure you want to wipe materializations for{' '} | ||
{numberFormatter.format(assetKeys.length)}{' '} | ||
{ifPlural(assetKeys.length, 'asset', 'assets')}? | ||
</div> | ||
<VirtualizedSimpleAssetKeyList assetKeys={assetKeys} style={{maxHeight: '50vh'}} /> | ||
<div> | ||
Assets defined only by their historical materializations will disappear from the Asset | ||
Catalog. Software-defined assets will remain unless their definition is also deleted. | ||
</div> | ||
<strong>This action cannot be undone.</strong> | ||
</Group> | ||
); | ||
} | ||
const value = assetKeys.length > 0 ? (wipedCount + failedCount) / assetKeys.length : 1; | ||
return ( | ||
<Box flex={{gap: 8, direction: 'column'}}> | ||
<div>Wiping...</div> | ||
<ProgressBar intent="primary" value={Math.max(0.1, value)} animate={value < 1} /> | ||
<NavigationBlock message="Wiping in progress, please do not navigate away yet." /> | ||
</Box> | ||
); | ||
}, [isDone, isWiping, assetKeys, wipedCount, failedCount]); | ||
|
||
return ( | ||
<> | ||
<DialogBody>{content}</DialogBody> | ||
<DialogFooter topBorder> | ||
<Button intent={isDone ? 'primary' : 'none'} onClick={onClose}> | ||
{isDone ? 'Done' : 'Cancel'} | ||
</Button> | ||
{isDone ? null : ( | ||
<Button | ||
intent="danger" | ||
onClick={() => wipeAssets(assetKeys.map((key) => asAssetPartitionRangeInput(key)))} | ||
disabled={isWiping} | ||
loading={isWiping} | ||
> | ||
Wipe | ||
</Button> | ||
)} | ||
</DialogFooter> | ||
</> | ||
); | ||
}, | ||
); |
Oops, something went wrong.
1ba71a3
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-storybook ready!
✅ Preview
https://dagit-storybook-ic3wd3lun-elementl.vercel.app
Built with commit 1ba71a3.
This pull request is being automatically deployed with vercel-action
1ba71a3
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-9aat25uzf-elementl.vercel.app
Built with commit 1ba71a3.
This pull request is being automatically deployed with vercel-action