From c22026a15313d46a9c8b055f73e982b9049619bc Mon Sep 17 00:00:00 2001 From: Dmytro-Melnyshyn Date: Fri, 12 Jul 2024 18:32:02 +0300 Subject: [PATCH 1/3] UIQM-677: Add MARC Settings page. --- CHANGELOG.md | 1 + package.json | 12 +++++- src/QuickMarc.js | 7 ++++ .../QuickMarcSettings/MarcBibTemplates.js | 22 ++++++++++ .../QuickMarcSettings/QuickMarcSettings.js | 40 +++++++++++++++++++ src/settings/QuickMarcSettings/index.js | 1 + src/settings/index.js | 1 + translations/ui-quick-marc/en.json | 6 ++- 8 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 src/settings/QuickMarcSettings/MarcBibTemplates.js create mode 100644 src/settings/QuickMarcSettings/QuickMarcSettings.js create mode 100644 src/settings/QuickMarcSettings/index.js create mode 100644 src/settings/index.js diff --git a/CHANGELOG.md b/CHANGELOG.md index d1f27c3a..1e101f36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * [UIQM-661](https://issues.folio.org/browse/UIQM-661) Derive a new MARC bib record > Do not copy over 010 field values. * [UIQM-666](https://issues.folio.org/browse/UIQM-666) Make leader positions `Type` and `BLvl` required when creating a bib record. * [UIQM-672](https://issues.folio.org/browse/UIQM-672) Add a tooltip for the search link. +* [UIQM-677](https://issues.folio.org/browse/UIQM-677) Add MARC Settings page. ## [8.0.1] (https://github.com/folio-org/ui-quick-marc/tree/v8.0.1) (2024-04-18) diff --git a/package.json b/package.json index b9361719..dbbd9067 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,10 @@ "license": "Apache-2.0", "stripes": { "actsAs": [ - "plugin" + "plugin", + "settings" ], + "route": "/quick-marc", "pluginType": "quick-marc", "displayName": "ui-quick-marc.meta.title", "okapiInterfaces": { @@ -141,6 +143,14 @@ "marc-records-editor.links.suggestion.post" ], "visible": true + }, + { + "permissionName": "settings.quick-marc.enabled", + "displayName": "Settings (MARC): Module is enabled.", + "subPermissions": [ + "settings.enabled" + ], + "visible": false } ] }, diff --git a/src/QuickMarc.js b/src/QuickMarc.js index ea06064a..89aec555 100644 --- a/src/QuickMarc.js +++ b/src/QuickMarc.js @@ -17,10 +17,12 @@ import { MARC_TYPES, keyboardCommands, } from './common/constants'; +import { QuickMarcSettings } from './settings'; const QuickMarc = ({ basePath, externalRecordPath, + showSettings, onClose, onSave, }) => { @@ -90,6 +92,10 @@ const QuickMarc = ({ }, ]; + if (showSettings) { + return ; + } + return (
{ + const intl = useIntl(); + + const paneTitle = intl.formatMessage({ id: 'ui-quick-marc.settings.marcBibTemplates.pane.title' }); + + return ( + + + + ); +}; + +export { MarcBibTemplates }; diff --git a/src/settings/QuickMarcSettings/QuickMarcSettings.js b/src/settings/QuickMarcSettings/QuickMarcSettings.js new file mode 100644 index 00000000..9ae4da1b --- /dev/null +++ b/src/settings/QuickMarcSettings/QuickMarcSettings.js @@ -0,0 +1,40 @@ +import { useLocation, useRouteMatch } from 'react-router-dom'; +import { useIntl } from 'react-intl'; + +import { TitleManager } from '@folio/stripes/core'; +import { + CommandList, + defaultKeyboardShortcuts, +} from '@folio/stripes/components'; +import { Settings } from '@folio/stripes/smart-components'; + +import { MarcBibTemplates } from './MarcBibTemplates'; + +const QuickMarcSettings = () => { + const match = useRouteMatch(); + const location = useLocation(); + const { formatMessage } = useIntl(); + + const pages = [ + { + component: MarcBibTemplates, + label: formatMessage({ id: 'ui-quick-marc.settings.marcBibTemplates.pane.title' }), + route: 'marc-bib-templates', + }, + ]; + + return ( + + + + + + ); +}; + +export { QuickMarcSettings }; diff --git a/src/settings/QuickMarcSettings/index.js b/src/settings/QuickMarcSettings/index.js new file mode 100644 index 00000000..8b43494b --- /dev/null +++ b/src/settings/QuickMarcSettings/index.js @@ -0,0 +1 @@ +export * from './QuickMarcSettings'; diff --git a/src/settings/index.js b/src/settings/index.js new file mode 100644 index 00000000..8b43494b --- /dev/null +++ b/src/settings/index.js @@ -0,0 +1 @@ +export * from './QuickMarcSettings'; diff --git a/translations/ui-quick-marc/en.json b/translations/ui-quick-marc/en.json index 0c8e80fe..85fd867a 100644 --- a/translations/ui-quick-marc/en.json +++ b/translations/ui-quick-marc/en.json @@ -1,5 +1,5 @@ { - "meta.title": "Quick MARC", + "meta.title": "MARC", "meta.source.system": "System", "permission.quick-marc-editor.all": "quickMARC: View, edit MARC bibliographic record", @@ -13,6 +13,10 @@ "permission.quick-marc-authorities-editor.all": "quickMARC: View, edit MARC authorities record", "permission.quick-marc-authority-records.linkUnlink": "quickMARC: Can Link/unlink authority records to bib records", + "settings.heading": "MARC", + "settings.marcBibTemplates.pane.title": "MARC bibliographic templates", + "settings.html.page.title": "MARC settings", + "holdings-record.create.title": "Create a new MARC Holdings record", "bibliographic-record.create.title": "Create a new {shared, select, true {shared} false {local} other {}} MARC bib record", "bibliographic-record.edit.title": "Edit {shared, select, true {shared} false {local} other {}} MARC record - {title}", From d419964174881c324970c0bd25f3d6209d6d3a4d Mon Sep 17 00:00:00 2001 From: Dmytro-Melnyshyn Date: Mon, 15 Jul 2024 10:53:29 +0300 Subject: [PATCH 2/3] add tests --- .../MarcBibTemplates.js | 0 .../MarcBibTemplates/MarcBibTemplates.test.js | 22 ++++++++++++++++++ src/settings/MarcBibTemplates/index.js | 1 + .../QuickMarcSettings/QuickMarcSettings.js | 2 +- .../QuickMarcSettings.test.js | 23 +++++++++++++++++++ test/jest/__mock__/index.js | 1 + .../__mock__/stripesSmartComponent.mock.js | 4 ++++ 7 files changed, 52 insertions(+), 1 deletion(-) rename src/settings/{QuickMarcSettings => MarcBibTemplates}/MarcBibTemplates.js (100%) create mode 100644 src/settings/MarcBibTemplates/MarcBibTemplates.test.js create mode 100644 src/settings/MarcBibTemplates/index.js create mode 100644 src/settings/QuickMarcSettings/QuickMarcSettings.test.js create mode 100644 test/jest/__mock__/stripesSmartComponent.mock.js diff --git a/src/settings/QuickMarcSettings/MarcBibTemplates.js b/src/settings/MarcBibTemplates/MarcBibTemplates.js similarity index 100% rename from src/settings/QuickMarcSettings/MarcBibTemplates.js rename to src/settings/MarcBibTemplates/MarcBibTemplates.js diff --git a/src/settings/MarcBibTemplates/MarcBibTemplates.test.js b/src/settings/MarcBibTemplates/MarcBibTemplates.test.js new file mode 100644 index 00000000..326947d4 --- /dev/null +++ b/src/settings/MarcBibTemplates/MarcBibTemplates.test.js @@ -0,0 +1,22 @@ +import { render } from '@folio/jest-config-stripes/testing-library/react'; + +import { MarcBibTemplates } from './MarcBibTemplates'; +import Harness from '../../../test/jest/helpers/harness'; + +const renderMarcBibTemplates = () => render( + + + , +); + +describe('Given MarcBibTemplates', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('should render pane title', () => { + const { getByText } = renderMarcBibTemplates(); + + expect(getByText('ui-quick-marc.settings.marcBibTemplates.pane.title')).toBeVisible(); + }); +}); diff --git a/src/settings/MarcBibTemplates/index.js b/src/settings/MarcBibTemplates/index.js new file mode 100644 index 00000000..4581afce --- /dev/null +++ b/src/settings/MarcBibTemplates/index.js @@ -0,0 +1 @@ +export * from './MarcBibTemplates'; diff --git a/src/settings/QuickMarcSettings/QuickMarcSettings.js b/src/settings/QuickMarcSettings/QuickMarcSettings.js index 9ae4da1b..3ec02e2f 100644 --- a/src/settings/QuickMarcSettings/QuickMarcSettings.js +++ b/src/settings/QuickMarcSettings/QuickMarcSettings.js @@ -8,7 +8,7 @@ import { } from '@folio/stripes/components'; import { Settings } from '@folio/stripes/smart-components'; -import { MarcBibTemplates } from './MarcBibTemplates'; +import { MarcBibTemplates } from '../MarcBibTemplates'; const QuickMarcSettings = () => { const match = useRouteMatch(); diff --git a/src/settings/QuickMarcSettings/QuickMarcSettings.test.js b/src/settings/QuickMarcSettings/QuickMarcSettings.test.js new file mode 100644 index 00000000..6798dd47 --- /dev/null +++ b/src/settings/QuickMarcSettings/QuickMarcSettings.test.js @@ -0,0 +1,23 @@ +import { render } from '@folio/jest-config-stripes/testing-library/react'; +import { Settings } from '@folio/stripes/smart-components'; + +import { QuickMarcSettings } from './QuickMarcSettings'; +import Harness from '../../../test/jest/helpers/harness'; + +const renderQuickMarcSettings = () => render( + + + , +); + +describe('Given Settings', () => { + beforeEach(() => { + Settings.mockClear(); + }); + + it('should be rendered', () => { + const { getByText } = renderQuickMarcSettings(); + + expect(getByText('Settings')).toBeVisible(); + }); +}); diff --git a/test/jest/__mock__/index.js b/test/jest/__mock__/index.js index 10288a9f..f1083254 100644 --- a/test/jest/__mock__/index.js +++ b/test/jest/__mock__/index.js @@ -1,2 +1,3 @@ import './stripesCore.mock'; import './resizeObserver.mock'; +import './stripesSmartComponent.mock'; diff --git a/test/jest/__mock__/stripesSmartComponent.mock.js b/test/jest/__mock__/stripesSmartComponent.mock.js new file mode 100644 index 00000000..f13c09ac --- /dev/null +++ b/test/jest/__mock__/stripesSmartComponent.mock.js @@ -0,0 +1,4 @@ +jest.mock('@folio/stripes/smart-components', () => ({ + ...jest.requireActual('@folio/stripes/smart-components'), + Settings: jest.fn(() =>
Settings
), +})); From 013a369d93fad1b33cb4b1b2a6d377c084600a5d Mon Sep 17 00:00:00 2001 From: Dmytro-Melnyshyn Date: Thu, 18 Jul 2024 13:53:27 +0300 Subject: [PATCH 3/3] remove marc bib templates page --- .../MarcBibTemplates/MarcBibTemplates.js | 22 ------------------- .../MarcBibTemplates/MarcBibTemplates.test.js | 22 ------------------- src/settings/MarcBibTemplates/index.js | 1 - .../QuickMarcSettings/QuickMarcSettings.js | 10 +-------- 4 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 src/settings/MarcBibTemplates/MarcBibTemplates.js delete mode 100644 src/settings/MarcBibTemplates/MarcBibTemplates.test.js delete mode 100644 src/settings/MarcBibTemplates/index.js diff --git a/src/settings/MarcBibTemplates/MarcBibTemplates.js b/src/settings/MarcBibTemplates/MarcBibTemplates.js deleted file mode 100644 index 0858d2ea..00000000 --- a/src/settings/MarcBibTemplates/MarcBibTemplates.js +++ /dev/null @@ -1,22 +0,0 @@ -import { useIntl } from 'react-intl'; - -import { TitleManager } from '@folio/stripes/core'; -import { Pane } from '@folio/stripes/components'; - -const MarcBibTemplates = () => { - const intl = useIntl(); - - const paneTitle = intl.formatMessage({ id: 'ui-quick-marc.settings.marcBibTemplates.pane.title' }); - - return ( - - - - ); -}; - -export { MarcBibTemplates }; diff --git a/src/settings/MarcBibTemplates/MarcBibTemplates.test.js b/src/settings/MarcBibTemplates/MarcBibTemplates.test.js deleted file mode 100644 index 326947d4..00000000 --- a/src/settings/MarcBibTemplates/MarcBibTemplates.test.js +++ /dev/null @@ -1,22 +0,0 @@ -import { render } from '@folio/jest-config-stripes/testing-library/react'; - -import { MarcBibTemplates } from './MarcBibTemplates'; -import Harness from '../../../test/jest/helpers/harness'; - -const renderMarcBibTemplates = () => render( - - - , -); - -describe('Given MarcBibTemplates', () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - - it('should render pane title', () => { - const { getByText } = renderMarcBibTemplates(); - - expect(getByText('ui-quick-marc.settings.marcBibTemplates.pane.title')).toBeVisible(); - }); -}); diff --git a/src/settings/MarcBibTemplates/index.js b/src/settings/MarcBibTemplates/index.js deleted file mode 100644 index 4581afce..00000000 --- a/src/settings/MarcBibTemplates/index.js +++ /dev/null @@ -1 +0,0 @@ -export * from './MarcBibTemplates'; diff --git a/src/settings/QuickMarcSettings/QuickMarcSettings.js b/src/settings/QuickMarcSettings/QuickMarcSettings.js index 3ec02e2f..62218b3a 100644 --- a/src/settings/QuickMarcSettings/QuickMarcSettings.js +++ b/src/settings/QuickMarcSettings/QuickMarcSettings.js @@ -8,20 +8,12 @@ import { } from '@folio/stripes/components'; import { Settings } from '@folio/stripes/smart-components'; -import { MarcBibTemplates } from '../MarcBibTemplates'; - const QuickMarcSettings = () => { const match = useRouteMatch(); const location = useLocation(); const { formatMessage } = useIntl(); - const pages = [ - { - component: MarcBibTemplates, - label: formatMessage({ id: 'ui-quick-marc.settings.marcBibTemplates.pane.title' }), - route: 'marc-bib-templates', - }, - ]; + const pages = []; return (