Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIQM-677: Add MARC Settings page. #695

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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
}
]
},
Expand Down
7 changes: 7 additions & 0 deletions src/QuickMarc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ import {
MARC_TYPES,
keyboardCommands,
} from './common/constants';
import { QuickMarcSettings } from './settings';

const QuickMarc = ({
basePath,
externalRecordPath,
showSettings,
onClose,
onSave,
}) => {
Expand Down Expand Up @@ -90,6 +92,10 @@ const QuickMarc = ({
},
];

if (showSettings) {
return <QuickMarcSettings />;
}

return (
<div data-test-quick-marc>
<CommandList
Expand Down Expand Up @@ -122,6 +128,7 @@ const QuickMarc = ({
QuickMarc.propTypes = {
basePath: PropTypes.string.isRequired,
externalRecordPath: PropTypes.string,
showSettings: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
onSave: PropTypes.func.isRequired,
};
Expand Down
22 changes: 22 additions & 0 deletions src/settings/MarcBibTemplates/MarcBibTemplates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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 (
<TitleManager record={paneTitle}>
<Pane
defaultWidth="100%"
paneTitle={paneTitle}
id="settings-marc-bib-templates-pane"
/>
</TitleManager>
);
};

export { MarcBibTemplates };
22 changes: 22 additions & 0 deletions src/settings/MarcBibTemplates/MarcBibTemplates.test.js
Original file line number Diff line number Diff line change
@@ -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(
<Harness>
<MarcBibTemplates />
</Harness>,
);

describe('Given MarcBibTemplates', () => {
beforeEach(() => {
jest.clearAllMocks();
});

it('should render pane title', () => {
const { getByText } = renderMarcBibTemplates();

expect(getByText('ui-quick-marc.settings.marcBibTemplates.pane.title')).toBeVisible();
});
});
1 change: 1 addition & 0 deletions src/settings/MarcBibTemplates/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './MarcBibTemplates';
40 changes: 40 additions & 0 deletions src/settings/QuickMarcSettings/QuickMarcSettings.js
Original file line number Diff line number Diff line change
@@ -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 = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ask Khalilah or Christine if we can show MARC templates setting now. I think it's not planned for this release yet

{
component: MarcBibTemplates,
label: formatMessage({ id: 'ui-quick-marc.settings.marcBibTemplates.pane.title' }),
route: 'marc-bib-templates',
},
];

return (
<CommandList commands={defaultKeyboardShortcuts}>
<TitleManager page={formatMessage({ id: 'ui-quick-marc.settings.html.page.title' })}>
<Settings
match={match}
location={location}
paneTitle={formatMessage({ id: 'ui-quick-marc.settings.heading' })}
pages={pages}
/>
</TitleManager>
</CommandList>
);
};

export { QuickMarcSettings };
23 changes: 23 additions & 0 deletions src/settings/QuickMarcSettings/QuickMarcSettings.test.js
Original file line number Diff line number Diff line change
@@ -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(
<Harness>
<QuickMarcSettings />
</Harness>,
);

describe('Given Settings', () => {
beforeEach(() => {
Settings.mockClear();
});

it('should be rendered', () => {
const { getByText } = renderQuickMarcSettings();

expect(getByText('Settings')).toBeVisible();
});
});
1 change: 1 addition & 0 deletions src/settings/QuickMarcSettings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './QuickMarcSettings';
1 change: 1 addition & 0 deletions src/settings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './QuickMarcSettings';
1 change: 1 addition & 0 deletions test/jest/__mock__/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import './stripesCore.mock';
import './resizeObserver.mock';
import './stripesSmartComponent.mock';
4 changes: 4 additions & 0 deletions test/jest/__mock__/stripesSmartComponent.mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jest.mock('@folio/stripes/smart-components', () => ({
...jest.requireActual('@folio/stripes/smart-components'),
Settings: jest.fn(() => <div>Settings</div>),
}));
6 changes: 5 additions & 1 deletion translations/ui-quick-marc/en.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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}",
Expand Down
Loading