8000 fix!: stop workspace before update by johnstcn · Pull Request #18425 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

fix!: stop workspace before update #18425

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 17 commits into from
Jun 23, 2025
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
Prev Previous commit
Next Next commit
reduce button explosion
  • Loading branch information
johnstcn committed Jun 19, 2025
commit da8bd12701a6e16a515460e41feda46f279fe989
4 changes: 2 additions & 2 deletions site/src/modules/workspaces/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import type { Workspace } from "api/typesGenerated";
const actionTypes = [
"start",
"starting",
// Replaces start when an update is available.
// Appears beside start when an update is available.
"updateAndStart",
// Replaces start when an update is required.
"updateAndStartRequireActiveVersion",
"stop",
"stopping",
"restart",
"restarting",
// Replaces restart when an update is available.
// Appears beside restart when an update is available.
"updateAndRestart",
// Replaces restart when an update is required.
"updateAndRestartRequireActiveVersion",
Expand Down
64 changes: 16 additions & 48 deletions site/src/pages/WorkspacePage/WorkspaceActions/Buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,33 @@ export interface ActionButtonProps {
handleAction: (buildParameters?: WorkspaceBuildParameter[]) => void;
disabled?: boolean;
tooltipText?: string;
isRunning?: boolean;
requireActiveVersion?: boolean;
}

export const UpdateAndStartButton: FC<ActionButtonProps> = ({
export const UpdateButton: FC<ActionButtonProps> = ({
handleAction,
loading,
isRunning,
requireActiveVersion,
}) => {
return (
<Tooltip title="Start workspace with the latest template version.">
<Tooltip
title={
requireActiveVersion
? "This template requires automatic updates on workspace startup. Contact your administrator if you want to preserve the template version."
: isRunning
? "Stop workspace and restart it with the latest template version."
: "Start workspace with the latest template version."
}
>
<TopbarButton
disabled={loading}
data-testid="workspace-update-button"
onClick={() => handleAction()}
>
<CirclePlayIcon />
{loading ? <>Updating&hellip;</> : <>Update&hellip;</>}
</TopbarButton>
</Tooltip>
);
};

export const UpdateAndRestartButton: FC<ActionButtonProps> = ({
handleAction,
loading,
}) => {
return (
<Tooltip title="Stop workspace, if running, and restart it with the latest template version.">
<TopbarButton
disabled={loading}
data-testid="workspace-update-and-restart-button"
onClick={() => handleAction()}
>
<RotateCcwIcon />
{loading ? <>Updating&hellip;</> : <>Update and restart&hellip;</>}
{isRunning ? <RotateCcwIcon /> : <CirclePlayIcon />}
{loading ? <>Updating&hellip;</> : <>Update&hellip;</>}
</TopbarButton>
</Tooltip>
);
Expand Down Expand Up @@ -103,19 +97,6 @@ export const StartButton: FC<ActionButtonPropsWithWorkspace> = ({
);
};

export const UpdateAndStartButtonRequireActiveVersion: FC<
ActionButtonProps
> = ({ handleAction }) => {
return (
<Tooltip title="This template requires automatic updates on workspace startup. Contact your administrator if you want to preserve the template version.">
<TopbarButton onClick={() => handleAction()}>
<CirclePlayIcon />
Update and start&hellip;
</TopbarButton>
</Tooltip>
);
};

export const StopButton: FC<ActionButtonProps> = ({
handleAction,
loading,
Expand Down Expand Up @@ -157,19 +138,6 @@ export const RestartButton: FC<ActionButtonPropsWithWorkspace> = ({
);
};

export const UpdateAndRestartButtonRequireActiveVersion: FC<
ActionButtonProps
> = ({ handleAction }) => {
return (
<Tooltip title="This template requires automatic updates on workspace startup. Contact your administrator if you want to preserve the template version.">
<TopbarButton onClick={() => handleAction()}>
<RotateCcwIcon />
Update and restart&hellip;
</TopbarButton>
</Tooltip>
);
};

export const CancelButton: FC<ActionButtonProps> = ({ handleAction }) => {
return (
<TopbarButton onClick={() => handleAction()}>
Expand Down
35 changes: 26 additions & 9 deletions site/src/pages/WorkspacePage/WorkspaceActions/WorkspaceActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ import {
RestartButton,
StartButton,
StopButton,
UpdateAndRestartButton,
UpdateAndRestartButtonRequireActiveVersion,
UpdateAndStartButton,
UpdateAndStartButtonRequireActiveVersion,
UpdateButton,
} from "./Buttons";
import { DebugButton } from "./DebugButton";
import { RetryButton } from "./RetryButton";
Expand Down Expand Up @@ -82,15 +79,35 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({

// A mapping of button type to the corresponding React component
const buttonMapping: Record<ActionType, ReactNode> = {
updateAndStart: <UpdateAndStartButton handleAction={handleUpdate} />,
updateAndStart: (
<UpdateButton
handleAction={handleUpdate}
isRunning={false}
requireActiveVersion={false}
/>
),
updateAndStartRequireActiveVersion: (
<UpdateAndStartButtonRequireActiveVersion handleAction={handleUpdate} />
<UpdateButton
handleAction={handleUpdate}
isRunning={false}
requireActiveVersion={true}
/>
),
updateAndRestart: (
<UpdateButton
handleAction={handleUpdate}
isRunning={true}
requireActiveVersion={false}
/>
),
updateAndRestart: <UpdateAndRestartButton handleAction={handleUpdate} />,
updateAndRestartRequireActiveVersion: (
<UpdateAndRestartButtonRequireActiveVersion handleAction={handleUpdate} />
<UpdateButton
handleAction={handleUpdate}
isRunning={true}
requireActiveVersion={true}
/>
),
updating: <UpdateAndStartButton loading handleAction={handleUpdate} />,
updating: <UpdateButton loading handleAction={handleUpdate} />,
start: (
<StartButton
workspace={workspace}
Expand Down
Loading
0