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-7455] - Add child account access column and disable button when account has child accounts #10012

Closed
wants to merge 21 commits into from
Closed

upcoming: [M3-7455] - Add child account access column and disable button when account has child accounts #10012

wants to merge 21 commits into from

Conversation

tyler-akamai
Copy link
Contributor

@tyler-akamai tyler-akamai commented Dec 20, 2023

Description 📝

Add child account access column and disable button when account has child accounts.

Changes 🔄

List any change relevant to the reviewer.

  • Add child account access column
  • Disable button when account has child accounts

Preview 📷

Before After
Screenshot 2023-12-27 at 3 29 43 PM Screenshot 2023-12-27 at 3 45 56 PM
Screenshot 2023-12-27 at 3 30 15 PM Screenshot 2023-12-27 at 3 30 45 PM

How to test 🧪

Prerequisites

  • MSW on
  • Parent/Child Account flag on

Verification steps

  • Navigate to http://localhost:3000/account/users and ensure there is an additional 'Child Account Access' column with accurate labels ('Enabled' and 'Disabled')
  • Navigate to http://localhost:3000/account/settings and ensure the button is disabled since the current account has a child account, and ensure there is a notice explaining why it is disabled.
  • Ensure the parent/child feature flag works as expected

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


import CloseAccountDialog from './CloseAccountDialog';

const CloseAccountSetting = () => {
const [dialogOpen, setDialogOpen] = React.useState<boolean>(false);

const { data: childAccounts } = useChildAccounts({});
const flags = useFlags();
const closeAccountDisabled = flags.parentChildAccountAccess
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the current account has child accounts, disable the 'Close Account' button

Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to simplify this:
const closeAccountDisabled = flags.parentChildAccountAccess && Boolean(childAccounts?.data?.length);

return (
<>
<Accordion defaultExpanded={true} heading="Close Account">
<Grid container direction="column">
<Grid>
<Button buttonType="outlined" onClick={() => setDialogOpen(true)}>
{closeAccountDisabled && (
<Notice spacingBottom={20} variant="info">
Copy link
Contributor Author

@tyler-akamai tyler-akamai Dec 27, 2023

Choose a reason for hiding this comment

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

This was not in the mocks but we should tell the user why the button is disabled. I can run this by the UI team.

I tried to keep this consistent with the 'Backup Auto Enrollment' Section:
Screenshot 2023-12-27 at 3 42 03 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this is a good call. Exact copy TBD - I know you reached out to Magda; we can be sure to get a response from her or Jan on that, whether it's finalized in this ticket or a follow up for copy changes.

@tyler-akamai tyler-akamai marked this pull request as ready for review December 29, 2023 19:33
@tyler-akamai tyler-akamai requested a review from a team as a code owner December 29, 2023 19:33
@tyler-akamai tyler-akamai requested review from mjac0bs and abailly-akamai and removed request for a team December 29, 2023 19:33
Copy link
Contributor

@mjac0bs mjac0bs left a comment

Choose a reason for hiding this comment

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

Nice! Just some minor things here. If there's any outstanding feedback you don't get to, I can pick this up.

✅ Unit tests are passing 🎉
✅ Ensured there is an additional 'Child Account Access' column with accurate labels ('Enabled' and 'Disabled')
✅ Ensured the Close Account button is disabled since the current account has a child account, and ensure there is a notice explaining why it is disabled.
✅ Ensured the Close Account button is enabled if the current account does not have any child accounts.
Ensure the parent/child feature flag works as expected

  • See the comment in UserRow.tsx for a crash fix.

packages/manager/src/features/Users/UserRow.test.tsx Outdated Show resolved Hide resolved
packages/manager/src/features/Users/UserRow.test.tsx Outdated Show resolved Hide resolved
packages/manager/src/features/Users/UserRow.test.tsx Outdated Show resolved Hide resolved
return (
<>
<Accordion defaultExpanded={true} heading="Close Account">
<Grid container direction="column">
<Grid>
<Button buttonType="outlined" onClick={() => setDialogOpen(true)}>
{closeAccountDisabled && (
<Notice spacingBottom={20} variant="info">
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this is a good call. Exact copy TBD - I know you reached out to Magda; we can be sure to get a response from her or Jan on that, whether it's finalized in this ticket or a follow up for copy changes.

packages/manager/src/features/Users/UserRow.tsx Outdated Show resolved Hide resolved
packages/manager/src/features/Users/UserRow.test.tsx Outdated Show resolved Hide resolved

import CloseAccountDialog from './CloseAccountDialog';

const CloseAccountSetting = () => {
const [dialogOpen, setDialogOpen] = React.useState<boolean>(false);

const { data: childAccounts } = useChildAccounts({});
const flags = useFlags();
const closeAccountDisabled = flags.parentChildAccountAccess
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to simplify this:
const closeAccountDisabled = flags.parentChildAccountAccess && Boolean(childAccounts?.data?.length);

@@ -36,6 +40,11 @@ export const UserRow = ({ onDelete, user }: Props) => {
<TableCell>{user.email}</TableCell>
</Hidden>
<TableCell>{user.restricted ? 'Limited' : 'Full'}</TableCell>
{flags.parentChildAccountAccess && (
Copy link
Contributor

Choose a reason for hiding this comment

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

We should provide a better check here as opposed to just relying on the feature flag, since that will disappear in the future and this entire column will be conditionally rendered.

packages/manager/src/features/Users/UsersLanding.tsx Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jan 2, 2024

Coverage Report:
Base Coverage: 79.25%
Current Coverage: 79.25%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants