From e9bf65cca5ad72ac8ae15c888dbeacbe8b48aa05 Mon Sep 17 00:00:00 2001
From: Dmytro-Melnyshyn <77053927+Dmytro-Melnyshyn@users.noreply.github.com>
Date: Tue, 31 Oct 2023 18:13:05 +0200
Subject: [PATCH] UIQM-580: Move QuickMarcView, PrintPopup,
useAuthorityLinkingRules and getHeaders to stripes-marc-components. (#613)
---
CHANGELOG.md | 4 +
package.json | 5 +-
src/QuickMarcEditor/QuickMarcEditWrapper.js | 2 +-
src/QuickMarcEditor/QuickMarcEditor.test.js | 6 +-
.../QuickMarcEditorContainer.js | 2 +-
.../QuickMarcEditorContainer.test.js | 8 +-
.../QuickMarcEditorRows.test.js | 8 +-
src/QuickMarcEditor/utils.js | 26 ---
src/QuickMarcView/MarcContent/MarcContent.css | 14 --
src/QuickMarcView/MarcContent/MarcContent.js | 69 --------
.../MarcContent/MarcContent.test.js | 67 --------
src/QuickMarcView/MarcContent/index.js | 1 -
src/QuickMarcView/MarcField.css | 3 -
src/QuickMarcView/MarcField.js | 122 -------------
src/QuickMarcView/PrintPopup/PrintPopup.css | 22 ---
src/QuickMarcView/PrintPopup/PrintPopup.js | 75 --------
.../PrintPopup/PrintPopup.test.js | 50 ------
src/QuickMarcView/PrintPopup/index.js | 1 -
src/QuickMarcView/QuickMarcView.js | 81 ---------
src/QuickMarcView/QuickMarcView.test.js | 160 ------------------
src/QuickMarcView/index.js | 1 -
src/QuickMarcView/utils.js | 3 -
.../useAuthorityLinking.js | 2 +-
.../useAuthorityLinking.test.js | 12 +-
src/queries/index.js | 1 -
src/queries/useAuthorityLinkingRules/index.js | 1 -
.../useAuthorityLinkingRules.js | 25 ---
.../useAuthorityLinkingRules.test.js | 44 -----
28 files changed, 34 insertions(+), 781 deletions(-)
delete mode 100644 src/QuickMarcView/MarcContent/MarcContent.css
delete mode 100644 src/QuickMarcView/MarcContent/MarcContent.js
delete mode 100644 src/QuickMarcView/MarcContent/MarcContent.test.js
delete mode 100644 src/QuickMarcView/MarcContent/index.js
delete mode 100644 src/QuickMarcView/MarcField.css
delete mode 100644 src/QuickMarcView/MarcField.js
delete mode 100644 src/QuickMarcView/PrintPopup/PrintPopup.css
delete mode 100644 src/QuickMarcView/PrintPopup/PrintPopup.js
delete mode 100644 src/QuickMarcView/PrintPopup/PrintPopup.test.js
delete mode 100644 src/QuickMarcView/PrintPopup/index.js
delete mode 100644 src/QuickMarcView/QuickMarcView.js
delete mode 100644 src/QuickMarcView/QuickMarcView.test.js
delete mode 100644 src/QuickMarcView/index.js
delete mode 100644 src/QuickMarcView/utils.js
delete mode 100644 src/queries/useAuthorityLinkingRules/index.js
delete mode 100644 src/queries/useAuthorityLinkingRules/useAuthorityLinkingRules.js
delete mode 100644 src/queries/useAuthorityLinkingRules/useAuthorityLinkingRules.test.js
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fed38fb1..600b6f49 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Change history for ui-quick-marc
+## [8.0.0] (IN PROGRESS)
+
+* [UIQM-580](https://issues.folio.org/browse/UIQM-580) *BREAKING* Move QuickMarcView, PrintPopup and getHeaders to stripes-marc-components.
+
## [7.1.0] (IN PROGRESS)
* [UIQM-543](https://issues.folio.org/browse/UIQM-543) Remove eslint deps that are already listed in eslint-config-stripes.
diff --git a/package.json b/package.json
index 30f7f971..b48c660a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@folio/quick-marc",
- "version": "7.0.2",
+ "version": "8.0.0",
"description": "Quick MARC editor",
"main": "index.js",
"repository": "",
@@ -155,6 +155,7 @@
"@folio/stripes": "^9.0.0",
"@folio/stripes-cli": "^3.0.0",
"@folio/stripes-core": "^10.0.0",
+ "@folio/stripes-marc-components": "^1.0.0",
"@folio/stripes-testing": "^4.2.0",
"@formatjs/cli": "^6.1.3",
"core-js": "^3.6.1",
@@ -181,11 +182,11 @@
"react-final-form-listeners": "^1.0.2",
"react-query": "^3.39.2",
"react-router-prop-types": "^1.0.4",
- "react-to-print": "^2.14.11",
"uuid": "^8.3.2"
},
"peerDependencies": {
"@folio/stripes": "^9.0.0",
+ "@folio/stripes-marc-components": "^1.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intl": "^6.4.4",
diff --git a/src/QuickMarcEditor/QuickMarcEditWrapper.js b/src/QuickMarcEditor/QuickMarcEditWrapper.js
index d9b1879c..3cc13dbe 100644
--- a/src/QuickMarcEditor/QuickMarcEditWrapper.js
+++ b/src/QuickMarcEditor/QuickMarcEditWrapper.js
@@ -12,6 +12,7 @@ import {
useStripes,
} from '@folio/stripes/core';
import { useShowCallout } from '@folio/stripes-acq-components';
+import { getHeaders } from '@folio/stripes-marc-components';
import QuickMarcEditor from './QuickMarcEditor';
import { useAuthorityLinking } from '../hooks';
@@ -36,7 +37,6 @@ import {
autopopulateFixedField,
autopopulatePhysDescriptionField,
autopopulateMaterialCharsField,
- getHeaders,
applyCentralTenantInHeaders,
} from './utils';
import {
diff --git a/src/QuickMarcEditor/QuickMarcEditor.test.js b/src/QuickMarcEditor/QuickMarcEditor.test.js
index 72ee7253..632e31ae 100644
--- a/src/QuickMarcEditor/QuickMarcEditor.test.js
+++ b/src/QuickMarcEditor/QuickMarcEditor.test.js
@@ -28,10 +28,14 @@ jest.mock('react-router', () => ({
jest.mock('../queries', () => ({
...jest.requireActual('../queries'),
- useAuthorityLinkingRules: jest.fn().mockReturnValue({ linkingRules: [] }),
useLinkSuggestions: jest.fn().mockReturnValue({ isLoading: false, fetchLinkSuggestions: jest.fn() }),
}));
+jest.mock('@folio/stripes-marc-components', () => ({
+ ...jest.requireActual('@folio/stripes-marc-components'),
+ useAuthorityLinkingRules: jest.fn().mockReturnValue({ linkingRules: [] }),
+}));
+
jest.mock('@folio/stripes-acq-components', () => ({
...jest.requireActual('@folio/stripes-acq-components'),
useShowCallout: jest.fn(),
diff --git a/src/QuickMarcEditor/QuickMarcEditorContainer.js b/src/QuickMarcEditor/QuickMarcEditorContainer.js
index ddd4927f..a122daee 100644
--- a/src/QuickMarcEditor/QuickMarcEditorContainer.js
+++ b/src/QuickMarcEditor/QuickMarcEditorContainer.js
@@ -18,6 +18,7 @@ import {
baseManifest,
useShowCallout,
} from '@folio/stripes-acq-components';
+import { getHeaders } from '@folio/stripes-marc-components';
import {
EXTERNAL_INSTANCE_APIS,
@@ -36,7 +37,6 @@ import {
splitFields,
getCreateBibMarcRecordResponse,
getCreateAuthorityMarcRecordResponse,
- getHeaders,
applyCentralTenantInHeaders,
} from './utils';
import { QUICK_MARC_ACTIONS } from './constants';
diff --git a/src/QuickMarcEditor/QuickMarcEditorContainer.test.js b/src/QuickMarcEditor/QuickMarcEditorContainer.test.js
index abf60c10..50860a15 100644
--- a/src/QuickMarcEditor/QuickMarcEditorContainer.test.js
+++ b/src/QuickMarcEditor/QuickMarcEditorContainer.test.js
@@ -55,12 +55,16 @@ jest.mock('react-router', () => ({
withRouter: Component => props => ,
}));
-jest.mock('../queries', () => ({
- ...jest.requireActual('../queries'),
+jest.mock('@folio/stripes-marc-components', () => ({
+ ...jest.requireActual('@folio/stripes-marc-components'),
useAuthorityLinkingRules: jest.fn().mockReturnValue({
linkingRules: [],
isLoading: false,
}),
+}));
+
+jest.mock('../queries', () => ({
+ ...jest.requireActual('../queries'),
useAuthoritySourceFiles: jest.fn().mockReturnValue({
sourceFiles: [],
isLoading: false,
diff --git a/src/QuickMarcEditor/QuickMarcEditorRows/QuickMarcEditorRows.test.js b/src/QuickMarcEditor/QuickMarcEditorRows/QuickMarcEditorRows.test.js
index 67a199a9..61e4e28d 100644
--- a/src/QuickMarcEditor/QuickMarcEditorRows/QuickMarcEditorRows.test.js
+++ b/src/QuickMarcEditor/QuickMarcEditorRows/QuickMarcEditorRows.test.js
@@ -47,12 +47,16 @@ jest.mock('../../hooks', () => ({
}),
}));
-jest.mock('../../queries', () => ({
- ...jest.requireActual('../../queries'),
+jest.mock('@folio/stripes-marc-components', () => ({
+ ...jest.requireActual('@folio/stripes-marc-components'),
useAuthorityLinkingRules: jest.fn().mockReturnValue({
linkingRules: [],
isLoading: false,
}),
+}));
+
+jest.mock('../../queries', () => ({
+ ...jest.requireActual('../../queries'),
useAuthoritySourceFiles: jest.fn().mockResolvedValue({
sourceFiles: [],
isLoading: false,
diff --git a/src/QuickMarcEditor/utils.js b/src/QuickMarcEditor/utils.js
index 91be5cc6..002db85a 100644
--- a/src/QuickMarcEditor/utils.js
+++ b/src/QuickMarcEditor/utils.js
@@ -1529,32 +1529,6 @@ export const hydrateForLinkSuggestions = (marcRecord, fields) => ({
_actionType: 'view',
});
-export const getHeaders = (tenant, token, locale, method = 'GET') => {
- // This is taken from stripes-connect/OkapiResource.js
- const headers = {
- POST: {
- Accept: 'application/json',
- },
- DELETE: {
- Accept: 'text/plain',
- },
- GET: {
- Accept: 'application/json',
- },
- PUT: {
- Accept: 'text/plain',
- },
- };
-
- return {
- ...headers[method],
- 'Accept-Language': locale,
- 'Content-Type': 'application/json',
- 'X-Okapi-Tenant': tenant,
- ...(token && { 'X-Okapi-Token': token }),
- };
-};
-
export const changeTenantHeader = (ky, tenantId) => {
return ky.extend({
hooks: {
diff --git a/src/QuickMarcView/MarcContent/MarcContent.css b/src/QuickMarcView/MarcContent/MarcContent.css
deleted file mode 100644
index a6f14010..00000000
--- a/src/QuickMarcView/MarcContent/MarcContent.css
+++ /dev/null
@@ -1,14 +0,0 @@
-.marcWrapper {
- margin-left: 20px;
-}
-
-.marc {
- table-layout: fixed;
- border: 0;
- font-family: courier;
- white-space: pre-wrap;
-
- & tr td {
- vertical-align: top;
- }
-}
diff --git a/src/QuickMarcView/MarcContent/MarcContent.js b/src/QuickMarcView/MarcContent/MarcContent.js
deleted file mode 100644
index 6a081c95..00000000
--- a/src/QuickMarcView/MarcContent/MarcContent.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import PropTypes from 'prop-types';
-
-import { Headline } from '@folio/stripes/components';
-
-import MarcField from '../MarcField';
-import { isControlField } from '../utils';
-import styles from './MarcContent.css';
-
-const propTypes = {
- isPrint: PropTypes.bool,
- marcTitle: PropTypes.node.isRequired,
- marc: PropTypes.object.isRequired,
- tenantId: PropTypes.string,
-};
-
-const MarcContent = ({
- marcTitle,
- marc,
- isPrint,
- tenantId,
-}) => {
- const showLinkIcon = marc.recordType === 'MARC_BIB';
- const parsedContent = marc.parsedRecord.content;
- const parsedMarc = {
- leader: parsedContent.leader,
- fields: [
- ...parsedContent.fields.filter(isControlField),
- ...parsedContent.fields.filter(field => !isControlField(field)),
- ],
- };
-
- return (
-
-
- {marcTitle}
-
-
-
-
-
- {`LEADER ${parsedMarc.leader}`}
- |
-
- {parsedMarc.fields.map((field, idx) => (
-
- ))}
-
-
-
- );
-};
-
-MarcContent.propTypes = propTypes;
-
-MarcContent.defaultProps = {
- isPrint: false,
-};
-
-export default MarcContent;
diff --git a/src/QuickMarcView/MarcContent/MarcContent.test.js b/src/QuickMarcView/MarcContent/MarcContent.test.js
deleted file mode 100644
index ecc65556..00000000
--- a/src/QuickMarcView/MarcContent/MarcContent.test.js
+++ /dev/null
@@ -1,67 +0,0 @@
-import React from 'react';
-import { render } from '@folio/jest-config-stripes/testing-library/react';
-
-import { runAxeTest } from '@folio/stripes-testing';
-
-import Harness from '../../../test/jest/helpers/harness';
-
-import MarcContent from './MarcContent';
-
-jest.mock('../MarcField', () => jest.fn(() =>
MarcField |
));
-
-const marc = {
- parsedRecord: {
- id: 'a178daf3-b10a-4ff9-a4bf-703a0091f043',
- content: {
- fields: [{
- '001': 'in00000000140',
- }, {
- '008': '120126r20122010nyu b 001 0 eng ',
- }],
- leader: '00331cam a2200085 a 4500',
- },
- },
- recordType: 'MARC_BIB',
-};
-
-const renderMarcContent = (props = {}) => render(
-
- fakeMarkTitle>}
- marc={marc}
- {...props}
- />
- ,
-);
-
-describe('Given MarcContent', () => {
- beforeEach(() => {
- jest.clearAllMocks();
- });
-
- it('should render with no axe errors', async () => {
- const { container } = renderMarcContent();
-
- await runAxeTest({
- rootNode: container,
- });
- });
-
- it('should show the marc title', () => {
- const { getByText } = renderMarcContent();
-
- expect(getByText('fakeMarkTitle')).toBeVisible();
- });
-
- it('should display the content of the marc record', () => {
- const { getByText } = renderMarcContent();
-
- expect(getByText('LEADER 00331cam a2200085 a 4500')).toBeVisible();
- });
-
- it('should render list of marc fields', () => {
- const { getAllByText } = renderMarcContent();
-
- expect(getAllByText('MarcField').length).toBe(2);
- });
-});
diff --git a/src/QuickMarcView/MarcContent/index.js b/src/QuickMarcView/MarcContent/index.js
deleted file mode 100644
index 3f463927..00000000
--- a/src/QuickMarcView/MarcContent/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './MarcContent';
diff --git a/src/QuickMarcView/MarcField.css b/src/QuickMarcView/MarcField.css
deleted file mode 100644
index 479c4b7a..00000000
--- a/src/QuickMarcView/MarcField.css
+++ /dev/null
@@ -1,3 +0,0 @@
-.indicators {
- width: 30px;
-}
diff --git a/src/QuickMarcView/MarcField.js b/src/QuickMarcView/MarcField.js
deleted file mode 100644
index 03fc981f..00000000
--- a/src/QuickMarcView/MarcField.js
+++ /dev/null
@@ -1,122 +0,0 @@
-import React, {
- Fragment,
- useCallback,
-} from 'react';
-import { useIntl } from 'react-intl';
-import { Link } from 'react-router-dom';
-import PropTypes from 'prop-types';
-
-import { AppIcon } from '@folio/stripes/core';
-import { Tooltip } from '@folio/stripes/components';
-
-import { useAuthorityLinking } from '../hooks';
-import { normalizeIndicator } from './utils';
-
-import styles from './MarcField.css';
-
-const propTypes = {
- field: PropTypes.object.isRequired,
- isPrint: PropTypes.bool,
- showLinkIcon: PropTypes.bool.isRequired,
- tenantId: PropTypes.string,
-};
-
-const MarcField = ({
- field,
- showLinkIcon,
- isPrint,
- tenantId,
-}) => {
- const intl = useIntl();
- const { linkableBibFields } = useAuthorityLinking({ tenantId });
-
- const fieldTag = Object.keys(field)[0];
- const hasIndicators = typeof field[fieldTag] !== 'string';
- const subFields = hasIndicators
- ? field[fieldTag].subfields.map((subFieldTag, index) => {
- const subKey = Object.keys(subFieldTag)[0];
-
- const subfieldValue = field[fieldTag].isHighlighted
- ? {subFieldTag[subKey]}
- : subFieldTag[subKey];
-
- return (
-
- ‡
- {subKey}
- {' '}
- {subfieldValue}
- {' '}
-
- );
- })
- : field[fieldTag].replace(/\\/g, ' ');
-
- const renderLinkIcon = useCallback(() => {
- const isLinkableField = linkableBibFields.includes(fieldTag);
-
- if (!hasIndicators || isPrint || !isLinkableField) {
- return null;
- }
-
- // get authority record id from $9 subfield
- const authorityId = field[fieldTag].subfields.find(subfield => Boolean(subfield['9']))?.['9'];
-
- if (!authorityId) {
- return null;
- }
-
- return (
-
- {({ ref, ariaIds }) => (
-
-
-
- )}
-
- );
- }, [field, fieldTag, intl, hasIndicators, isPrint, linkableBibFields]);
-
- return (
-
-
- {showLinkIcon && renderLinkIcon()}
- |
-
- {fieldTag}
- |
-
- {
- hasIndicators && (
-
- {`${normalizeIndicator(field[fieldTag].ind1)} ${normalizeIndicator(field[fieldTag].ind2)}`}
- |
- )
- }
-
-
- {subFields}
- |
-
- );
-};
-
-MarcField.propTypes = propTypes;
-
-MarcField.defaultProps = {
- isPrint: false,
-};
-
-export default MarcField;
diff --git a/src/QuickMarcView/PrintPopup/PrintPopup.css b/src/QuickMarcView/PrintPopup/PrintPopup.css
deleted file mode 100644
index d3d4cb06..00000000
--- a/src/QuickMarcView/PrintPopup/PrintPopup.css
+++ /dev/null
@@ -1,22 +0,0 @@
-.hidden {
- display: none;
-}
-
-.paneTitle {
- position: relative;
- flex: 1;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 100%;
- font-size: var(--font-size-medium);
- font-weight: var(--text-weight-bold);
- letter-spacing: 0.04em;
- color: var(--color-text);
-
- & span {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
-}
diff --git a/src/QuickMarcView/PrintPopup/PrintPopup.js b/src/QuickMarcView/PrintPopup/PrintPopup.js
deleted file mode 100644
index a39c0ec3..00000000
--- a/src/QuickMarcView/PrintPopup/PrintPopup.js
+++ /dev/null
@@ -1,75 +0,0 @@
-import React, { useEffect, useRef } from 'react';
-import { useReactToPrint } from 'react-to-print';
-import PropTypes from 'prop-types';
-
-import MarcContent from '../MarcContent';
-import styles from './PrintPopup.css';
-
-const PrintPopup = ({
- marc,
- paneTitle,
- marcTitle,
- onAfterPrint,
-}) => {
- const contentToPrintRef = useRef(null);
-
- const popupStyles = `
- @page {
- size: A4 auto;
- margin: 30px;
- }
-
- @media print {
- html, body {
- height: auto !important;
- overflow: initial !important;
- color-adjust: exact;
- -webkit-print-color-adjust: exact;
- }
- }
- `;
-
- const handlePrint = useReactToPrint({
- content: () => contentToPrintRef.current,
- pageStyle: popupStyles,
- onAfterPrint,
- });
-
- useEffect(() => {
- handlePrint();
- }, [handlePrint]);
-
- return (
-
-
- {paneTitle &&
- <>
-
-
- {paneTitle}
-
-
-
- >
- }
-
-
-
- );
-};
-
-PrintPopup.propTypes = {
- marc: PropTypes.object.isRequired,
- marcTitle: PropTypes.node.isRequired,
- onAfterPrint: PropTypes.func.isRequired,
- paneTitle: PropTypes.oneOfType([
- PropTypes.node,
- PropTypes.string,
- ]),
-};
-
-export default PrintPopup;
diff --git a/src/QuickMarcView/PrintPopup/PrintPopup.test.js b/src/QuickMarcView/PrintPopup/PrintPopup.test.js
deleted file mode 100644
index 8082bd1f..00000000
--- a/src/QuickMarcView/PrintPopup/PrintPopup.test.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import React from 'react';
-import { render } from '@folio/jest-config-stripes/testing-library/react';
-
-import { runAxeTest } from '@folio/stripes-testing';
-
-import PrintPopup from './PrintPopup';
-
-jest.mock('../MarcContent', () => jest.fn().mockReturnValue('MarcContent'));
-
-const renderPrintPopup = (props = {}) => render(
- fakeMarkTitle>}
- onAfterPrint={jest.fn()}
- {...props}
- />,
-);
-
-describe('Given PrintPopup', () => {
- beforeEach(() => {
- jest.clearAllMocks();
- });
-
- it('should render with no axe errors', async () => {
- const { container } = renderPrintPopup();
-
- await runAxeTest({
- rootNode: container,
- });
- });
-
- it('should show the pane title if a paneTitle prop is given', () => {
- const { getByText } = renderPrintPopup();
-
- expect(getByText('fakePaneTitle')).toBeVisible();
- });
-
- it('should not show the pane title if a paneTitle prop is not given', () => {
- const { queryByTestId } = renderPrintPopup({ paneTitle: undefined });
-
- expect(queryByTestId('print-popup-title')).not.toBeInTheDocument();
- });
-
- it('should display the content of the marc record', () => {
- const { getByText } = renderPrintPopup();
-
- expect(getByText('MarcContent')).toBeVisible();
- });
-});
diff --git a/src/QuickMarcView/PrintPopup/index.js b/src/QuickMarcView/PrintPopup/index.js
deleted file mode 100644
index f959c3b5..00000000
--- a/src/QuickMarcView/PrintPopup/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './PrintPopup';
diff --git a/src/QuickMarcView/QuickMarcView.js b/src/QuickMarcView/QuickMarcView.js
deleted file mode 100644
index ee88d7f7..00000000
--- a/src/QuickMarcView/QuickMarcView.js
+++ /dev/null
@@ -1,81 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-
-import {
- Pane,
- Paneset,
-} from '@folio/stripes/components';
-
-import MarcContent from './MarcContent';
-
-const propTypes = {
- isPaneset: PropTypes.bool,
- lastMenu: PropTypes.node,
- marc: PropTypes.object.isRequired,
- marcTitle: PropTypes.node.isRequired,
- paneTitle: PropTypes.oneOfType([
- PropTypes.node,
- PropTypes.string,
- ]).isRequired,
- paneHeight: PropTypes.string,
- paneSub: PropTypes.oneOfType([
- PropTypes.node,
- PropTypes.string,
- ]),
- onClose: PropTypes.func.isRequired,
- paneWidth: PropTypes.string,
- tenantId: PropTypes.string,
-};
-
-const QuickMarcView = ({
- paneTitle,
- paneSub,
- paneHeight,
- marcTitle,
- marc,
- onClose,
- paneWidth,
- lastMenu,
- isPaneset,
- tenantId,
-}) => {
- const renderContent = () => (
-
-
-
- );
-
- return isPaneset
- ? (
-
- {renderContent()}
-
- )
- : renderContent();
-};
-
-QuickMarcView.propTypes = propTypes;
-QuickMarcView.defaultProps = {
- isPaneset: true,
- paneHeight: null,
-};
-
-export default QuickMarcView;
diff --git a/src/QuickMarcView/QuickMarcView.test.js b/src/QuickMarcView/QuickMarcView.test.js
deleted file mode 100644
index b3cad1aa..00000000
--- a/src/QuickMarcView/QuickMarcView.test.js
+++ /dev/null
@@ -1,160 +0,0 @@
-import React from 'react';
-import { render } from '@folio/jest-config-stripes/testing-library/react';
-
-import { runAxeTest } from '@folio/stripes-testing';
-
-import QuickMarcView from './QuickMarcView';
-
-import Harness from '../../test/jest/helpers/harness';
-
-jest.mock('../hooks', () => ({
- ...jest.requireActual('../hooks'),
- useAuthorityLinking: jest.fn().mockReturnValue({
- linkAuthority: jest.fn(),
- linkableBibFields: ['100', '240'],
- sourceFiles: [{ id: 'af045f2f-e851-4613-984c-4bc13430454a' }],
- }),
-}));
-
-const marc = {
- parsedRecord: {
- id: 'a178daf3-b10a-4ff9-a4bf-703a0091f043',
- content: {
- fields: [{
- '001': 'in00000000140',
- }, {
- '008': '120126r20122010nyu b 001 0 eng ',
- }, {
- '005': '20211207090250.8',
- }, {
- '100': {
- 'ind1': '/',
- 'ind2': '/',
- subfields: [{
- a: 'Some controlled value',
- }, {
- 9: 'authority-id',
- }],
- },
- }, {
- '245': {
- 'ind1': '1',
- 'ind2': '0',
- subfields: [{
- a: 'Across the line of control :',
- }, {
- b: 'inside Pakistan-administered Jammu and Kashmir /',
- }, {
- b: 'Luv Puri.',
- }],
- isHighlighted: true,
- },
- }, {
- '999': {
- ind1: 'f',
- ind2: 'f',
- subfields: [{
- s: '225f733f-8231-4d48-b104-a9c56d675eec',
- }, {
- i: '225f733f-8231-4d48-b104-a9c56d675eec',
- }],
- },
- }],
- leader: '00331cam a2200085 a 4500',
- },
- },
- recordType: 'MARC_BIB',
-};
-
-const mockOnClose = jest.fn();
-
-const renderQuickMarcView = (props = {}) => render(
-
-
- ,
-);
-
-describe('Given QuickMarcView', () => {
- it('should render with no axe errors', async () => {
- const { container } = renderQuickMarcView();
-
- await runAxeTest({
- rootNode: container,
- });
- });
-
- it('should show pane title', () => {
- const { getByText } = renderQuickMarcView();
-
- expect(getByText('Pane title')).toBeDefined();
- });
-
- it('should show pane sub', () => {
- const { getByText } = renderQuickMarcView();
-
- expect(getByText('Pane sub')).toBeDefined();
- });
-
- it('should show MARC title', () => {
- const { getByText } = renderQuickMarcView();
-
- expect(getByText('MARC title')).toBeDefined();
- });
-
- it('should show MARC leader', () => {
- const { getByText } = renderQuickMarcView();
-
- expect(getByText(`LEADER ${marc.parsedRecord.content.leader}`)).toBeDefined();
- });
-
- it('should render paneset wrapper', () => {
- const { getByTestId } = renderQuickMarcView();
-
- expect(getByTestId('qm-view-paneset')).toBeDefined();
- });
-
- describe('when a field has isHighlighted flag', () => {
- it('should highlight the field content', () => {
- const { container } = renderQuickMarcView();
-
- const highlightedContent = [...container.querySelectorAll('mark')].map(mark => mark.textContent).join(' ');
-
- expect(highlightedContent).toEqual('Across the line of control : inside Pakistan-administered Jammu and Kashmir / Luv Puri.');
- });
- });
-
- describe('when there is a linked field', () => {
- it('should display authority link', () => {
- const { getByTestId } = renderQuickMarcView();
-
- expect(getByTestId('authority-app-link-authority-id')).toBeDefined();
- });
- });
-
- describe('when "isPaneset" prop is false', () => {
- it('should not render paneset wrapper', () => {
- const { queryByTestId } = renderQuickMarcView({
- isPaneset: false,
- });
-
- expect(queryByTestId('qm-view-paneset')).toBeNull();
- });
- });
-
- describe('when present "lastMenu" prop', () => {
- it('should render "lastMenu" prop', () => {
- const { getByText } = renderQuickMarcView({
- lastMenu: Last Menu Node
,
- });
-
- expect(getByText('Last Menu Node')).toBeDefined();
- });
- });
-});
diff --git a/src/QuickMarcView/index.js b/src/QuickMarcView/index.js
deleted file mode 100644
index 45a23a61..00000000
--- a/src/QuickMarcView/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export { default as QuickMarcView } from './QuickMarcView';
diff --git a/src/QuickMarcView/utils.js b/src/QuickMarcView/utils.js
deleted file mode 100644
index ca7a4a5d..00000000
--- a/src/QuickMarcView/utils.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export const isControlField = field => (Object.keys(field)[0]).startsWith('00');
-
-export const normalizeIndicator = indictor => indictor.replace(/\\/g, ' ');
diff --git a/src/hooks/useAuthorityLinking/useAuthorityLinking.js b/src/hooks/useAuthorityLinking/useAuthorityLinking.js
index 1ef8d26e..efa11a36 100644
--- a/src/hooks/useAuthorityLinking/useAuthorityLinking.js
+++ b/src/hooks/useAuthorityLinking/useAuthorityLinking.js
@@ -8,10 +8,10 @@ import omit from 'lodash/omit';
import pick from 'lodash/pick';
import { useStripes } from '@folio/stripes/core';
+import { useAuthorityLinkingRules } from '@folio/stripes-marc-components';
import {
useAuthoritySourceFiles,
- useAuthorityLinkingRules,
useLinkSuggestions,
} from '../../queries';
diff --git a/src/hooks/useAuthorityLinking/useAuthorityLinking.test.js b/src/hooks/useAuthorityLinking/useAuthorityLinking.test.js
index be4f5733..7fdb5f4f 100644
--- a/src/hooks/useAuthorityLinking/useAuthorityLinking.test.js
+++ b/src/hooks/useAuthorityLinking/useAuthorityLinking.test.js
@@ -4,13 +4,11 @@ import {
QueryClientProvider,
} from 'react-query';
import { renderHook } from '@folio/jest-config-stripes/testing-library/react';
+import { useAuthorityLinkingRules } from '@folio/stripes-marc-components';
import { useLocation } from 'react-router-dom';
import useAuthorityLinking from './useAuthorityLinking';
-import {
- useAuthorityLinkingRules,
- useLinkSuggestions,
-} from '../../queries';
+import { useLinkSuggestions } from '../../queries';
import { MARC_TYPES } from '../../common/constants';
import { linkingRules } from '../../../test/jest/fixtures/linkingRules';
@@ -21,8 +19,12 @@ jest.mock('react-router-dom', () => ({
useLocation: jest.fn(),
}));
-jest.mock('../../queries', () => ({
+jest.mock('@folio/stripes-marc-components', () => ({
+ ...jest.requireActual('@folio/stripes-marc-components'),
useAuthorityLinkingRules: jest.fn(),
+}));
+
+jest.mock('../../queries', () => ({
useAuthoritySourceFiles: jest.fn().mockReturnValue({
sourceFiles: [{
id: '1',
diff --git a/src/queries/index.js b/src/queries/index.js
index 41987bab..76e302ef 100644
--- a/src/queries/index.js
+++ b/src/queries/index.js
@@ -1,6 +1,5 @@
export * from './useMarcSource';
export * from './useAuthoritySourceFiles';
-export * from './useAuthorityLinkingRules';
export * from './useAuthorityLinksCount';
export * from './useLinkSuggestions';
export * from './useUserTenantPermissions';
diff --git a/src/queries/useAuthorityLinkingRules/index.js b/src/queries/useAuthorityLinkingRules/index.js
deleted file mode 100644
index 43c4a0c6..00000000
--- a/src/queries/useAuthorityLinkingRules/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export { default as useAuthorityLinkingRules } from './useAuthorityLinkingRules';
diff --git a/src/queries/useAuthorityLinkingRules/useAuthorityLinkingRules.js b/src/queries/useAuthorityLinkingRules/useAuthorityLinkingRules.js
deleted file mode 100644
index a7a53c94..00000000
--- a/src/queries/useAuthorityLinkingRules/useAuthorityLinkingRules.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import { useQuery } from 'react-query';
-
-import { useNamespace } from '@folio/stripes/core';
-
-import { LINKING_RULES_API } from '../../common/constants';
-import { useTenantKy } from '../../temp';
-
-const useAuthorityLinkingRules = ({ tenantId } = {}) => {
- const ky = useTenantKy({ tenantId });
- const [namespace] = useNamespace({ key: 'authority-linking-rules' });
-
- const { isFetching, data } = useQuery(
- [namespace],
- async () => {
- return ky.get(LINKING_RULES_API).json();
- },
- );
-
- return ({
- linkingRules: data || [],
- isLoading: isFetching,
- });
-};
-
-export default useAuthorityLinkingRules;
diff --git a/src/queries/useAuthorityLinkingRules/useAuthorityLinkingRules.test.js b/src/queries/useAuthorityLinkingRules/useAuthorityLinkingRules.test.js
deleted file mode 100644
index daaad708..00000000
--- a/src/queries/useAuthorityLinkingRules/useAuthorityLinkingRules.test.js
+++ /dev/null
@@ -1,44 +0,0 @@
-import {
- QueryClient,
- QueryClientProvider,
-} from 'react-query';
-import { renderHook, act } from '@folio/jest-config-stripes/testing-library/react';
-
-import '../../../test/jest/__mock__';
-
-import { useOkapiKy } from '@folio/stripes/core';
-
-import useAuthorityLinkingRules from './useAuthorityLinkingRules';
-
-jest.mock('react-router-dom', () => ({
- ...jest.requireActual('react-router-dom'),
- useLocation: jest.fn(),
-}));
-
-const queryClient = new QueryClient();
-
-const wrapper = ({ children }) => (
-
- {children}
-
-);
-
-describe('Given useAuthorityLinkingRules', () => {
- const mockGet = jest.fn(() => ({
- json: () => Promise.resolve([]),
- }));
-
- beforeEach(() => {
- useOkapiKy.mockClear().mockReturnValue({
- get: mockGet,
- });
- });
-
- it('should fetch linking rules', async () => {
- const { result } = renderHook(() => useAuthorityLinkingRules(), { wrapper });
-
- await act(async () => !result.current.isLoading);
-
- expect(mockGet).toHaveBeenCalled();
- });
-});