Skip to content

Commit 2c7394b

Browse files
refactor(site): change a few names related to workspace actions (#11079)
1 parent 2b19a23 commit 2c7394b

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

site/src/pages/WorkspacePage/WorkspaceActions/WorkspaceActions.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Workspace, WorkspaceBuildParameter } from "api/typesGenerated";
33
import { useWorkspaceDuplication } from "pages/CreateWorkspacePage/useWorkspaceDuplication";
44

55
import { workspaceUpdatePolicy } from "utils/workspace";
6-
import { type ButtonType, actionsByWorkspaceStatus } from "./constants";
6+
import { type ActionType, abilitiesByWorkspaceStatus } from "./constants";
77

88
import {
99
ActionLoadingButton,
@@ -72,7 +72,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
7272
const { duplicateWorkspace, isDuplicationReady } =
7373
useWorkspaceDuplication(workspace);
7474

75-
const { actions, canCancel, canAcceptJobs } = actionsByWorkspaceStatus(
75+
const { actions, canCancel, canAcceptJobs } = abilitiesByWorkspaceStatus(
7676
workspace,
7777
canRetryDebug,
7878
);
@@ -85,7 +85,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
8585
const canBeUpdated = workspace.outdated && canAcceptJobs;
8686

8787
// A mapping of button type to the corresponding React component
88-
const buttonMapping: Record<ButtonType, ReactNode> = {
88+
const buttonMapping: Record<ActionType, ReactNode> = {
8989
update: <UpdateButton handleAction={handleUpdate} />,
9090
updating: <UpdateButton loading handleAction={handleUpdate} />,
9191
start: (

site/src/pages/WorkspacePage/WorkspaceActions/constants.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { type Workspace, type WorkspaceStatus } from "api/typesGenerated";
22

33
/**
4-
* An iterable of all button types supported by the workspace actions UI
4+
* An iterable of all action types supported by the workspace UI
55
*/
6-
export const buttonTypes = [
6+
export const actionTypes = [
77
"start",
88
"starting",
99
"stop",
@@ -28,18 +28,15 @@ export const buttonTypes = [
2828
"pending",
2929
] as const;
3030

31-
/**
32-
* A button type supported by the workspace actions UI
33-
*/
34-
export type ButtonType = (typeof buttonTypes)[number];
31+
export type ActionType = (typeof actionTypes)[number];
3532

3633
type WorkspaceAbilities = {
37-
actions: readonly ButtonType[];
34+
actions: readonly ActionType[];
3835
canCancel: boolean;
3936
canAcceptJobs: boolean;
4037
};
4138

42-
export const actionsByWorkspaceStatus = (
39+
export const abilitiesByWorkspaceStatus = (
4340
workspace: Workspace,
4441
canRetryDebug: boolean,
4542
): WorkspaceAbilities => {
@@ -54,15 +51,15 @@ export const actionsByWorkspaceStatus = (
5451
const status = workspace.latest_build.status;
5552
if (status === "failed" && canRetryDebug) {
5653
return {
57-
...statusToActions.failed,
54+
...statusToAbility.failed,
5855
actions: ["retry", "retryDebug"],
5956
};
6057
}
6158

62-
return statusToActions[status];
59+
return statusToAbility[status];
6360
};
6461

65-
const statusToActions: Record<WorkspaceStatus, WorkspaceAbilities> = {
62+
const statusToAbility: Record<WorkspaceStatus, WorkspaceAbilities> = {
6663
starting: {
6764
actions: ["starting"],
6865
canCancel: true,

0 commit comments

Comments
 (0)