diff --git a/CHANGELOG.md b/CHANGELOG.md index 83f862655..a2c14eff3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 10.1.0 IN PROGRESS * React v19: refactor away from default props for functional components. Refs UICIRC-1080. +* Remove feature toggle. Refs UICIRC-1125. ## [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) diff --git a/src/deprecated/settings/TitleLevelRequests/TitleLevelRequests.js b/src/deprecated/settings/TitleLevelRequests/TitleLevelRequests.js deleted file mode 100644 index 1942687d2..000000000 --- a/src/deprecated/settings/TitleLevelRequests/TitleLevelRequests.js +++ /dev/null @@ -1,58 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { injectIntl } from 'react-intl'; - -import { ConfigManager } from '@folio/stripes/smart-components'; -import { - withStripes, - TitleManager, -} from '@folio/stripes/core'; - -import TitleLevelRequestsForm from './TitleLevelRequestsForm'; -import { - getInitialValues, - normalizeData, -} from './utils'; -import { - MODULE_NAMES, -} from '../../../constants'; - -export const CONFIG_NAMES = { - TLR: 'TLR', - PRINT_HOLD_REQUESTS: 'PRINT_HOLD_REQUESTS', -}; - -const TitleLevelRequests = ({ - stripes, - intl: { - formatMessage, - }, -}) => { - const ConnectedConfigManager = stripes.connect(ConfigManager); - - return ( - - - - ); -}; - -TitleLevelRequests.propTypes = { - stripes: PropTypes.shape({ - connect: PropTypes.func.isRequired, - }).isRequired, - intl: PropTypes.object.isRequired, -}; - -export default withStripes(injectIntl(TitleLevelRequests)); diff --git a/src/deprecated/settings/TitleLevelRequests/TitleLevelRequests.test.js b/src/deprecated/settings/TitleLevelRequests/TitleLevelRequests.test.js deleted file mode 100644 index ba6411f00..000000000 --- a/src/deprecated/settings/TitleLevelRequests/TitleLevelRequests.test.js +++ /dev/null @@ -1,68 +0,0 @@ -import { - render, -} from '@folio/jest-config-stripes/testing-library/react'; -import { ConfigManager } from '@folio/stripes/smart-components'; -import { TitleManager } from '@folio/stripes/core'; - -import TitleLevelRequests, { - CONFIG_NAMES, -} from './TitleLevelRequests'; -import TitleLevelRequestsForm from './TitleLevelRequestsForm'; -import { - getInitialValues, - normalizeData, -} from './utils'; -import { - MODULE_NAMES, -} from '../../../constants'; - -describe('deprecated TitleLevelRequests', () => { - const paneTitleLabelId = 'ui-circulation.settings.titleLevelRequests.paneTitle'; - const mockedStripes = { - connect: jest.fn((component) => component), - }; - const labelIds = { - generalTitle: 'ui-circulation.settings.title.general', - titleLevelRequestsTitle: 'ui-circulation.settings.title.titleLevelRequests', - }; - - beforeEach(() => { - render( - - ); - }); - - afterEach(() => { - ConfigManager.mockClear(); - mockedStripes.connect.mockClear(); - }); - - it('should connect "ConfigManager" to stripes', () => { - expect(mockedStripes.connect).toHaveBeenLastCalledWith(ConfigManager); - }); - - it('should execute "ConfigManager" with passed props', () => { - const expectedResult = { - label: paneTitleLabelId, - moduleName: MODULE_NAMES.SETTINGS, - configName: CONFIG_NAMES.TLR, - configFormComponent: TitleLevelRequestsForm, - stripes: mockedStripes, - getInitialValues, - onBeforeSave: normalizeData, - }; - - expect(ConfigManager).toHaveBeenLastCalledWith(expectedResult, {}); - }); - - it('should trigger TitleManager with correct props', () => { - const expectedProps = { - page: labelIds.generalTitle, - record: labelIds.titleLevelRequestsTitle, - }; - - expect(TitleManager).toHaveBeenCalledWith(expect.objectContaining(expectedProps), {}); - }); -}); diff --git a/src/deprecated/settings/TitleLevelRequests/TitleLevelRequestsForm.css b/src/deprecated/settings/TitleLevelRequests/TitleLevelRequestsForm.css deleted file mode 100644 index db366aa9c..000000000 --- a/src/deprecated/settings/TitleLevelRequests/TitleLevelRequestsForm.css +++ /dev/null @@ -1,7 +0,0 @@ -.titleLevelRequestsForm { - height: 100%; -} - -.tlrSettings { - margin: 1.5em 0 2em; -} diff --git a/src/deprecated/settings/TitleLevelRequests/TitleLevelRequestsForm.js b/src/deprecated/settings/TitleLevelRequests/TitleLevelRequestsForm.js deleted file mode 100644 index abeec08db..000000000 --- a/src/deprecated/settings/TitleLevelRequests/TitleLevelRequestsForm.js +++ /dev/null @@ -1,212 +0,0 @@ -import React, { useState } from 'react'; -import PropTypes from 'prop-types'; -import { injectIntl } from 'react-intl'; - -import { Field } from 'react-final-form'; - -import stripesFinalForm from '@folio/stripes/final-form'; -import { stripesConnect } from '@folio/stripes/core'; -import { - Button, - Checkbox, - Col, - Pane, - Row, - PaneFooter, - Modal, -} from '@folio/stripes/components'; - -import NoticeTemplates from '../../../settings/TLRPatronNotices/NoticeTemplates'; -import { - patronNoticeCategoryIds, - MAX_UNPAGED_RESOURCE_COUNT, - TITLE_LEVEL_REQUESTS, - OPEN_REQUESTS_STATUSES, - REQUEST_LEVEL, -} from '../../../constants'; - -import css from './TitleLevelRequestsForm.css'; - -const statusesQueryPart = OPEN_REQUESTS_STATUSES.map(status => `status=="${status}"`).join(' OR '); - -const TitleLevelRequestsForm = (props) => { - const { - handleSubmit, - intl: { formatMessage }, - label, - pristine, - submitting, - form, - resources, - mutator, - } = props; - - const [isErrorModalOpen, setIsErrorModalOpen] = useState(false); - const templates = resources.templates?.records || []; - const { values: titleLevelRequestsValues } = form.getState(); - - const renderFooter = () => ( - - {formatMessage({ id: 'stripes-core.button.save' })} - - )} - /> - ); - - const handleTlrCheckboxClick = async () => { - if (!titleLevelRequestsValues[TITLE_LEVEL_REQUESTS.TLR_ENABLED]) { - form.change(TITLE_LEVEL_REQUESTS.TLR_ENABLED, true); - - return; - } - - const activeTitleRequests = await mutator.requests.GET(); - - if (activeTitleRequests.length) { - setIsErrorModalOpen(true); - - return; - } - - form.change(TITLE_LEVEL_REQUESTS.TLR_ENABLED, false); - }; - - const handleModalClose = () => setIsErrorModalOpen(false); - - const modalFooter = ( - - ); - - return ( -
- - - - - - - { - titleLevelRequestsValues[TITLE_LEVEL_REQUESTS.TLR_ENABLED] && - <> -
- - -
-
- -
- - } - - {formatMessage({ id: 'ui-circulation.settings.titleLevelRequests.forbiddenDisableTlrModal.description' })} - -
-
- ); -}; - -TitleLevelRequestsForm.manifest = Object.freeze({ - templates: { - type: 'okapi', - path: 'templates', - records: 'templates', - params: { - query: `cql.allRecords=1 AND category="${patronNoticeCategoryIds.REQUEST}" AND active="true"`, - }, - perRequest: MAX_UNPAGED_RESOURCE_COUNT, - }, - requests: { - type: 'okapi', - path: 'circulation/requests', - records: 'requests', - accumulate: true, - fetch: false, - params: { - query: `${statusesQueryPart} AND requestLevel=="${REQUEST_LEVEL.TITLE}"`, - limit: '1', - }, - }, -}); - -TitleLevelRequestsForm.propTypes = { - handleSubmit: PropTypes.func.isRequired, - intl: PropTypes.object.isRequired, - label: PropTypes.string.isRequired, - pristine: PropTypes.bool.isRequired, - submitting: PropTypes.bool.isRequired, - form: PropTypes.object.isRequired, - resources: PropTypes.shape({ - templates: PropTypes.shape({ - records: PropTypes.arrayOf(PropTypes.shape({ - id: PropTypes.string.isRequired, - name: PropTypes.string.isRequired, - })), - }), - requests: PropTypes.shape({ - records: PropTypes.arrayOf(PropTypes.object).isRequired, - }).isRequired, - }).isRequired, - mutator: PropTypes.shape({ - requests: PropTypes.shape({ - GET: PropTypes.func.isRequired, - }).isRequired, - }).isRequired, -}; - -const withStripes = stripesConnect(TitleLevelRequestsForm); - -export default injectIntl(stripesFinalForm({ - navigationCheck: true, - subscription: { values: true }, -})(withStripes)); diff --git a/src/deprecated/settings/TitleLevelRequests/TitleLevelRequestsForm.test.js b/src/deprecated/settings/TitleLevelRequests/TitleLevelRequestsForm.test.js deleted file mode 100644 index fa2d80212..000000000 --- a/src/deprecated/settings/TitleLevelRequests/TitleLevelRequestsForm.test.js +++ /dev/null @@ -1,353 +0,0 @@ -import { - render, - screen, - fireEvent, - cleanup, - waitFor, -} from '@folio/jest-config-stripes/testing-library/react'; - -import { - Button, - Checkbox, - Pane, - PaneFooter, - Modal, -} from '@folio/stripes/components'; -import { Field } from 'react-final-form'; - -import TitleLevelRequestsForm from './TitleLevelRequestsForm'; -import NoticeTemplates from '../../../settings/TLRPatronNotices/NoticeTemplates'; -import { - TITLE_LEVEL_REQUESTS, -} from '../../../constants'; -import { - TITLE_LEVEL_REQUESTS_DEFAULT_VALUES, -} from './constants'; - -jest.mock('../../../settings/TLRPatronNotices/NoticeTemplates', () => jest.fn(() => null)); -PaneFooter.mockImplementation(jest.fn(({ renderEnd }) => ( -
- {renderEnd} -
-))); -Modal.mockImplementation(jest.fn(({ onClose, footer, children, open, ...rest }) => ( - // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events -
- {children} - {footer} -
-))); -Field.mockImplementation(jest.fn(({ onChange, ...rest }) => ( - // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -
-))); - -describe('deprecated TitleLevelRequestsForm', () => { - const mockedHandleSubmit = jest.fn(); - const mockedRecord = [ - { - id: 'testId', - name: 'testName', - }, - ]; - const mockedResources = { - templates: { - records: mockedRecord, - }, - }; - const mockedRequest = [{ id: 'testRequest' }]; - const defaultProps = { - handleSubmit: mockedHandleSubmit, - label: 'testLabel', - pristine: false, - submitting: false, - resources: mockedResources, - mutator: { - requests: { - GET: () => mockedRequest, - }, - }, - }; - const testIds = { - form: 'tlrForm', - pane: 'tlrPane', - tlrCheckbox: 'tlrSwitchCheckbox', - errorModal: 'forbiddenDisableTlrModal', - }; - const labelIds = { - tlrEnabled: 'ui-circulation.settings.titleLevelRequests.allow', - tlrByDefault: 'ui-circulation.settings.titleLevelRequests.createTLR', - tlrHoldShouldFollowCirculationRules: 'ui-circulation.settings.titleLevelRequests.tlrHoldShouldFollowCirculationRules', - saveButon: 'stripes-core.button.save', - errorModalTitle: 'ui-circulation.settings.titleLevelRequests.forbiddenDisableTlrModal.title', - errorModalDescription: 'ui-circulation.settings.titleLevelRequests.forbiddenDisableTlrModal.description', - closeButton: 'stripes-core.button.close', - }; - const orderOfFieldCall = { - tlrEnabled: 1, - tlrByDefault: 2, - tlrHoldShouldFollowCirculationRules: 3, - }; - const mockedFormChange = jest.fn(); - - afterEach(() => { - Pane.mockClear(); - Field.mockClear(); - Button.mockClear(); - NoticeTemplates.mockClear(); - mockedFormChange.mockClear(); - }); - - describe('when "titleLevelRequestsFeatureEnabled" is true', () => { - const mockedForm = { - getState: jest.fn(() => ({ - values: { - ...TITLE_LEVEL_REQUESTS_DEFAULT_VALUES, - titleLevelRequestsFeatureEnabled: true, - }, - })), - change: mockedFormChange, - }; - - beforeEach(() => { - render( - - ); - }); - - it('should render form', () => { - expect(screen.getByTestId(testIds.form)).toBeVisible(); - }); - - it('should correctly handle form submit', () => { - expect(mockedHandleSubmit).toHaveBeenCalledTimes(0); - fireEvent.submit(screen.getByTestId(testIds.form)); - expect(mockedHandleSubmit).toHaveBeenCalledTimes(1); - }); - - it('should execute "Pane" with passed props', () => { - const expectedResult = { - defaultWidth: 'fill', - fluidContentWidth: true, - paneTitle:'testLabel', - }; - - expect(Pane).toHaveBeenLastCalledWith(expect.objectContaining(expectedResult), {}); - }); - - it('should execute "Field" associated with "TLR eneblade" with passed props', () => { - const expectedResult = { - name: TITLE_LEVEL_REQUESTS.TLR_ENABLED, - type: 'checkbox', - label: labelIds.tlrEnabled, - component: Checkbox, - }; - - expect(Field).toHaveBeenNthCalledWith(orderOfFieldCall.tlrEnabled, expect.objectContaining(expectedResult), {}); - }); - - it('should execute "Field" associated with "TLR by default" with passed props', () => { - const expectedResult = { - name: TITLE_LEVEL_REQUESTS.CREATE_TLR_BY_DEFAULT, - type: 'checkbox', - label: labelIds.tlrByDefault, - component: Checkbox, - }; - - expect(Field).toHaveBeenNthCalledWith(orderOfFieldCall.tlrByDefault, expectedResult, {}); - }); - - it('should execute "Field" associated with "tlr hold should follow circulation rules" with passed props', () => { - const expectedResult = { - name: TITLE_LEVEL_REQUESTS.TLR_HOLD_SHOULD_FOLLOW_CIRCULATION_RULES, - type: 'checkbox', - label: labelIds.tlrHoldShouldFollowCirculationRules, - component: Checkbox, - }; - - expect(Field).toHaveBeenNthCalledWith(orderOfFieldCall.tlrHoldShouldFollowCirculationRules, expectedResult, {}); - }); - - it('should execute "NoticeTemplates" with passed props', () => { - expect(NoticeTemplates).toHaveBeenLastCalledWith({ templates: mockedRecord }, {}); - }); - - it('should execute "Button" with passed props', () => { - const expectedResult = { - type: 'submit', - buttonStyle: 'primary paneHeaderNewButton', - disabled: false, - marginBottom0: true, - children: labelIds.saveButon, - }; - - expect(Button).toHaveBeenLastCalledWith(expectedResult, {}); - }); - - describe('when resources are empty', () => { - it('should execute "NoticeTemplates" with empty array instead of templates', () => { - render( - - ); - - expect(NoticeTemplates).toHaveBeenLastCalledWith({ templates: [] }, {}); - }); - }); - - describe('"Button" should be disabled', () => { - it('when "pristine" is true', () => { - render( - - ); - - expect(Button).toHaveBeenLastCalledWith(expect.objectContaining({ disabled: true }), {}); - }); - - it('when "submitting" is true', () => { - render( - - ); - - expect(Button).toHaveBeenLastCalledWith(expect.objectContaining({ disabled: true }), {}); - }); - }); - - describe('Modal', () => { - it('should be executed with passed props', () => { - const expectedResult = { - label: labelIds.errorModalTitle, - open: false, - dismissible: true, - children: labelIds.errorModalDescription, - }; - - expect(Modal).toHaveBeenLastCalledWith(expect.objectContaining(expectedResult), {}); - }); - - it('should be open', async () => { - expect(screen.getByTestId(testIds.errorModal)).not.toHaveAttribute('open'); - - fireEvent.click(screen.getByTestId(testIds.tlrCheckbox)); - - const modalAfterClick = await screen.findByTestId(testIds.errorModal); - - expect(mockedFormChange).not.toHaveBeenCalled(); - expect(modalAfterClick).toHaveAttribute('open'); - }); - - it('should have "Close" button', () => { - expect(screen.getByText(labelIds.closeButton)).toBeVisible(); - }); - - it('should close modal on "Close" button click', async () => { - expect(screen.getByTestId(testIds.errorModal)).not.toHaveAttribute('open'); - fireEvent.click(screen.getByTestId(testIds.tlrCheckbox)); - const modalAfterFirstClick = await screen.findByTestId(testIds.errorModal); - expect(modalAfterFirstClick).toHaveAttribute('open'); - - fireEvent.click(screen.getByText(labelIds.closeButton)); - const modalAfterSecondClick = await screen.findByTestId(testIds.errorModal); - expect(modalAfterSecondClick).not.toHaveAttribute('open'); - }); - }); - - describe('when there are no "Title" requests in data base', () => { - it('should disable TLR on checkbox click', async () => { - cleanup(); - render( - [], - }, - }} - /> - ); - - fireEvent.click(screen.getByTestId(testIds.tlrCheckbox)); - - await waitFor(() => { - expect(mockedFormChange).toHaveBeenCalledWith(TITLE_LEVEL_REQUESTS.TLR_ENABLED, false); - }); - }); - }); - }); - - describe('when "titleLevelRequestsFeatureEnabled" is false', () => { - const mockedForm = { - getState: jest.fn(() => ({ - values: { - ...TITLE_LEVEL_REQUESTS_DEFAULT_VALUES, - titleLevelRequestsFeatureEnabled: false, - }, - })), - change: mockedFormChange, - }; - - beforeEach(() => { - render( - - ); - }); - - it('should render only one "Field"', () => { - const expectedResult = { - name: TITLE_LEVEL_REQUESTS.TLR_ENABLED, - type: 'checkbox', - label: labelIds.tlrEnabled, - component: Checkbox, - }; - - expect(Field).toHaveBeenCalledTimes(1); - expect(Field).toHaveBeenNthCalledWith(orderOfFieldCall.tlrEnabled, expect.objectContaining(expectedResult), {}); - }); - - it('should not render "NoticeTemplates"', () => { - expect(NoticeTemplates).toHaveBeenCalledTimes(0); - }); - - it('should execute "Button" with passed props', () => { - const expectedResult = { - type: 'submit', - buttonStyle: 'primary paneHeaderNewButton', - disabled: false, - marginBottom0: true, - children: labelIds.saveButon, - }; - - expect(Button).toHaveBeenLastCalledWith(expectedResult, {}); - }); - - it('should enable TLR on checkbox click', async () => { - fireEvent.click(screen.getByTestId(testIds.tlrCheckbox)); - - await waitFor(() => { - expect(mockedFormChange).toHaveBeenCalledWith(TITLE_LEVEL_REQUESTS.TLR_ENABLED, true); - }); - }); - }); -}); diff --git a/src/deprecated/settings/TitleLevelRequests/constants.js b/src/deprecated/settings/TitleLevelRequests/constants.js deleted file mode 100644 index 70da6959d..000000000 --- a/src/deprecated/settings/TitleLevelRequests/constants.js +++ /dev/null @@ -1,13 +0,0 @@ -import { - NOT_SELECTED, - TITLE_LEVEL_REQUESTS, -} from '../../../constants'; - -export const TITLE_LEVEL_REQUESTS_DEFAULT_VALUES = { - [TITLE_LEVEL_REQUESTS.TLR_ENABLED]: false, - [TITLE_LEVEL_REQUESTS.CREATE_TLR_BY_DEFAULT]: false, - [TITLE_LEVEL_REQUESTS.TLR_HOLD_SHOULD_FOLLOW_CIRCULATION_RULES]: false, - [TITLE_LEVEL_REQUESTS.CONFIRMATION_TEMPLATE]: NOT_SELECTED, - [TITLE_LEVEL_REQUESTS.CANCELLATION_TEMPLATE]: NOT_SELECTED, - [TITLE_LEVEL_REQUESTS.EXPIRATION_TEMPLATE]: NOT_SELECTED, -}; diff --git a/src/deprecated/settings/TitleLevelRequests/index.js b/src/deprecated/settings/TitleLevelRequests/index.js deleted file mode 100644 index 62d94875b..000000000 --- a/src/deprecated/settings/TitleLevelRequests/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './TitleLevelRequests'; diff --git a/src/deprecated/settings/TitleLevelRequests/utils/getInitialValues.js b/src/deprecated/settings/TitleLevelRequests/utils/getInitialValues.js deleted file mode 100644 index 7dc20a1f2..000000000 --- a/src/deprecated/settings/TitleLevelRequests/utils/getInitialValues.js +++ /dev/null @@ -1,33 +0,0 @@ -import { - isEmpty, - head, -} from 'lodash'; - -import { - NOT_SELECTED, - TLR_FIELDS_FOR_RESET, -} from '../../../../constants'; -import { - TITLE_LEVEL_REQUESTS_DEFAULT_VALUES, -} from '../constants'; - -const getInitialValues = (settings) => { - if (isEmpty(settings)) { - return TITLE_LEVEL_REQUESTS_DEFAULT_VALUES; - } - - const settingsForReturn = { - ...TITLE_LEVEL_REQUESTS_DEFAULT_VALUES, - ...JSON.parse(head(settings).value), - }; - - TLR_FIELDS_FOR_RESET.forEach(field => { - if (settingsForReturn[field] === null) { - settingsForReturn[field] = NOT_SELECTED; - } - }); - - return settingsForReturn; -}; - -export default getInitialValues; diff --git a/src/deprecated/settings/TitleLevelRequests/utils/getInitialValues.test.js b/src/deprecated/settings/TitleLevelRequests/utils/getInitialValues.test.js deleted file mode 100644 index 1463d8b15..000000000 --- a/src/deprecated/settings/TitleLevelRequests/utils/getInitialValues.test.js +++ /dev/null @@ -1,33 +0,0 @@ -import getInitialValues from './getInitialValues'; -import { - TITLE_LEVEL_REQUESTS, -} from '../../../../constants'; -import { - TITLE_LEVEL_REQUESTS_DEFAULT_VALUES, -} from '../constants'; - -describe('deprecated getInitialValues', () => { - it('should return default config if nothing found in database', () => { - expect(getInitialValues()).toEqual(TITLE_LEVEL_REQUESTS_DEFAULT_VALUES); - }); - - it('should return config with values from database', () => { - const testData = [ - { - value: JSON.stringify({ - [TITLE_LEVEL_REQUESTS.TLR_ENABLED]: true, - [TITLE_LEVEL_REQUESTS.CONFIRMATION_TEMPLATE]: 'testId', - [TITLE_LEVEL_REQUESTS.EXPIRATION_TEMPLATE]: null, - [TITLE_LEVEL_REQUESTS.CANCELLATION_TEMPLATE]: null, - }), - }, - ]; - const expectedData = { - ...TITLE_LEVEL_REQUESTS_DEFAULT_VALUES, - [TITLE_LEVEL_REQUESTS.TLR_ENABLED]: true, - [TITLE_LEVEL_REQUESTS.CONFIRMATION_TEMPLATE]: 'testId', - }; - - expect(getInitialValues(testData)).toEqual(expectedData); - }); -}); diff --git a/src/deprecated/settings/TitleLevelRequests/utils/index.js b/src/deprecated/settings/TitleLevelRequests/utils/index.js deleted file mode 100644 index 77f927b74..000000000 --- a/src/deprecated/settings/TitleLevelRequests/utils/index.js +++ /dev/null @@ -1,2 +0,0 @@ -export { default as normalizeData } from './normalizeData'; -export { default as getInitialValues } from './getInitialValues'; diff --git a/src/deprecated/settings/TitleLevelRequests/utils/normalizeData.js b/src/deprecated/settings/TitleLevelRequests/utils/normalizeData.js deleted file mode 100644 index 5564fe507..000000000 --- a/src/deprecated/settings/TitleLevelRequests/utils/normalizeData.js +++ /dev/null @@ -1,24 +0,0 @@ -import { - TITLE_LEVEL_REQUESTS, - TLR_FIELDS_FOR_RESET, - NOT_SELECTED, -} from '../../../../constants'; -import { - TITLE_LEVEL_REQUESTS_DEFAULT_VALUES, -} from '../constants'; - -const normalizeData = (value) => { - const configForReturn = value[TITLE_LEVEL_REQUESTS.TLR_ENABLED] - ? value - : TITLE_LEVEL_REQUESTS_DEFAULT_VALUES; - - TLR_FIELDS_FOR_RESET.forEach(field => { - if (configForReturn[field] === NOT_SELECTED) { - configForReturn[field] = null; - } - }); - - return JSON.stringify(configForReturn); -}; - -export default normalizeData; diff --git a/src/deprecated/settings/TitleLevelRequests/utils/normalizeData.test.js b/src/deprecated/settings/TitleLevelRequests/utils/normalizeData.test.js deleted file mode 100644 index 89a40f5de..000000000 --- a/src/deprecated/settings/TitleLevelRequests/utils/normalizeData.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import normalizeData from './normalizeData'; -import { - TITLE_LEVEL_REQUESTS, - NOT_SELECTED, -} from '../../../../constants'; -import { - TITLE_LEVEL_REQUESTS_DEFAULT_VALUES, -} from '../constants'; - -describe('deprecated normalizeData', () => { - const testId = 'testId'; - - it('should return modified passed config if "TLR" is allowed', () => { - const testData = { - titleLevelRequestsFeatureEnabled: true, - someData: 'test', - [TITLE_LEVEL_REQUESTS.CONFIRMATION_TEMPLATE]: NOT_SELECTED, - [TITLE_LEVEL_REQUESTS.CANCELLATION_TEMPLATE]: NOT_SELECTED, - [TITLE_LEVEL_REQUESTS.EXPIRATION_TEMPLATE]: testId, - }; - - const expectedResult = { - titleLevelRequestsFeatureEnabled: true, - someData: 'test', - [TITLE_LEVEL_REQUESTS.CONFIRMATION_TEMPLATE]: null, - [TITLE_LEVEL_REQUESTS.CANCELLATION_TEMPLATE]: null, - [TITLE_LEVEL_REQUESTS.EXPIRATION_TEMPLATE]: testId, - }; - - expect(normalizeData(testData)).toBe(JSON.stringify(expectedResult)); - }); - - it('should return modified default config if "TLR" is not allowed', () => { - const testData = { - titleLevelRequestsFeatureEnabled: false, - someData: 'test', - }; - - expect(normalizeData(testData)).toBe(JSON.stringify(TITLE_LEVEL_REQUESTS_DEFAULT_VALUES)); - }); -}); diff --git a/src/index.js b/src/index.js index 334db8db5..2db5a192f 100644 --- a/src/index.js +++ b/src/index.js @@ -22,7 +22,6 @@ import RequestPolicySettings from './settings/RequestPolicy'; import TitleLevelRequests from './settings/TitleLevelRequests'; import PrintHoldRequests from './settings/PrintHoldRequests'; import TLRPatronNotices from './settings/TLRPatronNotices'; -import DeprecatedTitleLevelRequests from './deprecated/settings/TitleLevelRequests'; import ConsortiumTLR from './settings/ConsortiumTLR'; import { getConsortiumTlrPermission } from './settings/utils/utils'; import ViewPrintDetails from './settings/ViewPrintDetails'; @@ -36,8 +35,6 @@ class Circulation extends Component { constructor(props) { super(props); - const isEnabledEcsRequests = props.stripes?.config?.enableEcsRequests; - this.sections = [ { label: , @@ -60,6 +57,18 @@ class Circulation extends Component { component: StaffSlips, perm: 'ui-circulation.settings.view-staff-slips', }, + { + route: 'title-level-requests', + label: , + component: TitleLevelRequests, + perm: 'ui-circulation.settings.view-titleLevelRequests', + }, + { + route: 'consortium-title-level-requests', + label: , + component: ConsortiumTLR, + perm: getConsortiumTlrPermission(props.stripes), + } ], }, { @@ -134,6 +143,12 @@ class Circulation extends Component { component: RequestPolicySettings, perm: 'ui-circulation.settings.view-request-policies', }, + { + route: 'tlr-patron-notice-templates', + label: , + component: TLRPatronNotices, + perm: 'ui-circulation.settings.view-titleLevelRequests', + }, { route: 'print-hold-requests', label: , @@ -149,34 +164,6 @@ class Circulation extends Component { ], }, ]; - - if (isEnabledEcsRequests === true) { - this.sections[0].pages.push({ - route: 'title-level-requests', - label: , - component: TitleLevelRequests, - perm: 'ui-circulation.settings.view-titleLevelRequests', - }, - { - route: 'consortium-title-level-requests', - label: , - component: ConsortiumTLR, - perm: getConsortiumTlrPermission(props.stripes), - }); - this.sections[4].pages.splice(2, 0, { - route: 'tlr-patron-notice-templates', - label: , - component: TLRPatronNotices, - perm: 'ui-circulation.settings.view-titleLevelRequests', - }); - } else { - this.sections[4].pages.splice(2, 0, { - route: 'title-level-requests', - label: , - component: DeprecatedTitleLevelRequests, - perm: 'ui-circulation.settings.view-titleLevelRequests', - }); - } } render() { diff --git a/translations/ui-circulation/en.json b/translations/ui-circulation/en.json index 83d4d7df3..51b4dcea9 100644 --- a/translations/ui-circulation/en.json +++ b/translations/ui-circulation/en.json @@ -12,7 +12,6 @@ "settings.index.patronNotices": "Patron notice templates", "settings.index.noticePolicies": "Patron notice policies", "settings.index.requestPolicies": "Request policies", - "settings.index.titleLevelRequests": "Title level requests", "settings.index.titleLevelRequestsTlr": "Title level requests (TLR)", "settings.index.tlrPatronNotices": "TLR patron notice templates", "settings.index.consortiumTLR": "Consortium title level requests (TLR)", @@ -37,7 +36,6 @@ "settings.title.patronNoticeTemplates": "Patron notice {optionNumber, plural, one {template} other {templates}}", "settings.title.requestCancellationReasons": "Request cancellation reasons", "settings.title.requestPolicies": "Request {optionNumber, plural, one {policy} other {policies}}", - "settings.title.titleLevelRequests": "Title level requests", "settings.title.titleLevelRequestsTlr": "Title level requests (TLR)", "settings.title.tlrPatronNotices": "TLR Patron notice templates", "settings.title.consortiumTLR": "Consortium title level requests (TLR)", @@ -338,7 +336,6 @@ "settings.requestPolicy.requestTypes.allowAll": "Allow all pickup service points", "settings.requestPolicy.requestTypes.allowSome": "Allow some pickup service points", - "settings.titleLevelRequests.paneTitle": "Title level requests", "settings.titleLevelRequestsTlr.paneTitle": "Title level requests (TLR)", "settings.tlrPatronNotices.paneTitle": "TLR Patron notice templates", "settings.titleLevelRequests.allow": "Allow title level requests",