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

UIU-3105: hide permissionSets from settings/users navigation pane if roles interface is present #2689

Merged
merged 5 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* Show Roles assigned to users. Refs UIU-3110.
* Add edit user roles accordion on edit role modal view. Refs UIU-3021.
* Wire up with API ability to assign/unassign user roles in UserForm. Refs UIU-3124.
* Fix filter issues in user roles modal. Refs UIU-3124.
* Fix filter issues in user roles modal. Refs UIU-3124.
* Suppress Settings > Users > Permission sets when `roles` interface is present. Refs UIU-3105.

## [10.1.0](https://github.com/folio-org/ui-users/tree/v10.1.0) (2024-03-20)
[Full Changelog](https://github.com/folio-org/ui-users/compare/v10.0.4...v10.1.0)
Expand Down
34 changes: 34 additions & 0 deletions src/settings/SettingsComponent.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { cleanup, render } from '@folio/jest-config-stripes/testing-library/react';
import { useStripes } from '@folio/stripes/core';
import Settings from './index';

jest.mock('@folio/stripes/core', () => ({
...jest.requireActual('@folio/stripes/core'),
useStripes: jest.fn(),
}));

jest.mock('./components/SettingsPage', () => () => <div>Settings page</div>);

const renderSettings = (props) => render(<Settings {...props}>Settings content</Settings>);

describe('Settings component', () => {
afterAll(() => {
cleanup();
jest.clearAllMocks();
});
it('renders with roles interface', () => {
useStripes.mockClear().mockReturnValue({ hasInterface: () => true });
const { getByText } = renderSettings({ match:{ path: '' } });

expect(getByText('Settings content')).toBeInTheDocument();
});

it('renders with NO roles interface', () => {
useStripes.mockClear().mockReturnValue({ hasInterface: () => false });
const { getByText } = renderSettings({ match:{ path: '' } });

expect(getByText('Settings content')).toBeInTheDocument();
});
});


11 changes: 10 additions & 1 deletion src/settings/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import React from 'react';
import PropTypes from 'prop-types';

import { useStripes } from '@folio/stripes/core';
import sections from './sections';
import SettingsPage from './components/SettingsPage';

const Settings = ({ children, match }) => {
const { path } = match;
const stripes = useStripes();

const [settingsGeneral, ...otherSections] = sections;

const getSettingSections = () => {
if (!stripes.hasInterface('roles')) return sections;
return [{ ...settingsGeneral, pages:settingsGeneral.pages.filter(page => page.route !== 'perms') }, ...otherSections];
};

return (
<>
<SettingsPage path={path} sections={sections} />
<SettingsPage path={path} sections={getSettingSections()} />
{children}
</>
);
Expand Down
Loading