Skip to content
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
10 changes: 10 additions & 0 deletions site/src/components/Resources/AgentRow.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
MockWorkspace,
MockWorkspaceAgent,
MockWorkspaceAgentConnecting,
MockWorkspaceAgentOutdated,
MockWorkspaceAgentStartError,
MockWorkspaceAgentStarting,
MockWorkspaceAgentStartTimeout,
Expand Down Expand Up @@ -120,3 +121,12 @@ ShowingPortForward.args = {
applicationsHost: "https://coder.com",
showApps: true,
}

export const Outdated = Template.bind({})
Outdated.args = {
agent: MockWorkspaceAgentOutdated,
workspace: MockWorkspace,
applicationsHost: "",
showApps: true,
serverVersion: "v99.999.9999+c1cdf14",
}
8 changes: 7 additions & 1 deletion site/src/components/Resources/AgentRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface AgentRowProps {
hideSSHButton?: boolean
hideVSCodeDesktopButton?: boolean
serverVersion: string
onUpdateAgent: () => void
}

export const AgentRow: FC<AgentRowProps> = ({
Expand All @@ -33,6 +34,7 @@ export const AgentRow: FC<AgentRowProps> = ({
hideSSHButton,
hideVSCodeDesktopButton,
serverVersion,
onUpdateAgent,
}) => {
const styles = useStyles()
const { t } = useTranslation("agent")
Expand Down Expand Up @@ -61,7 +63,11 @@ export const AgentRow: FC<AgentRowProps> = ({
<span className={styles.agentOS}>{agent.operating_system}</span>

<Maybe condition={agent.status === "connected"}>
<AgentVersion agent={agent} serverVersion={serverVersion} />
<AgentVersion
agent={agent}
serverVersion={serverVersion}
onUpdate={onUpdateAgent}
/>
</Maybe>

<AgentLatency agent={agent} />
Expand Down
55 changes: 47 additions & 8 deletions site/src/components/Resources/AgentVersion.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import { useRef, useState, FC } from "react"
import { makeStyles } from "@material-ui/core/styles"
import RefreshIcon from "@material-ui/icons/RefreshOutlined"
import {
HelpTooltipText,
HelpPopover,
HelpTooltipTitle,
HelpTooltipAction,
HelpTooltipLinksGroup,
HelpTooltipContext,
} from "components/Tooltips/HelpTooltip"
import { WorkspaceAgent } from "api/typesGenerated"
import { getDisplayVersionStatus } from "util/workspace"
import { Stack } from "components/Stack/Stack"

export const AgentVersion: FC<{
agent: WorkspaceAgent
serverVersion: string
}> = ({ agent, serverVersion }) => {
onUpdate: () => void
}> = ({ agent, serverVersion, onUpdate }) => {
const styles = useStyles()
const anchorRef = useRef<HTMLButtonElement>(null)
const [isOpen, setIsOpen] = useState(false)
Expand Down Expand Up @@ -44,19 +50,52 @@ export const AgentVersion: FC<{
onOpen={() => setIsOpen(true)}
onClose={() => setIsOpen(false)}
>
<HelpTooltipTitle>Agent Outdated</HelpTooltipTitle>
<HelpTooltipText>
This agent is an older version than the Coder server. This can happen
after you update Coder with running workspaces. To fix this, you can
stop and start the workspace.
</HelpTooltipText>
<HelpTooltipContext.Provider
value={{ open: isOpen, onClose: () => setIsOpen(false) }}
>
<Stack spacing={1}>
<div>
<HelpTooltipTitle>Agent Outdated</HelpTooltipTitle>
<HelpTooltipText>
This agent is an older version than the Coder server. This can
happen after you update Coder with running workspaces. To fix
this, you can stop and start the workspace.
</HelpTooltipText>
Copy link
Member

Choose a reason for hiding this comment

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

We should add a translation.

</div>

<Stack spacing={0.5}>
<span className={styles.versionLabel}>Agent version</span>
<span>{agent.version}</span>
</Stack>

<Stack spacing={0.5}>
<span className={styles.versionLabel}>Server version</span>
<span>{serverVersion}</span>
</Stack>

<HelpTooltipLinksGroup>
<HelpTooltipAction
icon={RefreshIcon}
onClick={onUpdate}
ariaLabel="Update workspace"
>
Update workspace
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a warning that this will restart the workspace and running applications will be terminated? (Or something along those lines.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it is a good idea but I think it is "common sense" that updating something will turn it off. We have other parts on the app we could use this warning to warn users about update actions (or actions that terminate the workspace) so, to make this work worth it, I would wait for users to ask for that.

</HelpTooltipAction>
</HelpTooltipLinksGroup>
</Stack>
</HelpTooltipContext.Provider>
</HelpPopover>
</>
)
}

const useStyles = makeStyles(() => ({
const useStyles = makeStyles((theme) => ({
trigger: {
cursor: "pointer",
},

versionLabel: {
fontWeight: 600,
color: theme.palette.text.primary,
},
}))
3 changes: 3 additions & 0 deletions site/src/components/Resources/ResourceCard.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { action } from "@storybook/addon-actions"
import { Story } from "@storybook/react"
import { MockWorkspace, MockWorkspaceResource } from "testHelpers/entities"
import { AgentRow } from "./AgentRow"
Expand All @@ -21,6 +22,7 @@ Example.args = {
workspace={MockWorkspace}
applicationsHost=""
serverVersion=""
onUpdateAgent={action("updateAgent")}
/>
),
}
Expand Down Expand Up @@ -75,6 +77,7 @@ BunchOfMetadata.args = {
workspace={MockWorkspace}
applicationsHost=""
serverVersion=""
onUpdateAgent={action("updateAgent")}
/>
),
}
2 changes: 1 addition & 1 deletion site/src/components/Tooltips/HelpTooltip/HelpTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const Language = {
ariaLabel: "tooltip",
}

const HelpTooltipContext = createContext<
export const HelpTooltipContext = createContext<
{ open: boolean; onClose: () => void } | undefined
>(undefined)

Expand Down
1 change: 1 addition & 0 deletions site/src/components/Workspace/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
hideSSHButton={hideSSHButton}
hideVSCodeDesktopButton={hideVSCodeDesktopButton}
serverVersion={serverVersion}
onUpdateAgent={handleUpdate} // On updating the workspace the agent version is also updated
/>
)}
/>
Expand Down