diff --git a/site/src/pages/WorkspacePage/Workspace.tsx b/site/src/pages/WorkspacePage/Workspace.tsx index e19f485aa903a..43a63db4e694b 100644 --- a/site/src/pages/WorkspacePage/Workspace.tsx +++ b/site/src/pages/WorkspacePage/Workspace.tsx @@ -55,12 +55,13 @@ export interface WorkspaceProps { workspaceErrors: WorkspaceErrors; buildInfo?: TypesGen.BuildInfoResponse; sshPrefix?: string; - template?: TypesGen.Template; + template: TypesGen.Template; canRetryDebugMode: boolean; handleBuildRetry: () => void; handleBuildRetryDebug: () => void; buildLogs?: React.ReactNode; canAutostart: boolean; + isOwner: boolean; } /** @@ -93,6 +94,7 @@ export const Workspace: FC = ({ handleBuildRetryDebug, buildLogs, canAutostart, + isOwner, }) => { const navigate = useNavigate(); const { saveLocal, getLocal } = useLocalStorage(); @@ -199,6 +201,7 @@ export const Workspace: FC = ({ isUpdating={isUpdating} isRestarting={isRestarting} canUpdateWorkspace={canUpdateWorkspace} + isOwner={isOwner} />
= ({ @@ -65,6 +66,7 @@ export const WorkspaceActions: FC = ({ isRestarting, canChangeVersions, canRetryDebug, + isOwner, }) => { const { duplicateWorkspace, isDuplicationReady } = useWorkspaceDuplication(workspace); @@ -73,6 +75,9 @@ export const WorkspaceActions: FC = ({ workspace, canRetryDebug, ); + const showCancel = + canCancel && + (workspace.template_allow_user_cancel_workspace_jobs || isOwner); const mustUpdate = workspaceUpdatePolicy(workspace, canChangeVersions) === "always" && @@ -146,7 +151,7 @@ export const WorkspaceActions: FC = ({ {buttonMapping[action]} ))} - {canCancel && } + {showCancel && } diff --git a/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx b/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx index f267d1689f1fd..c7e284e7bf88e 100644 --- a/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx +++ b/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx @@ -36,6 +36,7 @@ import { WorkspacePermissions } from "./permissions"; import { workspaceResolveAutostart } from "api/queries/workspaceQuota"; import { WorkspaceDeleteDialog } from "./WorkspaceDeleteDialog"; import dayjs from "dayjs"; +import { useMe } from "hooks"; interface WorkspaceReadyPageProps { template: TypesGen.Template; @@ -56,6 +57,10 @@ export const WorkspaceReadyPage = ({ throw Error("Workspace is undefined"); } + // Owner + const me = useMe(); + const isOwner = me.roles.find((role) => role.name === "owner") !== undefined; + // Debug mode const { data: deploymentValues } = useQuery({ ...deploymentConfig(), @@ -247,6 +252,7 @@ export const WorkspaceReadyPage = ({ ) } canAutostart={canAutostart} + isOwner={isOwner} /> void; handleBuildRetryDebug: () => void; + isOwner: boolean; } export const WorkspaceTopbar = (props: WorkspaceProps) => { @@ -77,6 +78,7 @@ export const WorkspaceTopbar = (props: WorkspaceProps) => { canRetryDebugMode, handleBuildRetry, handleBuildRetryDebug, + isOwner, } = props; const theme = useTheme(); @@ -265,6 +267,7 @@ export const WorkspaceTopbar = (props: WorkspaceProps) => { canChangeVersions={canChangeVersions} isUpdating={isUpdating} isRestarting={isRestarting} + isOwner={isOwner} />