Skip to content

Commit

Permalink
UIU-3021: conditionally show use roles accordion
Browse files Browse the repository at this point in the history
  • Loading branch information
aidynoJ committed Apr 19, 2024
1 parent 2fde36c commit 068b49d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* UX consistency: Use Save & close button label stripes-component translation key. Refs UIU-3078.
* Fix two "triangle down" icons in select element of "Copy existing fee/fine owner table entries" modal. Refs UIU-2929.
* Show Roles assigned to users. Refs UIU-3110.
* Add edit user roles accordion on edit role modal view. Refs UIU-3021.

## [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
13 changes: 7 additions & 6 deletions src/components/EditSections/EditUserRoles/EditUserRoles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { Accordion, Headline, Badge, Row, Col, List, Button, Icon, Loading } fro
import { useIntl, FormattedMessage } from 'react-intl';
import { withRouter } from 'react-router';
import PropTypes from 'prop-types';
import { useStripes } from '@folio/stripes/core';
import { useUserTenantRoles } from '../../../hooks';

function EditUserRoles({ match, accordionId }) {
const userId = match.params.id;

const { okapi } = useStripes();
const intl = useIntl();
const [open, setOpen] = useState(false);

const { userRoles, isLoading } = useUserTenantRoles({ userId, tenantId: 'diku2' });
const userId = match.params.id;

const { userRoles, isLoading } = useUserTenantRoles({ userId, tenantId: okapi.tenant });

const renderRoles = (role) => {
return (
Expand All @@ -36,9 +37,7 @@ function EditUserRoles({ match, accordionId }) {
return (
<Accordion
label={<Headline size="large" tag="h3"><FormattedMessage id="ui-users.roles.userRoles" /></Headline>}
open={open}
id={accordionId}
onToggle={() => { setOpen(!open); }}
displayWhenClosed={isLoading ? <Loading /> : <Badge>{userRoles.length}</Badge>}
>
<Row>
Expand All @@ -49,6 +48,8 @@ function EditUserRoles({ match, accordionId }) {
isEmptyMessage={<FormattedMessage id="ui-users.roles.empty" />}
/>
</Col>
<Button><FormattedMessage id="ui-users.roles.addRoles" /></Button>
<Button><FormattedMessage id="ui-users.roles.unassignAllRoles" /></Button>
</Row>
</Accordion>
);
Expand Down
2 changes: 1 addition & 1 deletion src/views/UserEdit/UserForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class UserForm extends React.Component {
/>
</div>
}
<EditUserRoles accordionId="userRoles" />
{!this.showPermissionsAccordion() && <EditUserRoles accordionId="userRoles" />}
</AccordionSet>
</AccordionStatus>
</Pane>
Expand Down
4 changes: 3 additions & 1 deletion translations/ui-users/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1172,5 +1172,7 @@

"roles.userRoles": "Roles",
"roles.empty": "No roles found",
"roles.deleteRole": "Delete user role"
"roles.deleteRole": "Delete user role",
"roles.addRoles": "Add roles",
"roles.unassignAllRoles": "Unassign all roles"
}

0 comments on commit 068b49d

Please sign in to comment.