Skip to content

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add version tooltup
  • Loading branch information
BrunoQuaresma committed Jun 13, 2022
commit e5cbcd85b967d3b37cda8a938cc0a7fe2d194206
38 changes: 35 additions & 3 deletions site/src/components/HelpTooltip/HelpTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ 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"
import { useState } from "react"
import React, { useState } from "react"
import { Stack } from "../Stack/Stack"

type Icon = typeof HelpIcon

type Size = "small" | "medium"
export interface HelpTooltipProps {
// Useful to test on storybook
Expand Down Expand Up @@ -70,6 +72,17 @@ 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()

return (
<button className={styles.action} onClick={onClick}>
<Icon className={styles.actionIcon} />
{children}
</button>
)
}

export const HelpTooltipLinksGroup: React.FC = ({ children }) => {
const styles = useStyles()

Expand Down Expand Up @@ -110,11 +123,12 @@ const useStyles = makeStyles((theme) => ({
padding: 0,
border: 0,
background: "transparent",
color: theme.palette.text.secondary,
color: theme.palette.text.primary,
opacity: 0.5,
cursor: "pointer",

"&:hover": {
color: theme.palette.text.primary,
opacity: 0.75,
},
},

Expand Down Expand Up @@ -156,4 +170,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),
},
}))
7 changes: 7 additions & 0 deletions site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ const Template: Story<WorkspacesPageViewProps> = (args) => <WorkspacesPageView {
const createWorkspaceWithStatus = (
status: ProvisionerJobStatus,
transition: WorkspaceTransition = "start",
outdated = false,
): Workspace => {
return {
...MockWorkspace,
outdated,
latest_build: {
...MockWorkspace.latest_build,
transition,
Expand Down Expand Up @@ -49,6 +51,11 @@ AllStates.args = {
],
}

export const Outdated = Template.bind({})
Outdated.args = {
workspaces: [createWorkspaceWithStatus("running", "stop", true)],
}

export const OwnerHasNoWorkspaces = Template.bind({})
OwnerHasNoWorkspaces.args = {
workspaces: [],
Expand Down
38 changes: 36 additions & 2 deletions site/src/pages/WorkspacesPage/WorkspacesPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import TableRow from "@material-ui/core/TableRow"
import TextField from "@material-ui/core/TextField"
import AddCircleOutline from "@material-ui/icons/AddCircleOutline"
import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight"
import RefreshIcon from "@material-ui/icons/Refresh"
import SearchIcon from "@material-ui/icons/Search"
import useTheme from "@material-ui/styles/useTheme"
import dayjs from "dayjs"
Expand All @@ -26,6 +27,7 @@ import { CloseDropdown, OpenDropdown } from "../../components/DropdownArrows/Dro
import { EmptyState } from "../../components/EmptyState/EmptyState"
import {
HelpTooltip,
HelpTooltipAction,
HelpTooltipLink,
HelpTooltipLinksGroup,
HelpTooltipText,
Expand Down Expand Up @@ -54,6 +56,11 @@ export const Language = {
workspaceTooltipLink1: "Create workspaces",
workspaceTooltipLink2: "Connect with SSH",
workspaceTooltipLink3: "Editors and IDEs",
outdatedLabel: "Outdated",
upToDateLabel: "Up to date",
versionTooltipText:
"Looks like the version you are using for this workspace is outdated and there is a newest version that you could use.",
updateVersionLabel: "Update version",
}

const WorkspaceHelpTooltip: React.FC = () => {
Expand All @@ -76,6 +83,20 @@ const WorkspaceHelpTooltip: React.FC = () => {
)
}

const OutdatedHelpTooltip: React.FC<{ onUpdateVersion: () => void }> = ({ onUpdateVersion }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file is getting really big.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is but, for now, I think it is ok. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can leave it for now. I want to talk about directory structure at the next FE Variety - maybe we can look at pulling stuff apart then.

return (
<HelpTooltip size="small">
<HelpTooltipTitle>{Language.outdatedLabel}</HelpTooltipTitle>
<HelpTooltipText>{Language.versionTooltipText}</HelpTooltipText>
<HelpTooltipLinksGroup>
<HelpTooltipAction icon={RefreshIcon} onClick={onUpdateVersion}>
{Language.updateVersionLabel}
</HelpTooltipAction>
</HelpTooltipLinksGroup>
</HelpTooltip>
)
}

interface FilterFormValues {
query: string
}
Expand Down Expand Up @@ -256,9 +277,16 @@ export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, works
<TableCell>{workspace.template_name}</TableCell>
<TableCell>
{workspace.outdated ? (
<span style={{ color: theme.palette.error.main }}>outdated</span>
<span className={styles.outdatedLabel}>
{Language.outdatedLabel}
<OutdatedHelpTooltip
onUpdateVersion={() => {
console.log("UPDATE!!")
}}
/>
</span>
) : (
<span style={{ color: theme.palette.text.secondary }}>up to date</span>
<span style={{ color: theme.palette.text.secondary }}>{Language.upToDateLabel}</span>
)}
</TableCell>
<TableCell>
Expand Down Expand Up @@ -341,4 +369,10 @@ const useStyles = makeStyles((theme) => ({
arrowCell: {
display: "flex",
},
outdatedLabel: {
color: theme.palette.error.main,
display: "flex",
alignItems: "center",
gap: theme.spacing(0.5),
},
}))