- Notifications
You must be signed in to change notification settings - Fork928
feat: Add "Outdated" tooltip and "Update version" button in the Workspaces page#2322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
e5cbcd8
9d92df2
58d6a6a
b4bc684
ca18646
d982d55
e6145bd
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3,35 +3,58 @@ import Popover from "@material-ui/core/Popover" | ||
import { makeStyles } from "@material-ui/core/styles" | ||
import HelpIcon from "@material-ui/icons/HelpOutline" | ||
import OpenInNewIcon from "@material-ui/icons/OpenInNew" | ||
importReact, { createContext, useContext, useState } from "react" | ||
import { Stack } from "../Stack/Stack" | ||
type Icon = typeof HelpIcon | ||
type Size = "small" | "medium" | ||
export interface HelpTooltipProps { | ||
// Useful to test on storybook | ||
open?: boolean | ||
size?: Size | ||
} | ||
const HelpTooltipContext = createContext<{ open: boolean; onClose: () => void } | undefined>(undefined) | ||
const useHelpTooltip = () => { | ||
const helpTooltipContext = useContext(HelpTooltipContext) | ||
if (!helpTooltipContext) { | ||
throw new Error("This hook should be used in side of the HelpTooltipContext.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. ❤️ | ||
} | ||
return helpTooltipContext | ||
} | ||
export const HelpTooltip: React.FC<HelpTooltipProps> = ({ children, open, size = "medium" }) => { | ||
const styles = useStyles({ size }) | ||
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null) | ||
open = open ?? Boolean(anchorEl) | ||
const id = open ? "help-popover" : undefined | ||
const onClose = () => { | ||
setAnchorEl(null) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Seems like when I click to escape the tooltip, regardless of where I click, I am automatically routed to the workspace page. Sometimes I just want to close the tooltip without leaving the list. Could we suppress navigation on close? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I think it is because you are clicking on a workspace row when you click outside of the tooltip. Member
| ||
return ( | ||
<> | ||
<button | ||
aria-describedby={id} | ||
className={styles.button} | ||
onClick={(event) => { | ||
event.stopPropagation() | ||
setAnchorEl(event.currentTarget) | ||
}} | ||
> | ||
<HelpIcon className={styles.icon} /> | ||
</button> | ||
<Popover | ||
classes={{ paper: styles.popoverPaper }} | ||
id={id} | ||
open={open} | ||
anchorEl={anchorEl} | ||
onClose={onClose} | ||
anchorOrigin={{ | ||
vertical: "bottom", | ||
horizontal: "left", | ||
@@ -41,7 +64,7 @@ export const HelpTooltip: React.FC<HelpTooltipProps> = ({ children, open, size = | ||
horizontal: "left", | ||
}} | ||
> | ||
<HelpTooltipContext.Provider value={{ open, onClose }}>{children}</HelpTooltipContext.Provider> | ||
</Popover> | ||
</> | ||
) | ||
@@ -70,6 +93,25 @@ export const HelpTooltipLink: React.FC<{ href: string }> = ({ children, href }) | ||
) | ||
} | ||
export const HelpTooltipAction: React.FC<{ icon: Icon; onClick: () => void }> = ({ children, icon: Icon, onClick }) => { | ||
const styles = useStyles() | ||
const tooltip = useHelpTooltip() | ||
return ( | ||
<button | ||
className={styles.action} | ||
onClick={(event) => { | ||
event.stopPropagation() | ||
onClick() | ||
tooltip.onClose() | ||
}} | ||
> | ||
<Icon className={styles.actionIcon} /> | ||
{children} | ||
</button> | ||
) | ||
} | ||
export const HelpTooltipLinksGroup: React.FC = ({ children }) => { | ||
const styles = useStyles() | ||
@@ -110,11 +152,12 @@ const useStyles = makeStyles((theme) => ({ | ||
padding: 0, | ||
border: 0, | ||
background: "transparent", | ||
color: theme.palette.text.primary, | ||
opacity: 0.5, | ||
cursor: "pointer", | ||
"&:hover": { | ||
opacity: 0.75, | ||
}, | ||
}, | ||
@@ -156,4 +199,22 @@ const useStyles = makeStyles((theme) => ({ | ||
linksGroup: { | ||
marginTop: theme.spacing(2), | ||
}, | ||
action: { | ||
display: "flex", | ||
alignItems: "center", | ||
background: "none", | ||
border: 0, | ||
color: theme.palette.primary.light, | ||
padding: 0, | ||
cursor: "pointer", | ||
fontSize: 14, | ||
}, | ||
actionIcon: { | ||
color: "inherit", | ||
width: 14, | ||
height: 14, | ||
marginRight: theme.spacing(1), | ||
}, | ||
})) |
Uh oh!
There was an error while loading.Please reload this page.