Skip to content

refactor(site): change a few names related to workspace actions #11079

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 2 commits into from
Dec 8, 2023
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
Change a few names related to workspace actions
  • Loading branch information
BrunoQuaresma committed Dec 7, 2023
commit ae8c67f1f637a057389770b06e6be4508ca94df2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Workspace, WorkspaceBuildParameter } from "api/typesGenerated";
import { useWorkspaceDuplication } from "pages/CreateWorkspacePage/useWorkspaceDuplication";

import { workspaceUpdatePolicy } from "utils/workspace";
import { type ButtonType, actionsByWorkspaceStatus } from "./constants";
import { type ActionType, abilitiesByWorkspaceStatus } from "./constants";

import {
ActionLoadingButton,
Expand Down Expand Up @@ -72,7 +72,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
const { duplicateWorkspace, isDuplicationReady } =
useWorkspaceDuplication(workspace);

const { actions, canCancel, canAcceptJobs } = actionsByWorkspaceStatus(
const { actions, canCancel, canAcceptJobs } = abilitiesByWorkspaceStatus(
workspace,
canRetryDebug,
);
Expand All @@ -85,7 +85,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
const canBeUpdated = workspace.outdated && canAcceptJobs;

// A mapping of button type to the corresponding React component
const buttonMapping: Record<ButtonType, ReactNode> = {
const buttonMapping: Record<ActionType, ReactNode> = {
update: <UpdateButton handleAction={handleUpdate} />,
updating: <UpdateButton loading handleAction={handleUpdate} />,
start: (
Expand Down
13 changes: 5 additions & 8 deletions site/src/pages/WorkspacePage/WorkspaceActions/constants.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type Workspace, type WorkspaceStatus } from "api/typesGenerated";

/**
* An iterable of all button types supported by the workspace actions UI
* An iterable of all action types supported by the workspace UI
*/
export const buttonTypes = [
export const actionTypes = [
"start",
"starting",
"stop",
Expand All @@ -28,18 +28,15 @@ export const buttonTypes = [
"pending",
] as const;

/**
* A button type supported by the workspace actions UI
*/
export type ButtonType = (typeof buttonTypes)[number];
export type ActionType = (typeof actionTypes)[number];

type WorkspaceAbilities = {
actions: readonly ButtonType[];
actions: readonly ActionType[];
canCancel: boolean;
canAcceptJobs: boolean;
};

export const actionsByWorkspaceStatus = (
export const abilitiesByWorkspaceStatus = (
workspace: Workspace,
canRetryDebug: boolean,
): WorkspaceAbilities => {
Expand Down