Skip to content
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

upcoming: [M3-7775] - Disable ability to edit or delete a proxy user via User Profile page #10202

Conversation

mjac0bs
Copy link
Contributor

@mjac0bs mjac0bs commented Feb 16, 2024

Description 📝

In Cloud Manager, a proxy user cannot be deleted, nor can its email address or username be edited once it is provisioned.

This PR is a follow up from #10103 which restricted proxy users from updating their username or email on the Display Settings page (http://localhost:3000/profile/display). There is one additional place that a proxy user could be edited, which is by visiting the User Profile page for the proxy user via URL. (The User Profile button is not visible for a proxy user on the Users & Grants page, http://localhost:3000/account/users.)

Changes 🔄

List any change relevant to the reviewer.

  • Disables the username and email fields and the buttons on the proxy user's profile. Displays tooltips with reason for disabling.
  • Separates out tests in change-username.spec.ts into two different files: one for the Display Settings section (display-settings.spec.ts) and another for the User Profile page (user-profile.spec.ts). This was suggested a while ago and included in the AC of another ticket in the backlog, but it was cleaner to make the switch now rather than shoehorn additional test coverage into where it didn't really belong.

Preview 📷

Before After
ChildAbleToEditProxyUser.mov
ChildUserTryingToEditProxyAccount.mov
ProxyAbleToEditProxyUser.mov
ProxyTryingToEditItsOwnAccount.mov

How to test 🧪

Prerequisites

(How to setup test environment)

  • Check out this PR and yarn dev.
  • Make sure Parent/Child feature flag and mocks are on.

Reproduction steps

(How to reproduce the issue, if applicable)

Verification steps

(How to verify changes)

  • Change the MSW */profile endpoint to mock the proxy user as the current active user.
const profile = profileFactory.build({
      restricted: false,
      // Parent/Child: switch the `user_type` depending on what account view you need to mock.
      user_type: 'proxy',
      username: 'ParentCompany_a1b2c3d4e5',
    });
const profile = profileFactory.build({
      restricted: false,
      // Parent/Child: switch the `user_type` depending on what account view you need to mock.
      user_type: 'child',
    });
yarn cy:run -s "cypress/e2e/core/account/user-profile.spec.ts, cypress/e2e/core/account/display-settings.spec.ts"

As an Author I have considered 🤔

Check all that apply

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@mjac0bs mjac0bs force-pushed the M3-7775-disable-edits-to-proxy-user-profile-page branch from 7f44e74 to bef3568 Compare February 16, 2024 21:32
@mjac0bs mjac0bs marked this pull request as ready for review February 16, 2024 22:19
@mjac0bs mjac0bs requested review from a team as code owners February 16, 2024 22:19
@mjac0bs mjac0bs requested review from cliu-akamai, cpathipa, abailly-akamai and jaalah-akamai and removed request for a team February 16, 2024 22:19

const [
deleteConfirmDialogOpen,
setDeleteConfirmDialogOpen,
] = React.useState<boolean>(false);

const isProxyUserProfile = currentUser?.user_type === 'proxy';
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Should this be just isProxyUser?

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 used isProxyUserProfile to try to avoid any confusion that the active user is a proxy user -- they don't have to be, just the current user whose profile is being viewed. If it feels more confusing as it currently is, I can change it, but it made more sense in my mind.

isProxyUserProfile
? RESTRICTED_FIELD_TOOLTIP
: profile?.username !== originalUsername
? 'You can\u{2019}t change another user\u{2019}s email address.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'm not too sure I care for escaped characters but that's a preferential choice. Double quotes would work fine here

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. Our IDE may show a squiggly line or something but there is no issue with using plain quotes here and escaping makes finding strings in code harder

Copy link
Contributor Author

@mjac0bs mjac0bs Feb 20, 2024

Choose a reason for hiding this comment

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

This is actually not just for escaping the quote - it's a curly quote, which is a stylistic choice in Cloud Manager. We can revisit with UX whether or not we want to continue to use the curly quote in CM in a cafe, but this change is intended to stay in line with our current standard for the single quote for the new messages and fix any that weren't consistent before.

This is not a very distinction easy to see in this screenshot, but the difference is visible with can't compared to user's:

Prod (straight apostrophe):
Screenshot 2024-02-20 at 9 34 02 AM

This branch (curly apostrophe):
Screenshot 2024-02-20 at 9 34 17 AM

Copy link
Contributor

@jaalah-akamai jaalah-akamai left a comment

Choose a reason for hiding this comment

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

✅ Implementation looks good!

@jaalah-akamai jaalah-akamai added the Add'tl Approval Needed Waiting on another approval! label Feb 17, 2024
Copy link
Contributor

@abailly-akamai abailly-akamai left a comment

Choose a reason for hiding this comment

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

  • UI and code look great ✅
  • Confirmed the inability to delete an account based on the mock data provided in the PR description ✅

Quick question: I am aware "proxy" is a possible technical value for user_type, but are we going to display that to the user??

Screenshot 2024-02-20 at 10 06 28

.should('be.visible');
});
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

isProxyUserProfile
? RESTRICTED_FIELD_TOOLTIP
: profile?.username !== originalUsername
? 'You can\u{2019}t change another user\u{2019}s email address.'
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. Our IDE may show a squiggly line or something but there is no issue with using plain quotes here and escaping makes finding strings in code harder

packages/manager/src/features/Users/UserProfile.tsx Outdated Show resolved Hide resolved
@mjac0bs mjac0bs added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! Ready for Review labels Feb 20, 2024
@mjac0bs
Copy link
Contributor Author

mjac0bs commented Feb 20, 2024

Quick question: I am aware "proxy" is a possible technical value for user_type, but are we going to display that to the user??

@abailly-akamai - Thank you for catching this! Changed it to business partner in cd22592.

Copy link

Coverage Report:
Base Coverage: 81.24%
Current Coverage: 81.24%

@mjac0bs
Copy link
Contributor Author

mjac0bs commented Feb 20, 2024

The one test failure in CI was unrelated.

Screenshot 2024-02-20 at 10 58 18 AM

I'm going to go ahead and merge.

@mjac0bs mjac0bs merged commit 9e03e40 into linode:develop Feb 20, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! Parent / Child Account
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants