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

feat: [M3-7684] - Disable Create Volume button with tooltiptext on 'Empty State Landing Page' for Restricted Users #10630

Conversation

pmakode-akamai
Copy link
Contributor

@pmakode-akamai pmakode-akamai commented Jul 1, 2024

Description 📝

To prevent unauthorized access to specific flows and provide clearer guidance, we aim to restrict entry to users without the required permissions.

Here, we are restricting users from creating new Volume from the Empty State Landing Page when they do not have access or have read-only access.

Changes 🔄

  • For restricted users:
    • Disabled Create Volume Button on the Empty State Landing Page

Target release date 🗓️

July 8th, 2024

Preview 📷

Before After
Screenshot 2024-07-01 at 9 23 51 PM Screenshot 2024-07-01 at 9 30 01 PM

How to test 🧪

Prerequisites

(How to setup test environment)

  • Log into two accounts side by side:
    • An unrestricted admin user account: full access
    • A restricted user account (use Incognito for this)
      - Start with Read Only for everything

Reproduction steps

  • Landing:
    • Observe as restricted user, notice shows and you cannot create Volumes

Verification steps

  • After changes, observe tooltips are tailored to the action.

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

@pmakode-akamai pmakode-akamai requested a review from a team as a code owner July 1, 2024 16:39
@pmakode-akamai pmakode-akamai requested review from bnussman-akamai and carrillo-erik and removed request for a team July 1, 2024 16:39
Copy link

github-actions bot commented Jul 1, 2024

Coverage Report:
Base Coverage: 82.18%
Current Coverage: 82.18%

@bnussman-akamai bnussman-akamai added the Volumes Relating to Volumes (aka Block Storage) label Jul 1, 2024
@dwiley-akamai dwiley-akamai self-requested a review July 1, 2024 19:02
Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

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

Congrats on opening your first PR for CM @pmakode-akamai! 🎉 (edit: oh, technically your second 😆)

"Create Volume" button on Volumes landing page is disabled for restricted users without the appropriate permission, and the appropriate tooltip shows up ✅

Can you add a changeset for these changes? Our CONTRIBUTING.md doc explains how to do it here in step 7.

Copy link
Member

@bnussman-akamai bnussman-akamai 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!

Here's an example of a unit test we could write to check for this new feature

Unit Test Example
import { waitFor } from '@testing-library/react';
import React from 'react';

import { grantsFactory, profileFactory } from 'src/factories';
import { makeResourcePage } from 'src/mocks/serverHandlers';
import { HttpResponse, http, server } from 'src/mocks/testServer';
import { renderWithTheme } from 'src/utilities/testHelpers';

import { VolumesLandingEmptyState } from './VolumesLandingEmptyState';

describe('VolumesLandingEmptyState', () => {
  it('disables the create button if the user does not have permission to create volumes', async () => {
    server.use(
      http.get('*/v4/profile', () => {
        const profile = profileFactory.build({ restricted: true });
        return HttpResponse.json(profile);
      }),
      http.get('*/v4/profile/grants', () => {
        const grants = grantsFactory.build({ global: { add_volumes: false } });
        return HttpResponse.json(grants);
      }),
      http.get('*/v4/volumes', () => {
        return HttpResponse.json(makeResourcePage([]));
      })
    );

    const { getByText } = renderWithTheme(<VolumesLandingEmptyState />);

    await waitFor(() => {
      const createVolumeButton = getByText('Create Volume').closest('button');

      expect(createVolumeButton).toBeDisabled();
      expect(createVolumeButton).toHaveAttribute(
        'data-qa-tooltip',
        "You don't have permissions to create Volumes. Please contact your account administrator to request the necessary permissions."
      );
    });
  });
});

@pmakode-akamai pmakode-akamai force-pushed the M3-7684-disable-empty-state-landing-page-create-volume-btn-for-restricted-users branch from 3bb571b to 2ba00bb Compare July 2, 2024 06:15
@pmakode-akamai
Copy link
Contributor Author

Congrats on opening your first PR for CM @pmakode-akamai! 🎉 (edit: oh, technically your second 😆)

"Create Volume" button on Volumes landing page is disabled for restricted users without the appropriate permission, and the appropriate tooltip shows up ✅

Can you add a changeset for these changes? Our CONTRIBUTING.md doc explains how to do it here in step 7.

Thanks @dwiley-akamai! I have added the changeset. Can you please check?

Copy link
Contributor

@dwiley-akamai dwiley-akamai 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 adding the changeset! I left a couple of comments on it, I think it'd be more accurate to consider this a change rather than an addition but things look good otherwise 🚀

@pmakode-akamai pmakode-akamai force-pushed the M3-7684-disable-empty-state-landing-page-create-volume-btn-for-restricted-users branch from 555133d to bbaa079 Compare July 2, 2024 14:56
@jaalah-akamai jaalah-akamai added Approved Multiple approvals and ready to merge! Restricted User Access Improve UX surrounding restricted access to features labels Jul 2, 2024
@pmakode-akamai pmakode-akamai merged commit 7bfb9d5 into linode:develop Jul 4, 2024
19 checks passed
@harsh-akamai harsh-akamai changed the title feat: [M3-7684] - Disable Create Volume button with tooltiptext on 'Empty State Landing Page' for Restricted Users feat: [M3-7684] - Disable Create Image button with tooltiptext on 'Empty State Landing Page' for Restricted Users Jul 11, 2024
@harsh-akamai harsh-akamai changed the title feat: [M3-7684] - Disable Create Image button with tooltiptext on 'Empty State Landing Page' for Restricted Users feat: [M3-7684] - Disable Create Volume button with tooltiptext on 'Empty State Landing Page' for Restricted Users Jul 11, 2024
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! Restricted User Access Improve UX surrounding restricted access to features Volumes Relating to Volumes (aka Block Storage)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants