Skip to content

fix: remove cancel button if user cannot cancel job #11553

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 6 commits into from
Jan 11, 2024
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
sync with backend logic
  • Loading branch information
f0ssel committed Jan 10, 2024
commit 98f1c4b8681f25f1e64bced124383384702f1084
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from "components/MoreMenu/MoreMenu";
import { TopbarIconButton } from "components/FullPageLayout/Topbar";
import MoreVertOutlined from "@mui/icons-material/MoreVertOutlined";
import { useMe } from "hooks";

export interface WorkspaceActionsProps {
workspace: Workspace;
Expand All @@ -46,7 +47,6 @@ export interface WorkspaceActionsProps {
children?: ReactNode;
canChangeVersions: boolean;
canRetryDebug: boolean;
templateUserCanCancel: boolean;
}

export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
Expand All @@ -66,16 +66,18 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
isRestarting,
canChangeVersions,
canRetryDebug,
templateUserCanCancel,
}) => {
const me = useMe();
const isOwner = me.roles.find((role) => role.name === "owner");

const { duplicateWorkspace, isDuplicationReady } =
useWorkspaceDuplication(workspace);

const { actions, canCancel, canAcceptJobs } = abilitiesByWorkspaceStatus(
workspace,
canRetryDebug,
);
const cancelEnabled = canCancel && templateUserCanCancel
const cancelEnabled = canCancel || isOwner

const mustUpdate =
workspaceUpdatePolicy(workspace, canChangeVersions) === "always" &&
Expand Down
3 changes: 0 additions & 3 deletions site/src/pages/WorkspacePage/WorkspaceTopbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { Popover, PopoverTrigger } from "components/Popover/Popover";
import { HelpTooltipContent } from "components/HelpTooltip/HelpTooltip";
import { AvatarData } from "components/AvatarData/AvatarData";
import { ExternalAvatar } from "components/Avatar/Avatar";
import { usePermissions } from "hooks";

export type WorkspaceError =
| "getBuildsError"
Expand Down Expand Up @@ -80,7 +79,6 @@ export const WorkspaceTopbar = (props: WorkspaceProps) => {
handleBuildRetryDebug,
} = props;
const theme = useTheme();
const permissions = usePermissions();

// Quota
const hasDailyCost = workspace.latest_build.daily_cost > 0;
Expand Down Expand Up @@ -267,7 +265,6 @@ export const WorkspaceTopbar = (props: WorkspaceProps) => {
canChangeVersions={canChangeVersions}
isUpdating={isUpdating}
isRestarting={isRestarting}
userCanCancel={permissions.updateTemplates}
/>
</div>
</Topbar>
Expand Down