Skip to content

Commit

Permalink
Add settings bundle and remove application_services for MyUserAccess (#…
Browse files Browse the repository at this point in the history
…1741)

* feat(MyUserAccess): add settings bundle and remove application_services

* test(MyUserAccess): add e2e test to verify Settings card
  • Loading branch information
apinkert authored Jan 14, 2025
1 parent 3a59f8c commit 836d3f4
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 54 deletions.
16 changes: 14 additions & 2 deletions cypress/e2e/my-user-access.cy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
describe('My User Access Landing page', () => {
it('Visit My User Access Landing page', () => {
beforeEach(() => {
cy.login();

cy.visit('/iam/my-user-access');
cy.wait(4000);
});

it('Visit My User Access Landing page', () => {
// check if My User Access heading exists on the page
cy.contains('My User Access').should('exist');
});

describe('Settings and User Access roles', () => {
it('Select the Settings and User Access roles card', () => {
// scroll to bottom of card list to make the settings card visible
cy.get('.rbac-l-myUserAccess-section__cards').scrollTo('bottom');
cy.contains('Settings and User Access').should('exist');
cy.contains('Settings and User Access').click();
// verify the card was selected
cy.contains('Your Settings and User Access roles').should('exist');
});
});
});
2 changes: 1 addition & 1 deletion src/hooks/useBundleApps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DEFAULT_MUA_BUNDLE } from '../utilities/constants';
const useBundleApps = (bundle) => {
const { pathname } = useLocation();
const navigate = useNavigate();
if (typeof bundle !== 'string' || bundle.length === 0 || !['application_services', 'openshift', 'rhel', 'ansible'].includes(bundle)) {
if (typeof bundle !== 'string' || bundle.length === 0 || !['openshift', 'rhel', 'ansible', 'settings'].includes(bundle)) {
bundle = DEFAULT_MUA_BUNDLE;
navigate({ to: pathname, search: `bundle=${bundle}` }, { replace: true });
return [];
Expand Down
22 changes: 13 additions & 9 deletions src/presentational-components/myUserAccess/bundles.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
export const bundleData = [
{
entitlement: 'application_services',
title: 'Application Services',
apps: {
'Streams for Apache Kafka (beta)': '/',
'API Management (beta)': '/',
'Data Science (private beta)': '/',
},
},
{
entitlement: 'openshift',
title: 'OpenShift',
Expand Down Expand Up @@ -35,6 +26,8 @@ export const bundleData = [
repositories: '/content',
provisioning: '/provisioning',
tasks: '/tasks',
ros: '/ros',
'malware detection': '/malware-detection',
},
appsIds: [
'dashboard',
Expand All @@ -52,6 +45,8 @@ export const bundleData = [
'content-sources',
'provisioning',
'tasks',
'ros',
'malware-detection',
],
},
{
Expand All @@ -64,4 +59,13 @@ export const bundleData = [
},
appsIds: ['catalog', 'approval', 'automation-analytics', 'automation-hub'],
},
{
entitlement: 'settings',
title: 'Settings and User Access',
apps: {
rbac: '/rbac',
sources: '/sources',
},
appsIds: ['rbac', 'sources'],
},
];
16 changes: 6 additions & 10 deletions src/smart-components/myUserAccess/MUAContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import messages from '../../Messages';

const MUAContent = ({ entitlements, isOrgAdmin, isUserAccessAdmin }) => {
const intl = useIntl();
const entitledBundles = Object.entries(entitlements).filter(
([entitlement, { is_entitled }]) => is_entitled && entitlement !== 'application_services'
);
const entitledBundles = Object.entries(entitlements).filter(([, { is_entitled }]) => is_entitled);
const { bundle } = useSearchParams('bundle');
const hasAdminAccess = isOrgAdmin || isUserAccessAdmin;

Expand All @@ -32,13 +30,11 @@ const MUAContent = ({ entitlements, isOrgAdmin, isUserAccessAdmin }) => {
</Stack>
</GridItem>
<GridItem className="pf-m-9-col-on-md rbac-l-myUserAccess-section__table">
{bundle !== 'application_services' && (
<Title headingLevel="h3" size="xl">
{intl.formatMessage(hasAdminAccess ? messages.yourRoles : messages.yourPermissions, {
name: bundleData.find(({ entitlement }) => entitlement === bundle)?.title,
})}
</Title>
)}
<Title headingLevel="h3" size="xl">
{intl.formatMessage(hasAdminAccess ? messages.yourRoles : messages.yourPermissions, {
name: bundleData.find(({ entitlement }) => entitlement === bundle)?.title,
})}
</Title>
<MuaBundleRoute />
</GridItem>
</Grid>
Expand Down
1 change: 0 additions & 1 deletion src/smart-components/myUserAccess/MUAHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const MyUserAccess = () => {
}, []);
const enhancedEntitlements = {
...user.entitlements,
application_services: { is_entitled: true, is_trial: false },
};

const entitledBundles = Object.entries(enhancedEntitlements).filter(([, { is_entitled }]) => is_entitled);
Expand Down
30 changes: 0 additions & 30 deletions src/smart-components/myUserAccess/bundles/application_services.js

This file was deleted.

1 change: 1 addition & 0 deletions src/smart-components/myUserAccess/bundles/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './rhel';
2 changes: 1 addition & 1 deletion src/test/hooks/useBundleApps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('useBundleApps', () => {
const { result } = renderHook(() => useBundleApps('rhel'), {
wrapper: MemoryRouter,
});
expect(result.current).toEqual(bundleData[2].appsIds);
expect(result.current).toEqual(bundleData[1].appsIds);
});

it('should retrieve an empty array apps from incorrect bundle', () => {
Expand Down

0 comments on commit 836d3f4

Please sign in to comment.