Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
f0ssel merged 6 commits intomainfromf0ssel/disable-cancel
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
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
5 changes: 4 additions & 1 deletionsite/src/pages/WorkspacePage/Workspace.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,12 +55,13 @@ export interface WorkspaceProps {
workspaceErrors: WorkspaceErrors;
buildInfo?: TypesGen.BuildInfoResponse;
sshPrefix?: string;
template?: TypesGen.Template;
template: TypesGen.Template;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why did we change this type?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I noticed it didn't need to be conditional and see those as a liability so I just drive-by fixed it while I was reading the code.

Kira-Pilot and BrunoQuaresma reacted with thumbs up emoji
canRetryDebugMode: boolean;
handleBuildRetry: () => void;
handleBuildRetryDebug: () => void;
buildLogs?: React.ReactNode;
canAutostart: boolean;
isOwner: boolean;
}

/**
Expand DownExpand Up@@ -93,6 +94,7 @@ export const Workspace: FC<WorkspaceProps> = ({
handleBuildRetryDebug,
buildLogs,
canAutostart,
isOwner,
}) => {
const navigate = useNavigate();
const { saveLocal, getLocal } = useLocalStorage();
Expand DownExpand Up@@ -199,6 +201,7 @@ export const Workspace: FC<WorkspaceProps> = ({
isUpdating={isUpdating}
isRestarting={isRestarting}
canUpdateWorkspace={canUpdateWorkspace}
isOwner={isOwner}
/>

<div
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,3 +107,29 @@ export const AlwaysUpdateStopped: Story = {
canChangeVersions: true,
},
};

export const CancelShownForOwner: Story = {
args: {
workspace: {
...Mocks.MockStartingWorkspace,
template_allow_user_cancel_workspace_jobs: false,
},
isOwner: true,
},
};
export const CancelShownForUser: Story = {
args: {
workspace: Mocks.MockStartingWorkspace,
isOwner: false,
},
};

export const CancelHiddenForUser: Story = {
args: {
workspace: {
...Mocks.MockStartingWorkspace,
template_allow_user_cancel_workspace_jobs: false,
},
isOwner: false,
},
};
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,6 +46,7 @@ export interface WorkspaceActionsProps {
children?: ReactNode;
canChangeVersions: boolean;
canRetryDebug: boolean;
isOwner: boolean;
}

export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
Expand All@@ -65,6 +66,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
isRestarting,
canChangeVersions,
canRetryDebug,
isOwner,
}) => {
const { duplicateWorkspace, isDuplicationReady } =
useWorkspaceDuplication(workspace);
Expand All@@ -73,6 +75,9 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
workspace,
canRetryDebug,
);
const showCancel =
canCancel &&
(workspace.template_allow_user_cancel_workspace_jobs || isOwner);

const mustUpdate =
workspaceUpdatePolicy(workspace, canChangeVersions) === "always" &&
Expand DownExpand Up@@ -146,7 +151,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
<Fragment key={action}>{buttonMapping[action]}</Fragment>
))}

{canCancel && <CancelButton handleAction={handleCancel} />}
{showCancel && <CancelButton handleAction={handleCancel} />}

<MoreMenu>
<MoreMenuTrigger>
Expand Down
6 changes: 6 additions & 0 deletionssite/src/pages/WorkspacePage/WorkspaceReadyPage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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;
Expand All@@ -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(),
Expand DownExpand Up@@ -247,6 +252,7 @@ export const WorkspaceReadyPage = ({
)
}
canAutostart={canAutostart}
isOwner={isOwner}
/>

<WorkspaceDeleteDialog
Expand Down
3 changes: 3 additions & 0 deletionssite/src/pages/WorkspacePage/WorkspaceTopbar.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,6 +56,7 @@ export interface WorkspaceProps {
canRetryDebugMode: boolean;
handleBuildRetry: () => void;
handleBuildRetryDebug: () => void;
isOwner: boolean;
}

export const WorkspaceTopbar = (props: WorkspaceProps) => {
Expand All@@ -77,6 +78,7 @@ export const WorkspaceTopbar = (props: WorkspaceProps) => {
canRetryDebugMode,
handleBuildRetry,
handleBuildRetryDebug,
isOwner,
} = props;
const theme = useTheme();

Expand DownExpand Up@@ -265,6 +267,7 @@ export const WorkspaceTopbar = (props: WorkspaceProps) => {
canChangeVersions={canChangeVersions}
isUpdating={isUpdating}
isRestarting={isRestarting}
isOwner={isOwner}
/>
</div>
</Topbar>
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp