Skip to content

Commit

Permalink
UICIRC-1192: Make Consortium title level request settings available o…
Browse files Browse the repository at this point in the history
…nly in Central tenant
  • Loading branch information
Dmitriy-Litvinenko committed Mar 3, 2025
1 parent bcfd88d commit 9341f27
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* *BREAKING* Update stripes-* dependencies to latest version. Refs UICIRC-1176.
* Add seven new item-level tokens to "Pick slip" staff slip. Fixes UICIRC-1169.
* Refactor RulesEditor away from componentWillReceiveProps. Refs UICIRC-431.
* Make `Consortium title level request` settings available only in Central tenant. Refs UICIRC-1192.

## [10.0.1](https://github.com/folio-org/ui-circulation/tree/v10.0.1) (2024-12-04)
[Full Changelog](https://github.com/folio-org/ui-circulation/compare/v10.0.0...v10.0.1)
Expand Down
26 changes: 15 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ class Circulation extends Component {
intl: PropTypes.object.isRequired,
}

constructor(props) {
super(props);
getSections() {
const {
stripes,
} = this.props;
const isEnabledEcsRequests = stripes?.config?.enableEcsRequests;

const isEnabledEcsRequests = props.stripes?.config?.enableEcsRequests;

this.sections = [
const sections = [
{
label: <FormattedMessage id="ui-circulation.settings.index.general" />,
pages: [
Expand Down Expand Up @@ -113,7 +114,7 @@ class Circulation extends Component {
},
{
route: 'patron-notices',
label: this.props.intl.formatMessage({ id: 'ui-circulation.settings.index.patronNotices' }),
label: <FormattedMessage id="ui-circulation.settings.index.patronNotices" />,
component: PatronNotices,
perm: 'ui-circulation.settings.view-notice-templates',
},
Expand Down Expand Up @@ -151,7 +152,7 @@ class Circulation extends Component {
];

if (isEnabledEcsRequests === true) {
this.sections[0].pages.push({
sections[0].pages.push({
route: 'title-level-requests',
label: <FormattedMessage id="ui-circulation.settings.index.titleLevelRequestsTlr" />,
component: TitleLevelRequests,
Expand All @@ -161,30 +162,33 @@ class Circulation extends Component {
route: 'consortium-title-level-requests',
label: <FormattedMessage id="ui-circulation.settings.index.consortiumTLR" />,
component: ConsortiumTLR,
perm: getConsortiumTlrPermission(props.stripes),
perm: getConsortiumTlrPermission(stripes),
});
this.sections[4].pages.splice(2, 0, {
sections[4].pages.splice(2, 0, {
route: 'tlr-patron-notice-templates',
label: <FormattedMessage id="ui-circulation.settings.index.tlrPatronNotices" />,
component: TLRPatronNotices,
perm: 'ui-circulation.settings.view-titleLevelRequests',
});
} else {
this.sections[4].pages.splice(2, 0, {
sections[4].pages.splice(2, 0, {
route: 'title-level-requests',
label: <FormattedMessage id="ui-circulation.settings.index.titleLevelRequests" />,
component: DeprecatedTitleLevelRequests,
perm: 'ui-circulation.settings.view-titleLevelRequests',
});
}

return sections;
}

render() {
return (
<TitleManager page={this.props.intl.formatMessage({ id: 'ui-circulation.settings.title.general' })}>
<Settings
key={getConsortiumTlrPermission(this.props.stripes)}
{...this.props}
sections={this.sections}
sections={this.getSections()}
paneTitle={<FormattedMessage id="ui-circulation.settings.index.paneTitle" />}
/>
</TitleManager>
Expand Down
6 changes: 5 additions & 1 deletion src/settings/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import {
get,
} from 'lodash';

import {
checkIfUserInCentralTenant,
} from '@folio/stripes/core';

export const LAYERS = {
EDIT: 'edit',
CLONE: 'clone',
Expand Down Expand Up @@ -95,7 +99,7 @@ export const getRecordName = ({
};

export const getConsortiumTlrPermission = (stripes) => {
if (stripes.hasInterface('consortia') && stripes.hasInterface('ecs-tlr')) {
if (stripes.hasInterface('consortia') && stripes.hasInterface('ecs-tlr') && checkIfUserInCentralTenant(stripes)) {
return 'tlr.consortium-tlr.view';
}

Expand Down

0 comments on commit 9341f27

Please sign in to comment.