-
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.
[Asset graph] Add query refresh button with "Date at most X seconds o…
…ld" tooltip (#16886) ## Summary & Motivation Adding back the ability to refresh data and also including a message indicating how old the last visible refreshed data on the screen is. ## How I Tested These Changes <img width="294" alt="Screenshot 2023-09-29 at 1 21 20 AM" src="https://github.com/dagster-io/dagster/assets/2286579/c0e7bfa4-e3d7-4d4c-8344-fbf2a1e87285">
- Loading branch information
Showing
7 changed files
with
340 additions
and
53 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
73 changes: 73 additions & 0 deletions
73
js_modules/dagster-ui/packages/ui-core/src/asset-data/AssetDataRefreshButton.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,73 @@ | ||
import {Box, Button, Colors, Icon, Tooltip} from '@dagster-io/ui-components'; | ||
import dayjs from 'dayjs'; | ||
import relativeTime from 'dayjs/plugin/relativeTime'; | ||
import updateLocale from 'dayjs/plugin/updateLocale'; | ||
import React from 'react'; | ||
|
||
dayjs.extend(relativeTime); | ||
dayjs.extend(updateLocale); | ||
|
||
dayjs.updateLocale('en', { | ||
relativeTime: { | ||
future: 'in %s', | ||
past: '%s ago', | ||
s: '%d seconds', | ||
m: 'a minute', | ||
mm: '%d minutes', | ||
h: 'an hour', | ||
hh: '%d hours', | ||
d: 'a day', | ||
dd: '%d days', | ||
M: 'a month', | ||
MM: '%d months', | ||
y: 'a year', | ||
yy: '%d years', | ||
}, | ||
}); | ||
|
||
export const AssetDataRefreshButton = ({ | ||
isRefreshing, | ||
onRefresh, | ||
oldestDataTimestamp, | ||
}: { | ||
isRefreshing: boolean; | ||
onRefresh: () => void; | ||
oldestDataTimestamp: number; | ||
}) => { | ||
return ( | ||
<Tooltip | ||
content={ | ||
isRefreshing ? ( | ||
'Refreshing asset data…' | ||
) : ( | ||
<Box flex={{direction: 'column', gap: 4}}> | ||
<TimeFromNowWithSeconds timestamp={oldestDataTimestamp} /> | ||
<div>Click to refresh now</div> | ||
</Box> | ||
) | ||
} | ||
> | ||
<Button | ||
icon={<Icon name="refresh" color={Colors.Gray400} />} | ||
onClick={() => { | ||
if (!isRefreshing) { | ||
onRefresh(); | ||
} | ||
}} | ||
/> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
const TimeFromNowWithSeconds: React.FC<{timestamp: number}> = ({timestamp}) => { | ||
const [text, setText] = React.useState(dayjs(timestamp).fromNow(true)); | ||
React.useEffect(() => { | ||
const interval = setInterval(() => { | ||
setText(dayjs(timestamp).fromNow(true)); | ||
}, 1000); | ||
return () => { | ||
clearInterval(interval); | ||
}; | ||
}, [timestamp]); | ||
return <>{text === '0s' ? 'Refreshing asset data…' : `Data is at most ${text} old`}</>; | ||
}; |
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.
202cb1d
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-putaxeg2c-elementl.vercel.app
Built with commit 202cb1d.
This pull request is being automatically deployed with vercel-action
202cb1d
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-mbuffcdsd-elementl.vercel.app
Built with commit 202cb1d.
This pull request is being automatically deployed with vercel-action