Skip to content

Commit b1555df

Browse files
committed
fix: remove cancel button if user cannot cancel job
1 parent 4fa0712 commit b1555df

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

site/src/pages/WorkspacePage/Workspace.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export interface WorkspaceProps {
5555
workspaceErrors: WorkspaceErrors;
5656
buildInfo?: TypesGen.BuildInfoResponse;
5757
sshPrefix?: string;
58-
template?: TypesGen.Template;
58+
template: TypesGen.Template;
5959
canRetryDebugMode: boolean;
6060
handleBuildRetry: () => void;
6161
handleBuildRetryDebug: () => void;

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export interface WorkspaceActionsProps {
4646
children?: ReactNode;
4747
canChangeVersions: boolean;
4848
canRetryDebug: boolean;
49+
templateUserCanCancel: boolean;
4950
}
5051

5152
export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
@@ -65,6 +66,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
6566
isRestarting,
6667
canChangeVersions,
6768
canRetryDebug,
69+
templateUserCanCancel,
6870
}) => {
6971
const { duplicateWorkspace, isDuplicationReady } =
7072
useWorkspaceDuplication(workspace);
@@ -73,6 +75,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
7375
workspace,
7476
canRetryDebug,
7577
);
78+
const cancelEnabled = canCancel && templateUserCanCancel
7679

7780
const mustUpdate =
7881
workspaceUpdatePolicy(workspace, canChangeVersions) === "always" &&
@@ -146,7 +149,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
146149
<Fragment key={action}>{buttonMapping[action]}</Fragment>
147150
))}
148151

149-
{canCancel && <CancelButton handleAction={handleCancel} />}
152+
{cancelEnabled && <CancelButton handleAction={handleCancel} />}
150153

151154
<MoreMenu>
152155
<MoreMenuTrigger>

site/src/pages/WorkspacePage/WorkspaceTopbar.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { Popover, PopoverTrigger } from "components/Popover/Popover";
3030
import { HelpTooltipContent } from "components/HelpTooltip/HelpTooltip";
3131
import { AvatarData } from "components/AvatarData/AvatarData";
3232
import { ExternalAvatar } from "components/Avatar/Avatar";
33+
import { usePermissions } from "hooks";
3334

3435
export type WorkspaceError =
3536
| "getBuildsError"
@@ -79,6 +80,7 @@ export const WorkspaceTopbar = (props: WorkspaceProps) => {
7980
handleBuildRetryDebug,
8081
} = props;
8182
const theme = useTheme();
83+
const permissions = usePermissions();
8284

8385
// Quota
8486
const hasDailyCost = workspace.latest_build.daily_cost > 0;
@@ -265,6 +267,7 @@ export const WorkspaceTopbar = (props: WorkspaceProps) => {
265267
canChangeVersions={canChangeVersions}
266268
isUpdating={isUpdating}
267269
isRestarting={isRestarting}
270+
userCanCancel={permissions.updateTemplates}
268271
/>
269272
</div>
270273
</Topbar>

0 commit comments

Comments
 (0)