From 51ef35e70b3a0f90e2e90c579e59d8d158a04a33 Mon Sep 17 00:00:00 2001 From: daniil-patckin Date: Tue, 14 Feb 2023 17:55:53 +0400 Subject: [PATCH 1/3] Remove print button from QuickMarckView --- src/QuickMarcView/QuickMarcView.js | 56 ++---------------------------- 1 file changed, 2 insertions(+), 54 deletions(-) diff --git a/src/QuickMarcView/QuickMarcView.js b/src/QuickMarcView/QuickMarcView.js index 3ac66c46..7ea4b5a1 100644 --- a/src/QuickMarcView/QuickMarcView.js +++ b/src/QuickMarcView/QuickMarcView.js @@ -1,17 +1,12 @@ -import React, { useState } from 'react'; -import { FormattedMessage } from 'react-intl'; +import React from 'react'; import PropTypes from 'prop-types'; -import { IfPermission } from '@folio/stripes/core'; import { - PaneMenu, Pane, Paneset, - Button, } from '@folio/stripes/components'; import MarcContent from './MarcContent'; -import PrintPopup from './PrintPopup'; const propTypes = { isPaneset: PropTypes.bool, @@ -42,45 +37,6 @@ const QuickMarcView = ({ lastMenu, isPaneset, }) => { - const [showPrintPopup, setShowPrintPopup] = useState(false); - - const isMarcBibRecord = marc.recordType === 'MARC_BIB'; - - const openPrintPopup = () => { - setShowPrintPopup(true); - }; - - const closePrintPopup = () => { - setShowPrintPopup(false); - }; - - const renderPrintButton = () => ( - - - - ); - - const optionalProps = {}; - - if (isMarcBibRecord && !lastMenu) { - optionalProps.lastMenu = renderPrintButton(); - } - - if (lastMenu) { - optionalProps.lastMenu = ( - - {lastMenu} - {isMarcBibRecord && renderPrintButton()} - - ); - } - const renderContent = () => ( - {showPrintPopup && ( - - )} ); From 4f221339195ba7bd90999906d68f6b3fc156deeb Mon Sep 17 00:00:00 2001 From: daniil-patckin Date: Tue, 14 Feb 2023 17:56:48 +0400 Subject: [PATCH 2/3] Made the paneTitle prop is optional --- src/QuickMarcView/PrintPopup/PrintPopup.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/QuickMarcView/PrintPopup/PrintPopup.js b/src/QuickMarcView/PrintPopup/PrintPopup.js index c5d734da..abc0672d 100644 --- a/src/QuickMarcView/PrintPopup/PrintPopup.js +++ b/src/QuickMarcView/PrintPopup/PrintPopup.js @@ -42,12 +42,16 @@ const PrintPopup = ({ return (
-

- - {paneTitle} - -

-
+ {paneTitle && + <> +

+ + {paneTitle} + +

+
+ + } Date: Wed, 15 Feb 2023 11:21:20 +0400 Subject: [PATCH 3/3] Add tests and changelog --- CHANGELOG.md | 1 + src/QuickMarcView/PrintPopup/PrintPopup.js | 2 +- .../PrintPopup/PrintPopup.test.js | 8 ++++- src/QuickMarcView/QuickMarcView.test.js | 31 +------------------ 4 files changed, 10 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 351f7a0f..eb2c4395 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ * [UIQM-375](https://issues.folio.org/browse/UIQM-375) Do not add "http://" to "base url" when user links "MARC Bib's" field with "MARC Authority" * [UIQM-386](https://issues.folio.org/browse/UIQM-386) Edit MARC authority | Add/Edit 010 $a when linking is based on 001. * [UIQM-385](https://issues.folio.org/browse/UIQM-385) Edit/Derive quickMARC | Allow user to drag text boxes to view all content +* [UIQM-351](https://issues.folio.org/browse/UIQM-351) MARC Authority | Print Source record ## [5.2.0](https://github.com/folio-org/ui-quick-marc/tree/v5.2.0) (2022-10-26) diff --git a/src/QuickMarcView/PrintPopup/PrintPopup.js b/src/QuickMarcView/PrintPopup/PrintPopup.js index abc0672d..a39c0ec3 100644 --- a/src/QuickMarcView/PrintPopup/PrintPopup.js +++ b/src/QuickMarcView/PrintPopup/PrintPopup.js @@ -44,7 +44,7 @@ const PrintPopup = ({
{paneTitle && <> -

+

{paneTitle} diff --git a/src/QuickMarcView/PrintPopup/PrintPopup.test.js b/src/QuickMarcView/PrintPopup/PrintPopup.test.js index a296b9b9..7c027131 100644 --- a/src/QuickMarcView/PrintPopup/PrintPopup.test.js +++ b/src/QuickMarcView/PrintPopup/PrintPopup.test.js @@ -30,12 +30,18 @@ describe('Given PrintPopup', () => { }); }); - it('should show the pane title', () => { + 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(); diff --git a/src/QuickMarcView/QuickMarcView.test.js b/src/QuickMarcView/QuickMarcView.test.js index e13c9e2e..79fd6e6f 100644 --- a/src/QuickMarcView/QuickMarcView.test.js +++ b/src/QuickMarcView/QuickMarcView.test.js @@ -1,5 +1,5 @@ import React from 'react'; -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { runAxeTest } from '@folio/stripes-testing'; @@ -148,33 +148,4 @@ describe('Given QuickMarcView', () => { expect(getByText('Last Menu Node')).toBeDefined(); }); }); - - describe('when it is the marc bib record', () => { - describe('and "lastMenu" is present', () => { - it('should render "lastMenu" and "Print" button', () => { - const { getByText } = renderQuickMarcView({ - lastMenu:
Last Menu Node
, - }); - - expect(getByText('Last Menu Node')).toBeDefined(); - expect(getByText('ui-quick-marc.print')).toBeDefined(); - }); - }); - - describe('and the "lastMenu" is not present', () => { - it('should render the "Print" button', () => { - const { getByText } = renderQuickMarcView(); - - expect(getByText('ui-quick-marc.print')).toBeDefined(); - }); - }); - - it('should display the print popup after clicking on the "Print" button', () => { - const { getByText, getByTestId } = renderQuickMarcView(); - - fireEvent.click(getByText('ui-quick-marc.print')); - - expect(getByTestId('print-popup')).toBeInTheDocument(); - }); - }); });