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

Conversation

f0ssel
Copy link
Contributor

@f0ssel f0ssel commented Jan 10, 2024

Closes #11449

The user can only cancel under the following circumstances according to the backend:

  1. You have the owner role.
    OR
  2. The template specifies that ANY user can cancel the builds based on it.

Owner View if user cancelation is disabled:
Screenshot 2024-01-10 at 11 42 10 AM

Member View if user cancelation is disabled:
Screenshot 2024-01-10 at 11 41 50 AM

@f0ssel f0ssel marked this pull request as ready for review January 10, 2024 16:27
@f0ssel f0ssel requested a review from BrunoQuaresma January 10, 2024 16:27
@@ -55,7 +55,7 @@ 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
Contributor Author

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.

Copy link
Member

@Kira-Pilot Kira-Pilot left a comment

Choose a reason for hiding this comment

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

Thanks for making this change! Looks good to me.

Can we add a storybook test before we merge it up? Your screenshots would be good test cases.
You'll need to mock the user value the useMe hook returns and the way to do this is to mock out the AuthContext.Provider

Here's an example of how we mock providers in a Storybook file.

As discussed over Slack, we'll need to move this hook invocation up to fix the broken stories. Since you'll be accessing isOwner as a prop, you won't need to mock that auth provider.

@f0ssel f0ssel requested a review from Kira-Pilot January 11, 2024 16:57
Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

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

Looks good!

@f0ssel f0ssel merged commit f9f94b5 into main Jan 11, 2024
@f0ssel f0ssel deleted the f0ssel/disable-cancel branch January 11, 2024 18:48
@github-actions github-actions bot locked and limited conversation to collaborators Jan 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

disable Cancel button entirely for non-Owners
3 participants