-
Notifications
You must be signed in to change notification settings - Fork 367
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
Coverage Report: ✅ |
There was a problem hiding this 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.
There was a problem hiding this 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."
);
});
});
});
3bb571b
to
2ba00bb
Compare
Thanks @dwiley-akamai! I have added the changeset. Can you please check? |
There was a problem hiding this 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 🚀
…pty state Landing Page for restricted users
…ding Page for Restricted Users
555133d
to
bbaa079
Compare
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 🔄
Target release date 🗓️
July 8th, 2024
Preview 📷
How to test 🧪
Prerequisites
(How to setup test environment)
- Start with
Read Only
for everythingReproduction steps
Verification steps
As an Author I have considered 🤔
Check all that apply