Skip to content

Commit

Permalink
STSMACOM-875 Use <IfAnyPermission> and stripes.hasAnyPerm to chec…
Browse files Browse the repository at this point in the history
…k for Notes assign/unassign perm.
  • Loading branch information
BogdanDenis committed Nov 15, 2024
1 parent 96af01a commit 03757f6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
## [9.2.3] IN PROGRESS

* Reset `qindex` once the search field is empty. Fixes STSMACOM-872.
* Use `<IfAnyPermission>` and `stripes.hasAnyPerm` to check for Notes assign/unassign perm. Fixes STSMACOM-875.

## [9.2.0](https://github.com/folio-org/stripes-smart-components/tree/v9.2.0) (2024-10-11)
[Full Changelog](https://github.com/folio-org/stripes-smart-components/compare/v9.1.3...v9.2.0)
Expand Down
7 changes: 4 additions & 3 deletions lib/Notes/NoteViewPage/components/NoteView/NoteView.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import dompurify from 'dompurify';

import {
IfPermission,
IfAnyPermission,
AppIcon,
withStripes,
stripesShape,
Expand Down Expand Up @@ -147,7 +148,7 @@ export default class NoteView extends Component {
} = this.props;


const canAssignUnassign = stripes.hasPerm('ui-notes.item.assign-unassign');
const canAssignUnassign = stripes.hasAnyPerm('ui-notes.item.assign-unassign,ui-notes.item.assign-unassign.execute');
const canDelete = stripes.hasPerm('ui-notes.item.delete');
const canEdit = stripes.hasPerm('ui-notes.item.edit');

Expand All @@ -162,7 +163,7 @@ export default class NoteView extends Component {
<>
{
canUnassign &&
<IfPermission perm="ui-notes.item.assign-unassign">
<IfAnyPermission perm="ui-notes.item.assign-unassign,ui-notes.item.assign-unassign.execute">
<Button
id="note-unassign-button"
buttonStyle="dropdownItem"
Expand All @@ -176,7 +177,7 @@ export default class NoteView extends Component {
<FormattedMessage id="stripes-smart-components.notes.unassign" />
</Icon>
</Button>
</IfPermission>
</IfAnyPermission>
}
<IfPermission perm="ui-notes.item.delete">
<Button
Expand Down
9 changes: 6 additions & 3 deletions lib/Notes/components/NotesAccordion/NotesAccordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { get } from 'lodash';

import { IfPermission } from '@folio/stripes-core';
import {
IfPermission,
IfAnyPermission,
} from '@folio/stripes-core';
import {
Accordion,
Headline,
Expand Down Expand Up @@ -71,15 +74,15 @@ export default class NotesAccordion extends Component {
return (
<>
{!hideAssignButton && (
<IfPermission perm="ui-notes.item.assign-unassign">
<IfAnyPermission perm="ui-notes.item.assign-unassign,ui-notes.item.assign-unassign.execute">
<Button
id="note-assign-button"
onClick={this.onAssignButtonClick}
data-test-notes-accordion-assign-button
>
<FormattedMessage id="stripes-smart-components.assignUnassign" />
</Button>
</IfPermission>
</IfAnyPermission>
)}
{
!hideNewButton && (
Expand Down

0 comments on commit 03757f6

Please sign in to comment.