From 28df52d4c6377b1a252f285f915dd8b8b4ea6f39 Mon Sep 17 00:00:00 2001 From: Mariia Aloshyna <55138456+mariia-aloshyna@users.noreply.github.com> Date: Mon, 25 Nov 2024 19:41:04 +0200 Subject: [PATCH] UIIN-2890: React v19: refactor away from default props for functional components (#2673) --- CHANGELOG.md | 1 + src/Instance/HoldingsList/Holding/Holding.js | 17 ++--- .../HoldingsList/Holding/HoldingContainer.js | 10 +-- src/Instance/HoldingsList/HoldingsList.js | 13 ++-- .../HoldingsList/HoldingsListContainer.js | 6 +- .../InstanceAdministrativeView.js | 18 ++--- .../StatisticalCodesList.js | 6 +- .../InstanceClassificationView.js | 9 +-- .../InstanceContributorsView.js | 16 ++--- .../DescriptiveFormatsList.js | 9 +-- .../DescriptivePublicationsList.js | 6 +- .../InstanceDescriptiveView.js | 18 ++--- .../InstanceDetails/InstanceDetails.js | 16 ++--- .../InstanceElecAccessView.js | 9 +-- .../InstanceIdentifiersView.js | 9 +-- .../InstanceNotesView/InstanceNotesList.js | 6 +- .../InstanceNotesView/InstanceNotesView.js | 9 +-- .../InstanceTitle/InstanceTitle.js | 10 ++- .../AlternativeTitlesList.js | 13 ++-- .../InstanceTitleData/InstanceTitleData.js | 13 ++-- .../TitleSeriesStatements.js | 8 +-- .../ChildInstanceFields.js | 17 ++--- .../ParentInstanceFields.js | 17 ++--- .../HoldingsListMovement.js | 13 ++-- .../InstanceMovement/InstanceMovement.js | 13 ++-- .../InstanceMovementDetails.js | 13 ++-- .../InstanceMovementDetailsActions.js | 6 +- .../InstanceMovementDetailsContainer.js | 11 +-- src/Instance/ItemsList/ItemsList.js | 28 ++++---- .../AdministrativeNoteList.js | 6 +- .../FacetOptionFormatter.js | 10 ++- .../FilterNavigation/FilterNavigation.js | 8 +-- .../WarningMessage/WarningMessage.js | 13 ++-- src/edit/InstanceForm.js | 71 ++++++++++--------- src/edit/alternativeTitles.js | 18 ++--- src/edit/classificationFields.js | 18 ++--- src/edit/contributorFields.js | 20 ++---- src/edit/descriptionFields.js | 17 ++--- src/edit/editionFields.js | 17 ++--- src/edit/electronicAccessFields.js | 20 ++---- .../FormerHoldingsIdFields.js | 12 +--- .../HoldingsStatementFields.js | 12 +--- .../HoldingsStatementForIndexesFields.js | 12 +--- .../HoldingsStatementForSupplementsFields.js | 12 +--- .../holdings/repeatableFields/NoteFields.js | 14 ++-- .../ReceivingHistoryFields.js | 12 +--- src/edit/identifierFields.js | 18 ++--- src/edit/instanceFormatFields.js | 19 ++--- .../CirculationNotesFields.js | 17 ++--- .../FormerIdentifierFields.js | 12 +--- .../repeatableFields/YearCaptionFields.js | 12 +--- src/edit/languageFields.js | 17 ++--- src/edit/natureOfContentFields.js | 21 ++---- src/edit/noteFields.js | 28 +++----- src/edit/precedingTitleFields.js | 14 ++-- src/edit/publicationFields.js | 17 ++--- src/edit/publicationFrequencyFields.js | 17 ++--- src/edit/publicationRangeFields.js | 17 ++--- src/edit/seriesFields.js | 17 ++--- src/edit/statisticalCodeFields.js | 14 ++-- src/edit/succeedingTitleFields.js | 14 ++-- src/views/ItemStatus/ItemStatus.js | 13 ++-- 62 files changed, 291 insertions(+), 608 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ba22d5de..40ce5a0e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * *BREAKING* Rename quick-marc routes from `bib` to `bibliographic` and `duplicate` to `derive`. Refs UIIN-3120. * *BREAKING* Provide necessary props for browse lookup facets. Remove the facets state reset functionality. Refs UIIN-3099. * Add permission for "Share local instance" option on Member tenants. Refs UIIN-3140. +* React v19: refactor away from default props for functional components. Refs UIIN-2890. ## [12.0.3] (IN PROGRESS) diff --git a/src/Instance/HoldingsList/Holding/Holding.js b/src/Instance/HoldingsList/Holding/Holding.js index 8a0b1adb9..ff85c255b 100644 --- a/src/Instance/HoldingsList/Holding/Holding.js +++ b/src/Instance/HoldingsList/Holding/Holding.js @@ -15,19 +15,19 @@ const Holding = ({ holding, onViewHolding, onAddItem, - holdings, - draggable, - droppable, + holdings = [], + draggable = false, + droppable = false, selectHoldingsForDrag, isHoldingDragSelected, - isDraggable, - isItemsDroppable, + isDraggable = false, + isItemsDroppable = true, tenantId, showViewHoldingsButton, showAddItemButton, isBarcodeAsHotlink, instanceId, - pathToAccordionsState, + pathToAccordionsState = [], }) => { return (
@@ -94,9 +94,4 @@ Holding.propTypes = { pathToAccordionsState: PropTypes.arrayOf(PropTypes.string), }; -Holding.defaultProps = { - isItemsDroppable: true, - pathToAccordionsState: [], -}; - export default Holding; diff --git a/src/Instance/HoldingsList/Holding/HoldingContainer.js b/src/Instance/HoldingsList/Holding/HoldingContainer.js index 43fb667bc..2a1b5f55a 100644 --- a/src/Instance/HoldingsList/Holding/HoldingContainer.js +++ b/src/Instance/HoldingsList/Holding/HoldingContainer.js @@ -51,7 +51,7 @@ const DraggableHolding = ({ showAddItemButton, isBarcodeAsHotlink, instanceId, - pathToAccordionsState, + pathToAccordionsState = [], ...rest }) => { const rowStyles = useMemo(() => ( @@ -115,8 +115,6 @@ DraggableHolding.propTypes = { pathToAccordionsState: PropTypes.arrayOf(PropTypes.string), }; -DraggableHolding.defaultProps = { pathToAccordionsState: [] }; - const HoldingContainer = ({ location, history, @@ -125,11 +123,11 @@ const HoldingContainer = ({ isBarcodeAsHotlink, instance, holding, - isDraggable, + isDraggable = false, holdingIndex, draggingHoldingsCount, tenantId, - pathToAccordionsState, + pathToAccordionsState = [], ...rest }) => { const stripes = useStripes(); @@ -202,6 +200,4 @@ HoldingContainer.propTypes = { pathToAccordionsState: PropTypes.arrayOf(PropTypes.string), }; -HoldingContainer.defaultProps = { pathToAccordionsState: [] }; - export default withRouter(HoldingContainer); diff --git a/src/Instance/HoldingsList/HoldingsList.js b/src/Instance/HoldingsList/HoldingsList.js index 1f5c7bbb6..af8ad4d71 100644 --- a/src/Instance/HoldingsList/HoldingsList.js +++ b/src/Instance/HoldingsList/HoldingsList.js @@ -5,14 +5,14 @@ import { HoldingContainer } from './Holding'; const HoldingsList = ({ instance, - holdings, + holdings = [], tenantId, showViewHoldingsButton, showAddItemButton, isBarcodeAsHotlink, - pathToAccordionsState, - draggable, - droppable, + pathToAccordionsState = [], + draggable = false, + droppable = false, }) => holdings.map(holding => ( { const stripes = useStripes(); @@ -57,6 +57,4 @@ HoldingsListContainer.propTypes = { pathToAccordionsState: PropTypes.arrayOf(PropTypes.string), }; -HoldingsListContainer.defaultProps = { pathToAccordionsState: [] }; - export default HoldingsListContainer; diff --git a/src/Instance/InstanceDetails/InstanceAdministrativeView/InstanceAdministrativeView.js b/src/Instance/InstanceDetails/InstanceAdministrativeView/InstanceAdministrativeView.js index 541cdff26..3a884ec83 100644 --- a/src/Instance/InstanceDetails/InstanceAdministrativeView/InstanceAdministrativeView.js +++ b/src/Instance/InstanceDetails/InstanceAdministrativeView/InstanceAdministrativeView.js @@ -36,11 +36,11 @@ import StatisticalCodesList from './StatisticalCodesList'; const InstanceAdministrativeView = ({ id, - instance, - instanceStatuses, - issuanceModes, - statisticalCodes, - statisticalCodeTypes, + instance = {}, + instanceStatuses = [], + issuanceModes = [], + statisticalCodes = [], + statisticalCodeTypes = [], }) => { const { search } = useLocation(); @@ -212,12 +212,4 @@ InstanceAdministrativeView.propTypes = { statisticalCodeTypes: PropTypes.arrayOf(PropTypes.object), }; -InstanceAdministrativeView.defaultProps = { - instance: {}, - instanceStatuses: [], - issuanceModes: [], - statisticalCodes: [], - statisticalCodeTypes: [], -}; - export default InstanceAdministrativeView; diff --git a/src/Instance/InstanceDetails/InstanceAdministrativeView/StatisticalCodesList.js b/src/Instance/InstanceDetails/InstanceAdministrativeView/StatisticalCodesList.js index 7bf19b5d7..2fbc60868 100644 --- a/src/Instance/InstanceDetails/InstanceAdministrativeView/StatisticalCodesList.js +++ b/src/Instance/InstanceDetails/InstanceAdministrativeView/StatisticalCodesList.js @@ -31,7 +31,7 @@ const columnWidths = { }; const StatisticalCodesList = ({ - statisticalCodes, + statisticalCodes = [], }) => { const intl = useIntl(); @@ -57,8 +57,4 @@ StatisticalCodesList.propTypes = { statisticalCodes: PropTypes.arrayOf(PropTypes.object), }; -StatisticalCodesList.defaultProps = { - statisticalCodes: [], -}; - export default StatisticalCodesList; diff --git a/src/Instance/InstanceDetails/InstanceClassificationView/InstanceClassificationView.js b/src/Instance/InstanceDetails/InstanceClassificationView/InstanceClassificationView.js index eb0218a18..b6b14ccf9 100644 --- a/src/Instance/InstanceDetails/InstanceClassificationView/InstanceClassificationView.js +++ b/src/Instance/InstanceDetails/InstanceClassificationView/InstanceClassificationView.js @@ -47,8 +47,8 @@ const classificationsRowFormatter = { const InstanceClassificationView = ({ id, - classifications, - classificationTypes, + classifications = [], + classificationTypes = [], }) => { const intl = useIntl(); @@ -100,9 +100,4 @@ InstanceClassificationView.propTypes = { classificationTypes: PropTypes.arrayOf(PropTypes.object), }; -InstanceClassificationView.defaultProps = { - classifications: [], - classificationTypes: [], -}; - export default InstanceClassificationView; diff --git a/src/Instance/InstanceDetails/InstanceContributorsView/InstanceContributorsView.js b/src/Instance/InstanceDetails/InstanceContributorsView/InstanceContributorsView.js index 2c7119887..9bd586267 100644 --- a/src/Instance/InstanceDetails/InstanceContributorsView/InstanceContributorsView.js +++ b/src/Instance/InstanceDetails/InstanceContributorsView/InstanceContributorsView.js @@ -35,11 +35,11 @@ const columnWidths = { const InstanceContributorsView = ({ id, - contributors, - contributorTypes, - contributorNameTypes, source, - segment, + contributors = [], + contributorTypes = [], + contributorNameTypes = [], + segment = '', }) => { const intl = useIntl(); @@ -103,17 +103,11 @@ const InstanceContributorsView = ({ InstanceContributorsView.propTypes = { id: PropTypes.string.isRequired, + source: PropTypes.string.isRequired, contributors: PropTypes.arrayOf(PropTypes.object), contributorTypes: PropTypes.arrayOf(PropTypes.object), contributorNameTypes: PropTypes.arrayOf(PropTypes.object), - source: PropTypes.string.isRequired, segment: PropTypes.string, }; -InstanceContributorsView.defaultProps = { - contributors: [], - contributorTypes: [], - contributorNameTypes: [], -}; - export default InstanceContributorsView; diff --git a/src/Instance/InstanceDetails/InstanceDescriptiveView/DescriptiveFormatsList.js b/src/Instance/InstanceDetails/InstanceDescriptiveView/DescriptiveFormatsList.js index eb117b0a3..a2260f5e0 100644 --- a/src/Instance/InstanceDetails/InstanceDescriptiveView/DescriptiveFormatsList.js +++ b/src/Instance/InstanceDetails/InstanceDescriptiveView/DescriptiveFormatsList.js @@ -36,8 +36,8 @@ const columnWidths = { }; const DescriptiveFormatsList = ({ - formats, - resourceFormats, + formats = [], + resourceFormats = [], }) => { const intl = useIntl(); @@ -79,9 +79,4 @@ DescriptiveFormatsList.propTypes = { resourceFormats: PropTypes.arrayOf(PropTypes.object), }; -DescriptiveFormatsList.defaultProps = { - formats: [], - resourceFormats: [], -}; - export default DescriptiveFormatsList; diff --git a/src/Instance/InstanceDetails/InstanceDescriptiveView/DescriptivePublicationsList.js b/src/Instance/InstanceDetails/InstanceDescriptiveView/DescriptivePublicationsList.js index 038da3098..75814705f 100644 --- a/src/Instance/InstanceDetails/InstanceDescriptiveView/DescriptivePublicationsList.js +++ b/src/Instance/InstanceDetails/InstanceDescriptiveView/DescriptivePublicationsList.js @@ -36,7 +36,7 @@ const columnWidths = { }; const DescriptivePublicationsList = ({ - publications, + publications = [], }) => { const intl = useIntl(); @@ -61,8 +61,4 @@ DescriptivePublicationsList.propTypes = { publications: PropTypes.arrayOf(PropTypes.object), }; -DescriptivePublicationsList.defaultProps = { - publications: [], -}; - export default DescriptivePublicationsList; diff --git a/src/Instance/InstanceDetails/InstanceDescriptiveView/InstanceDescriptiveView.js b/src/Instance/InstanceDetails/InstanceDescriptiveView/InstanceDescriptiveView.js index fac9b4557..b7d745392 100644 --- a/src/Instance/InstanceDetails/InstanceDescriptiveView/InstanceDescriptiveView.js +++ b/src/Instance/InstanceDetails/InstanceDescriptiveView/InstanceDescriptiveView.js @@ -23,11 +23,11 @@ import { const InstanceDescriptiveView = ({ id, - instance, - resourceTypes, - resourceFormats, - natureOfContentTerms, - instanceDateTypes, + instance = {}, + resourceTypes = [], + resourceFormats = [], + natureOfContentTerms = [], + instanceDateTypes = [], }) => { const resourceType = useMemo(() => { return resourceTypes.find(type => type.id === instance.instanceTypeId) || {}; @@ -169,12 +169,4 @@ InstanceDescriptiveView.propTypes = { instanceDateTypes: PropTypes.arrayOf(PropTypes.object), }; -InstanceDescriptiveView.defaultProps = { - instance: {}, - resourceTypes: [], - resourceFormats: [], - natureOfContentTerms: [], - instanceDateTypes: [], -}; - export default InstanceDescriptiveView; diff --git a/src/Instance/InstanceDetails/InstanceDetails.js b/src/Instance/InstanceDetails/InstanceDetails.js index 9eb564ab3..cad55bb7f 100644 --- a/src/Instance/InstanceDetails/InstanceDetails.js +++ b/src/Instance/InstanceDetails/InstanceDetails.js @@ -72,13 +72,13 @@ const accordions = { const InstanceDetails = forwardRef(({ children, - instance, onClose, actionMenu, - tagsEnabled, mutateInstance, - userTenantPermissions, - isShared, + instance = {}, + userTenantPermissions = [], + tagsEnabled = false, + isShared = false, ...rest }, ref) => { const intl = useIntl(); @@ -316,9 +316,9 @@ const InstanceDetails = forwardRef(({ }); InstanceDetails.propTypes = { + onClose: PropTypes.func.isRequired, children: PropTypes.node, actionMenu: PropTypes.func, - onClose: PropTypes.func.isRequired, mutateInstance: PropTypes.func, instance: PropTypes.object, tagsToggle: PropTypes.func, @@ -327,10 +327,4 @@ InstanceDetails.propTypes = { isShared: PropTypes.bool, }; -InstanceDetails.defaultProps = { - instance: {}, - tagsEnabled: false, - isShared: false, -}; - export default InstanceDetails; diff --git a/src/Instance/InstanceDetails/InstanceElecAccessView/InstanceElecAccessView.js b/src/Instance/InstanceDetails/InstanceElecAccessView/InstanceElecAccessView.js index 9ab4111b1..9cbe95006 100644 --- a/src/Instance/InstanceDetails/InstanceElecAccessView/InstanceElecAccessView.js +++ b/src/Instance/InstanceDetails/InstanceElecAccessView/InstanceElecAccessView.js @@ -59,8 +59,8 @@ const getFormatter = (elAccessRelationshipsMap) => ({ const InstanceElecAccessView = ({ id, - electronicAccessLines, - electronicAccessRelationships, + electronicAccessLines = [], + electronicAccessRelationships = [], }) => { const intl = useIntl(); @@ -101,9 +101,4 @@ InstanceElecAccessView.propTypes = { electronicAccessRelationships: PropTypes.arrayOf(PropTypes.object), }; -InstanceElecAccessView.defaultProps = { - electronicAccessLines: [], - electronicAccessRelationships: [], -}; - export default InstanceElecAccessView; diff --git a/src/Instance/InstanceDetails/InstanceIdentifiersView/InstanceIdentifiersView.js b/src/Instance/InstanceDetails/InstanceIdentifiersView/InstanceIdentifiersView.js index a4a1332f6..017b28a30 100644 --- a/src/Instance/InstanceDetails/InstanceIdentifiersView/InstanceIdentifiersView.js +++ b/src/Instance/InstanceDetails/InstanceIdentifiersView/InstanceIdentifiersView.js @@ -34,8 +34,8 @@ const formatter = { const InstanceIdentifiersView = ({ id, - identifiers, - identifierTypes, + identifiers = [], + identifierTypes = [], }) => { const intl = useIntl(); @@ -87,9 +87,4 @@ InstanceIdentifiersView.propTypes = { identifierTypes: PropTypes.arrayOf(PropTypes.object), }; -InstanceIdentifiersView.defaultProps = { - identifiers: [], - identifierTypes: [], -}; - export default InstanceIdentifiersView; diff --git a/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesList.js b/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesList.js index bdbfb59e7..37f0ddd21 100644 --- a/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesList.js +++ b/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesList.js @@ -32,8 +32,8 @@ const formatter = { const InstanceNotesList = ({ id, - notes, notesType, + notes = [], }) => { const intl = useIntl(); @@ -61,8 +61,4 @@ InstanceNotesList.propTypes = { notes: PropTypes.arrayOf(PropTypes.object), }; -InstanceNotesList.defaultProps = { - notes: [], -}; - export default InstanceNotesList; diff --git a/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesView.js b/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesView.js index ff7f7947b..742208133 100644 --- a/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesView.js +++ b/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesView.js @@ -18,8 +18,8 @@ import InstanceNotesList from './InstanceNotesList'; const InstanceNotesView = ({ id, - instance, - noteTypes, + instance = {}, + noteTypes = [], }) => { const notesGroups = useMemo(() => { if (isEmpty(instance.notes)) { @@ -62,9 +62,4 @@ InstanceNotesView.propTypes = { noteTypes: PropTypes.arrayOf(PropTypes.object), }; -InstanceNotesView.defaultProps = { - instance: {}, - noteTypes: [], -}; - export default InstanceNotesView; diff --git a/src/Instance/InstanceDetails/InstanceTitle/InstanceTitle.js b/src/Instance/InstanceDetails/InstanceTitle/InstanceTitle.js index 0f3a30ee8..5dafb3e69 100644 --- a/src/Instance/InstanceDetails/InstanceTitle/InstanceTitle.js +++ b/src/Instance/InstanceDetails/InstanceTitle/InstanceTitle.js @@ -12,7 +12,10 @@ import { Headline, } from '@folio/stripes/components'; -const InstanceTitle = ({ instance, instanceTypes }) => { +const InstanceTitle = ({ + instance = {}, + instanceTypes = [], +}) => { const instanceTypeName = useMemo(() => { return instanceTypes.find(instanceType => instanceType.id === instance.instanceTypeId)?.name; }, [instance, instanceTypes]); @@ -60,9 +63,4 @@ InstanceTitle.propTypes = { instanceTypes: PropTypes.arrayOf(PropTypes.object), }; -InstanceTitle.defaultProps = { - instance: {}, - instanceTypes: [], -}; - export default InstanceTitle; diff --git a/src/Instance/InstanceDetails/InstanceTitleData/AlternativeTitlesList.js b/src/Instance/InstanceDetails/InstanceTitleData/AlternativeTitlesList.js index a0d268475..8f2afe93d 100644 --- a/src/Instance/InstanceDetails/InstanceTitleData/AlternativeTitlesList.js +++ b/src/Instance/InstanceDetails/InstanceTitleData/AlternativeTitlesList.js @@ -27,10 +27,10 @@ const columnWidths = { }; const AlternativeTitlesList = ({ - titles, - titleTypes, source, segment, + titles = [], + titleTypes = [], }) => { const intl = useIntl(); @@ -79,15 +79,10 @@ const AlternativeTitlesList = ({ }; AlternativeTitlesList.propTypes = { - titles: PropTypes.arrayOf(PropTypes.object), - titleTypes: PropTypes.arrayOf(PropTypes.object), segment: PropTypes.oneOf([Object.values(segments)]).isRequired, source: PropTypes.string.isRequired, -}; - -AlternativeTitlesList.defaultProps = { - titles: [], - titleTypes: [], + titles: PropTypes.arrayOf(PropTypes.object), + titleTypes: PropTypes.arrayOf(PropTypes.object), }; export default AlternativeTitlesList; diff --git a/src/Instance/InstanceDetails/InstanceTitleData/InstanceTitleData.js b/src/Instance/InstanceDetails/InstanceTitleData/InstanceTitleData.js index f11e10e36..016b90345 100644 --- a/src/Instance/InstanceDetails/InstanceTitleData/InstanceTitleData.js +++ b/src/Instance/InstanceDetails/InstanceTitleData/InstanceTitleData.js @@ -22,10 +22,10 @@ import TitleSeriesStatements from './TitleSeriesStatements'; const InstanceTitleData = ({ id, - instance, - titleTypes, - identifierTypesById, segment, + instance = {}, + titleTypes = [], + identifierTypesById = {}, }) => { const precedingTitles = useMemo(() => { return checkIfArrayIsEmpty(instance.precedingTitles); @@ -100,15 +100,10 @@ const InstanceTitleData = ({ InstanceTitleData.propTypes = { id: PropTypes.string.isRequired, - instance: PropTypes.object, segment: PropTypes.string.isRequired, + instance: PropTypes.object, titleTypes: PropTypes.arrayOf(PropTypes.object), identifierTypesById: PropTypes.object, }; -InstanceTitleData.defaultProps = { - instance: {}, - titleTypes: [], -}; - export default InstanceTitleData; diff --git a/src/Instance/InstanceDetails/InstanceTitleData/TitleSeriesStatements.js b/src/Instance/InstanceDetails/InstanceTitleData/TitleSeriesStatements.js index e2da94ff4..abd137cbd 100644 --- a/src/Instance/InstanceDetails/InstanceTitleData/TitleSeriesStatements.js +++ b/src/Instance/InstanceDetails/InstanceTitleData/TitleSeriesStatements.js @@ -16,9 +16,9 @@ const getColumnMapping = intl => ({ }); const TitleSeriesStatements = ({ - seriesStatements, segment, source, + seriesStatements = [], }) => { const intl = useIntl(); @@ -49,13 +49,9 @@ const TitleSeriesStatements = ({ }; TitleSeriesStatements.propTypes = { - seriesStatements: PropTypes.arrayOf(PropTypes.string), segment: PropTypes.oneOf(Object.values(segments)).isRequired, source: PropTypes.string.isRequired, -}; - -TitleSeriesStatements.defaultProps = { - seriesStatements: [], + seriesStatements: PropTypes.arrayOf(PropTypes.string), }; export default TitleSeriesStatements; diff --git a/src/Instance/InstanceEdit/ChildInstanceFields/ChildInstanceFields.js b/src/Instance/InstanceEdit/ChildInstanceFields/ChildInstanceFields.js index d46578649..03c13dd0f 100644 --- a/src/Instance/InstanceEdit/ChildInstanceFields/ChildInstanceFields.js +++ b/src/Instance/InstanceEdit/ChildInstanceFields/ChildInstanceFields.js @@ -8,11 +8,11 @@ import { RepeatableField } from '@folio/stripes/components'; import InstanceField from '../InstanceField'; const ChildInstanceFields = ({ - canAdd, - canEdit, - canDelete, - isDisabled, - relationshipTypes, + canAdd = true, + canEdit = true, + canDelete = true, + isDisabled = false, + relationshipTypes = [], }) => ( } @@ -44,11 +44,4 @@ ChildInstanceFields.propTypes = { relationshipTypes: PropTypes.arrayOf(PropTypes.object), }; -ChildInstanceFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, - isDisabled: false, -}; - export default ChildInstanceFields; diff --git a/src/Instance/InstanceEdit/ParentInstanceFields/ParentInstanceFields.js b/src/Instance/InstanceEdit/ParentInstanceFields/ParentInstanceFields.js index bfe861040..0b23b6f35 100644 --- a/src/Instance/InstanceEdit/ParentInstanceFields/ParentInstanceFields.js +++ b/src/Instance/InstanceEdit/ParentInstanceFields/ParentInstanceFields.js @@ -8,11 +8,11 @@ import { RepeatableField } from '@folio/stripes/components'; import InstanceField from '../InstanceField'; const ParentInstanceFields = ({ - canAdd, - canEdit, - canDelete, - isDisabled, - relationshipTypes, + canAdd = true, + canEdit = true, + canDelete = true, + isDisabled = false, + relationshipTypes = [], }) => ( } @@ -44,11 +44,4 @@ ParentInstanceFields.propTypes = { relationshipTypes: PropTypes.arrayOf(PropTypes.object), }; -ParentInstanceFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, - isDisabled: false, -}; - export default ParentInstanceFields; diff --git a/src/Instance/InstanceMovement/HoldingMovementList/HoldingsListMovement.js b/src/Instance/InstanceMovement/HoldingMovementList/HoldingsListMovement.js index 009c66090..b12b90c4d 100644 --- a/src/Instance/InstanceMovement/HoldingMovementList/HoldingsListMovement.js +++ b/src/Instance/InstanceMovement/HoldingMovementList/HoldingsListMovement.js @@ -19,14 +19,14 @@ const getDropStyle = (holdingsLength) => { const HoldingsListMovement = ({ instance, - holdings, - draggable, - droppable, tenantId, showViewHoldingsButton, showAddItemButton, isBarcodeAsHotlink, - pathToAccordionsState, + holdings = [], + draggable = false, + droppable = false, + pathToAccordionsState = [], }) => { const { selectItemsForDrag, @@ -93,9 +93,4 @@ HoldingsListMovement.propTypes = { pathToAccordionsState: PropTypes.arrayOf(PropTypes.string), }; -HoldingsListMovement.defaultProps = { - holdings: [], - pathToAccordionsState: [], -}; - export default HoldingsListMovement; diff --git a/src/Instance/InstanceMovement/InstanceMovement.js b/src/Instance/InstanceMovement/InstanceMovement.js index 1d75a2272..f8b09c7a7 100644 --- a/src/Instance/InstanceMovement/InstanceMovement.js +++ b/src/Instance/InstanceMovement/InstanceMovement.js @@ -11,10 +11,10 @@ import { import { InstanceMovementDetailsContainer } from './InstanceMovementDetails'; const InstanceMovement = ({ - instanceFrom, - instanceTo, onClose, moveHoldings, + instanceFrom = {}, + instanceTo = {}, }) => { return ( @@ -42,15 +42,10 @@ const InstanceMovement = ({ }; InstanceMovement.propTypes = { - instanceFrom: PropTypes.object, - instanceTo: PropTypes.object, onClose: PropTypes.func.isRequired, moveHoldings: PropTypes.func.isRequired, -}; - -InstanceMovement.defaultProps = { - instanceFrom: {}, - instanceTo: {}, + instanceFrom: PropTypes.object, + instanceTo: PropTypes.object, }; export default InstanceMovement; diff --git a/src/Instance/InstanceMovement/InstanceMovementDetails/InstanceMovementDetails.js b/src/Instance/InstanceMovement/InstanceMovementDetails/InstanceMovementDetails.js index 339048e5e..5d7d07f7d 100644 --- a/src/Instance/InstanceMovement/InstanceMovementDetails/InstanceMovementDetails.js +++ b/src/Instance/InstanceMovement/InstanceMovementDetails/InstanceMovementDetails.js @@ -14,10 +14,10 @@ import { HoldingsListContainer } from '../../HoldingsList'; import InstanceMovementDetailsActions from './InstanceMovementDetailsActions'; const InstanceMovementDetails = ({ - instance, onClose, hasMarc, - id, + instance = {}, + id = 'movement-instance-details', }) => { const stripes = useStripes(); @@ -85,15 +85,10 @@ const InstanceMovementDetails = ({ }; InstanceMovementDetails.propTypes = { - instance: PropTypes.object, - hasMarc: PropTypes.bool, onClose: PropTypes.func.isRequired, + hasMarc: PropTypes.bool, + instance: PropTypes.object, id: PropTypes.string, }; -InstanceMovementDetails.defaultProps = { - instance: {}, - id: 'movement-instance-details', -}; - export default InstanceMovementDetails; diff --git a/src/Instance/InstanceMovement/InstanceMovementDetails/InstanceMovementDetailsActions.js b/src/Instance/InstanceMovement/InstanceMovementDetails/InstanceMovementDetailsActions.js index a8eecf02e..43b0d58e1 100644 --- a/src/Instance/InstanceMovement/InstanceMovementDetails/InstanceMovementDetailsActions.js +++ b/src/Instance/InstanceMovement/InstanceMovementDetails/InstanceMovementDetailsActions.js @@ -18,8 +18,8 @@ import { const InstanceMovementDetailsActions = ({ onToggle, - instance, hasMarc, + instance = {}, }) => { const history = useHistory(); const location = useLocation(); @@ -86,8 +86,4 @@ InstanceMovementDetailsActions.propTypes = { hasMarc: PropTypes.bool, }; -InstanceMovementDetailsActions.defaultProps = { - instance: {}, -}; - export default InstanceMovementDetailsActions; diff --git a/src/Instance/InstanceMovement/InstanceMovementDetails/InstanceMovementDetailsContainer.js b/src/Instance/InstanceMovement/InstanceMovementDetails/InstanceMovementDetailsContainer.js index 68ba2179b..e968d217a 100644 --- a/src/Instance/InstanceMovement/InstanceMovementDetails/InstanceMovementDetailsContainer.js +++ b/src/Instance/InstanceMovement/InstanceMovementDetails/InstanceMovementDetailsContainer.js @@ -9,10 +9,10 @@ import { stripesConnect } from '@folio/stripes/core'; import InstanceMovementDetails from './InstanceMovementDetails'; const InstanceMovementDetailsContainer = ({ - instance, onClose, mutator, - id, + instance = {}, + id = 'movement-instance-details', }) => { const [marc, setMarc] = useState(); @@ -33,17 +33,12 @@ const InstanceMovementDetailsContainer = ({ }; InstanceMovementDetailsContainer.propTypes = { - instance: PropTypes.object, onClose: PropTypes.func.isRequired, mutator: PropTypes.object.isRequired, + instance: PropTypes.object, id: PropTypes.string, }; -InstanceMovementDetailsContainer.defaultProps = { - instance: {}, - id: 'movement-instance-details', -}; - InstanceMovementDetailsContainer.manifest = Object.freeze({ marcRecord: { type: 'okapi', diff --git a/src/Instance/ItemsList/ItemsList.js b/src/Instance/ItemsList/ItemsList.js index e6fefd4e7..6e975addf 100644 --- a/src/Instance/ItemsList/ItemsList.js +++ b/src/Instance/ItemsList/ItemsList.js @@ -155,18 +155,18 @@ const rowMetadata = ['id', 'holdingsRecordId']; const ItemsList = ({ holding, - items, setOffset, setSorting, - total, - draggable, - offset, - isItemsDragSelected, selectItemsForDrag, + isItemsDragSelected, getDraggingItems, - isFetching, isBarcodeAsHotlink, tenantId, + items = [], + total = 0, + draggable = false, + offset = 0, + isFetching = false, }) => { const { boundWithHoldings: holdings, isLoading } = useBoundWithHoldings(items, tenantId); const holdingsMapById = keyBy(holdings, 'id'); @@ -264,22 +264,18 @@ const ItemsList = ({ ItemsList.propTypes = { holding: PropTypes.object.isRequired, - items: PropTypes.arrayOf(PropTypes.object), setOffset: PropTypes.func.isRequired, setSorting: PropTypes.func.isRequired, - offset: PropTypes.number, - total: PropTypes.number, - draggable: PropTypes.bool, selectItemsForDrag: PropTypes.func.isRequired, isItemsDragSelected: PropTypes.func.isRequired, getDraggingItems: PropTypes.func.isRequired, - isFetching: PropTypes.bool, - tenantId: PropTypes.string, isBarcodeAsHotlink: PropTypes.bool, -}; - -ItemsList.defaultProps = { - items: [], + tenantId: PropTypes.string, + items: PropTypes.arrayOf(PropTypes.object), + offset: PropTypes.number, + total: PropTypes.number, + draggable: PropTypes.bool, + isFetching: PropTypes.bool, }; export default ItemsList; diff --git a/src/components/AdministrativeNoteList/AdministrativeNoteList.js b/src/components/AdministrativeNoteList/AdministrativeNoteList.js index 3fb89b5c0..f5cad82a6 100644 --- a/src/components/AdministrativeNoteList/AdministrativeNoteList.js +++ b/src/components/AdministrativeNoteList/AdministrativeNoteList.js @@ -23,7 +23,7 @@ const formatter = { }; const AdministrativeNoteList = ({ - administrativeNotes, + administrativeNotes = [], }) => { const intl = useIntl(); const columnMapping = useMemo(() => getColumnMapping(intl), []); @@ -48,8 +48,4 @@ AdministrativeNoteList.propTypes = { administrativeNotes: PropTypes.arrayOf(PropTypes.string), }; -AdministrativeNoteList.defaultProps = { - administrativeNotes: [], -}; - export default AdministrativeNoteList; diff --git a/src/components/FacetOptionFormatter/FacetOptionFormatter.js b/src/components/FacetOptionFormatter/FacetOptionFormatter.js index 7cb1d7abd..e9039a446 100644 --- a/src/components/FacetOptionFormatter/FacetOptionFormatter.js +++ b/src/components/FacetOptionFormatter/FacetOptionFormatter.js @@ -9,7 +9,10 @@ const propTypes = { searchTerm: PropTypes.string, }; -const FacetOptionFormatter = ({ option, searchTerm }) => { +const FacetOptionFormatter = ({ + option = null, + searchTerm = '', +}) => { if (!option) { return null; } @@ -26,9 +29,4 @@ const FacetOptionFormatter = ({ option, searchTerm }) => { FacetOptionFormatter.propTypes = propTypes; -FacetOptionFormatter.defaultProps = { - option: null, - searchTerm: '', -}; - export default FacetOptionFormatter; diff --git a/src/components/FilterNavigation/FilterNavigation.js b/src/components/FilterNavigation/FilterNavigation.js index d07652469..61b6221d5 100644 --- a/src/components/FilterNavigation/FilterNavigation.js +++ b/src/components/FilterNavigation/FilterNavigation.js @@ -16,8 +16,8 @@ import { useLastSearchTerms } from '../../hooks'; const FilterNavigation = ({ data, - segment, onChange, + segment = segments.instances, }) => { const { getLastSearch } = useLastSearchTerms(); @@ -55,12 +55,8 @@ const FilterNavigation = ({ FilterNavigation.propTypes = { data: PropTypes.object.isRequired, - segment: PropTypes.string, onChange: PropTypes.func, -}; - -FilterNavigation.defaultProps = { - segment: segments.instances, + segment: PropTypes.string, }; export default FilterNavigation; diff --git a/src/components/WarningMessage/WarningMessage.js b/src/components/WarningMessage/WarningMessage.js index 152239fc5..05b8d8564 100644 --- a/src/components/WarningMessage/WarningMessage.js +++ b/src/components/WarningMessage/WarningMessage.js @@ -18,7 +18,12 @@ const renderIcon = (icon, iconClassName) => ( /> ); -const WarningMessage = ({ id, icon, fill, iconPosition }) => ( +const WarningMessage = ({ + id, + icon = 'exclamation-circle', + iconPosition = 'start', + fill = false, +}) => (
{iconPosition === 'start' && renderIcon(icon, css.iconStart)} @@ -33,10 +38,4 @@ WarningMessage.propTypes = { fill: PropTypes.bool, }; -WarningMessage.defaultProps = { - icon: 'exclamation-circle', - iconPosition: 'start', - fill: false, -}; - export default WarningMessage; diff --git a/src/edit/InstanceForm.js b/src/edit/InstanceForm.js index f0571a8de..9a2c148ce 100644 --- a/src/edit/InstanceForm.js +++ b/src/edit/InstanceForm.js @@ -181,6 +181,42 @@ class InstanceForm extends React.Component { }, }); + static propTypes = { + onClose: PropTypes.func, // eslint-disable-line react/no-unused-prop-types + newinstance: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types + handleSubmit: PropTypes.func.isRequired, + pristine: PropTypes.bool, + submitting: PropTypes.bool, + onCancel: PropTypes.func, + initialValues: PropTypes.object, + referenceTables: PropTypes.object.isRequired, + copy: PropTypes.bool, + setKeepEditing: PropTypes.func, + showKeepEditingButton: PropTypes.bool, + stripes: PropTypes.shape({ + connect: PropTypes.func.isRequired, + locale: PropTypes.string.isRequired, + logger: PropTypes.object.isRequired, + }).isRequired, + resources: PropTypes.shape({ + instanceBlockedFields: PropTypes.shape({ + records: PropTypes.arrayOf(PropTypes.object), + }), + }), + instanceSource: PropTypes.string, + history: PropTypes.object.isRequired, + id: PropTypes.string, + httpError: PropTypes.object, + }; + + static defaultProps = { + instanceSource: 'FOLIO', + initialValues: {}, + id: 'instance-form', + showKeepEditingButton: false, + setKeepEditing: noop, + }; + constructor(props) { super(props); @@ -852,41 +888,6 @@ class InstanceForm extends React.Component { } } -InstanceForm.propTypes = { - onClose: PropTypes.func, // eslint-disable-line react/no-unused-prop-types - newinstance: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types - handleSubmit: PropTypes.func.isRequired, - pristine: PropTypes.bool, - submitting: PropTypes.bool, - onCancel: PropTypes.func, - initialValues: PropTypes.object, - referenceTables: PropTypes.object.isRequired, - copy: PropTypes.bool, - setKeepEditing: PropTypes.func, - showKeepEditingButton: PropTypes.bool, - stripes: PropTypes.shape({ - connect: PropTypes.func.isRequired, - locale: PropTypes.string.isRequired, - logger: PropTypes.object.isRequired, - }).isRequired, - resources: PropTypes.shape({ - instanceBlockedFields: PropTypes.shape({ - records: PropTypes.arrayOf(PropTypes.object), - }), - }), - instanceSource: PropTypes.string, - history: PropTypes.object.isRequired, - id: PropTypes.string, - httpError: PropTypes.object, -}; -InstanceForm.defaultProps = { - instanceSource: 'FOLIO', - initialValues: {}, - id: 'instance-form', - showKeepEditingButton: false, - setKeepEditing: noop, -}; - export default withRouter(stripesFinalForm({ validate, navigationCheck: true, diff --git a/src/edit/alternativeTitles.js b/src/edit/alternativeTitles.js index 42c2a0a47..dfdf9f0d3 100644 --- a/src/edit/alternativeTitles.js +++ b/src/edit/alternativeTitles.js @@ -16,15 +16,14 @@ import { Col, } from '@folio/stripes/components'; -const AlternativeTitles = props => { +const AlternativeTitles = ({ + canAdd = true, + canEdit = true, + canDelete = true, + alternativeTitleTypes = [], +}) => { const { formatMessage } = useIntl(); - const { - alternativeTitleTypes, - canAdd, - canEdit, - canDelete, - } = props; const alternativeTitleTypeOptions = alternativeTitleTypes.map(it => ({ label: it.name, value: it.id, @@ -99,10 +98,5 @@ AlternativeTitles.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -AlternativeTitles.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default AlternativeTitles; diff --git a/src/edit/classificationFields.js b/src/edit/classificationFields.js index 66fff796a..8e910b5f3 100644 --- a/src/edit/classificationFields.js +++ b/src/edit/classificationFields.js @@ -16,15 +16,14 @@ import { Label, } from '@folio/stripes/components'; -const ClassificationFields = props => { +const ClassificationFields = ({ + canAdd = true, + canEdit = true, + canDelete = true, + classificationTypes = [], +}) => { const { formatMessage } = useIntl(); - const { - classificationTypes, - canAdd, - canEdit, - canDelete, - } = props; const classificationTypeOptions = classificationTypes.map(it => ({ label: it.name, value: it.id, @@ -97,10 +96,5 @@ ClassificationFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -ClassificationFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default ClassificationFields; diff --git a/src/edit/contributorFields.js b/src/edit/contributorFields.js index f7a9b2533..842f2dbc4 100644 --- a/src/edit/contributorFields.js +++ b/src/edit/contributorFields.js @@ -18,16 +18,15 @@ import { import PrimaryToggleButton from './components/PrimaryToggleButton'; -const ContributorFields = props => { +const ContributorFields = ({ + contributorNameTypes = [], + contributorTypes = [], + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const { formatMessage } = useIntl(); - const { - contributorNameTypes, - contributorTypes, - canAdd, - canEdit, - canDelete, - } = props; const contributorNameTypeOptions = contributorNameTypes.map(it => ({ label: it.name, value: it.id, @@ -154,10 +153,5 @@ ContributorFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -ContributorFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default ContributorFields; diff --git a/src/edit/descriptionFields.js b/src/edit/descriptionFields.js index 95e0c0165..4322ec93f 100644 --- a/src/edit/descriptionFields.js +++ b/src/edit/descriptionFields.js @@ -13,15 +13,13 @@ import { RepeatableField, } from '@folio/stripes/components'; -const DescriptionFields = props => { +const DescriptionFields = ({ + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const { formatMessage } = useIntl(); - const { - canAdd, - canEdit, - canDelete, - } = props; - const physicalDescriptionLabel = formatMessage({ id: 'ui-inventory.physicalDescription' }); const legend = ( @@ -59,10 +57,5 @@ DescriptionFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -DescriptionFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default DescriptionFields; diff --git a/src/edit/editionFields.js b/src/edit/editionFields.js index b436450cf..8f604c4ea 100644 --- a/src/edit/editionFields.js +++ b/src/edit/editionFields.js @@ -13,15 +13,13 @@ import { TextField, } from '@folio/stripes/components'; -const EditionFields = props => { +const EditionFields = ({ + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const { formatMessage } = useIntl(); - const { - canAdd, - canEdit, - canDelete, - } = props; - const editionLabel = formatMessage({ id: 'ui-inventory.edition' }); const legend = ( @@ -59,10 +57,5 @@ EditionFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -EditionFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default EditionFields; diff --git a/src/edit/electronicAccessFields.js b/src/edit/electronicAccessFields.js index a37d9727c..dff4a77c9 100644 --- a/src/edit/electronicAccessFields.js +++ b/src/edit/electronicAccessFields.js @@ -18,15 +18,14 @@ import { import { parseEmptyFormValue } from '../utils'; -const ElectronicAccessFields = props => { +const ElectronicAccessFields = ({ + canAdd = true, + canEdit = true, + canDelete = true, + relationship = [], +}) => { const { formatMessage } = useIntl(); - const { - relationship, - canAdd, - canEdit, - canDelete, - } = props; const relationshipOptions = relationship.map(it => ({ label: it.name, value: it.id, @@ -141,11 +140,4 @@ ElectronicAccessFields.propTypes = { canDelete: PropTypes.bool, }; -ElectronicAccessFields.defaultProps = { - relationship: [], - canAdd: true, - canEdit: true, - canDelete: true, -}; - export default ElectronicAccessFields; diff --git a/src/edit/holdings/repeatableFields/FormerHoldingsIdFields.js b/src/edit/holdings/repeatableFields/FormerHoldingsIdFields.js index 5b4ff3c33..db90c3aa5 100644 --- a/src/edit/holdings/repeatableFields/FormerHoldingsIdFields.js +++ b/src/edit/holdings/repeatableFields/FormerHoldingsIdFields.js @@ -14,9 +14,9 @@ import { } from '@folio/stripes/components'; const FormerHoldingsIdFields = ({ - canAdd, - canEdit, - canDelete, + canAdd = true, + canEdit = true, + canDelete = true, }) => { const { formatMessage } = useIntl(); @@ -57,10 +57,4 @@ FormerHoldingsIdFields.propTypes = { canDelete: PropTypes.bool, }; -FormerHoldingsIdFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; - export default FormerHoldingsIdFields; diff --git a/src/edit/holdings/repeatableFields/HoldingsStatementFields.js b/src/edit/holdings/repeatableFields/HoldingsStatementFields.js index ef7bc0d28..f95ecb17f 100644 --- a/src/edit/holdings/repeatableFields/HoldingsStatementFields.js +++ b/src/edit/holdings/repeatableFields/HoldingsStatementFields.js @@ -16,9 +16,9 @@ import { } from '@folio/stripes/components'; const HoldingsStatementFields = ({ - canAdd, - canEdit, - canDelete, + canAdd = true, + canEdit = true, + canDelete = true, }) => { const { formatMessage } = useIntl(); @@ -103,10 +103,4 @@ HoldingsStatementFields.propTypes = { canDelete: PropTypes.bool, }; -HoldingsStatementFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; - export default HoldingsStatementFields; diff --git a/src/edit/holdings/repeatableFields/HoldingsStatementForIndexesFields.js b/src/edit/holdings/repeatableFields/HoldingsStatementForIndexesFields.js index 92131cf22..61c166a71 100644 --- a/src/edit/holdings/repeatableFields/HoldingsStatementForIndexesFields.js +++ b/src/edit/holdings/repeatableFields/HoldingsStatementForIndexesFields.js @@ -16,9 +16,9 @@ import { } from '@folio/stripes/components'; const HoldingsStatementForIndexesFields = ({ - canAdd, - canEdit, - canDelete, + canAdd = true, + canEdit = true, + canDelete = true, }) => { const { formatMessage } = useIntl(); @@ -102,10 +102,4 @@ HoldingsStatementForIndexesFields.propTypes = { canDelete: PropTypes.bool, }; -HoldingsStatementForIndexesFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; - export default HoldingsStatementForIndexesFields; diff --git a/src/edit/holdings/repeatableFields/HoldingsStatementForSupplementsFields.js b/src/edit/holdings/repeatableFields/HoldingsStatementForSupplementsFields.js index 35cef5d85..ca2f7934f 100644 --- a/src/edit/holdings/repeatableFields/HoldingsStatementForSupplementsFields.js +++ b/src/edit/holdings/repeatableFields/HoldingsStatementForSupplementsFields.js @@ -16,9 +16,9 @@ import { } from '@folio/stripes/components'; const HoldingsStatementForSupplementsFields = ({ - canAdd, - canEdit, - canDelete, + canAdd = true, + canEdit = true, + canDelete = true, }) => { const { formatMessage } = useIntl(); @@ -104,10 +104,4 @@ HoldingsStatementForSupplementsFields.propTypes = { canDelete: PropTypes.bool, }; -HoldingsStatementForSupplementsFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; - export default HoldingsStatementForSupplementsFields; diff --git a/src/edit/holdings/repeatableFields/NoteFields.js b/src/edit/holdings/repeatableFields/NoteFields.js index 771fce770..da2a90412 100644 --- a/src/edit/holdings/repeatableFields/NoteFields.js +++ b/src/edit/holdings/repeatableFields/NoteFields.js @@ -26,10 +26,10 @@ import { } from '../../../constants'; const NoteFields = ({ - noteTypeOptions, - canAdd, - canEdit, - canDelete, + canAdd = true, + canEdit = true, + canDelete = true, + noteTypeOptions = [], }) => { const { formatMessage } = useIntl(); @@ -128,10 +128,4 @@ NoteFields.propTypes = { noteTypeOptions: PropTypes.arrayOf(PropTypes.object), }; -NoteFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; - export default NoteFields; diff --git a/src/edit/holdings/repeatableFields/ReceivingHistoryFields.js b/src/edit/holdings/repeatableFields/ReceivingHistoryFields.js index a43b0a7f4..646665f5a 100644 --- a/src/edit/holdings/repeatableFields/ReceivingHistoryFields.js +++ b/src/edit/holdings/repeatableFields/ReceivingHistoryFields.js @@ -17,9 +17,9 @@ import { } from '@folio/stripes/components'; const ReceivingHistoryFields = ({ - canAdd, - canEdit, - canDelete, + canAdd = true, + canEdit = true, + canDelete = true, }) => { const { formatMessage } = useIntl(); @@ -103,10 +103,4 @@ ReceivingHistoryFields.propTypes = { canDelete: PropTypes.bool, }; -ReceivingHistoryFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; - export default ReceivingHistoryFields; diff --git a/src/edit/identifierFields.js b/src/edit/identifierFields.js index 811c4c377..4ba40555a 100644 --- a/src/edit/identifierFields.js +++ b/src/edit/identifierFields.js @@ -16,13 +16,12 @@ import { TextField, } from '@folio/stripes/components'; -const IdentifierFields = props => { - const { - identifierTypes, - canAdd, - canEdit, - canDelete, - } = props; +const IdentifierFields = ({ + identifierTypes = [], + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const { formatMessage } = useIntl(); const identifierTypeOptions = identifierTypes.map(it => ({ @@ -94,10 +93,5 @@ IdentifierFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -IdentifierFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default IdentifierFields; diff --git a/src/edit/instanceFormatFields.js b/src/edit/instanceFormatFields.js index 3af8eac11..8d045ed3f 100644 --- a/src/edit/instanceFormatFields.js +++ b/src/edit/instanceFormatFields.js @@ -13,16 +13,14 @@ import { RepeatableField, } from '@folio/stripes/components'; -const InstanceFormatFields = props => { +const InstanceFormatFields = ({ + instanceFormats = [], + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const { formatMessage } = useIntl(); - const { - instanceFormats, - canAdd, - canEdit, - canDelete, - } = props; - const instanceFormatOptions = instanceFormats ? instanceFormats.map(it => ({ label: it.name, @@ -72,10 +70,5 @@ InstanceFormatFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -InstanceFormatFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default InstanceFormatFields; diff --git a/src/edit/items/repeatableFields/CirculationNotesFields.js b/src/edit/items/repeatableFields/CirculationNotesFields.js index 015178794..26dca9669 100644 --- a/src/edit/items/repeatableFields/CirculationNotesFields.js +++ b/src/edit/items/repeatableFields/CirculationNotesFields.js @@ -17,15 +17,13 @@ import { Label, } from '@folio/stripes/components'; -const CirculationNotesFields = props => { +const CirculationNotesFields = ({ + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const { formatMessage } = useIntl(); - const { - canAdd, - canEdit, - canDelete, - } = props; - const noteTypeOptions = [ { label: formatMessage({ id: 'ui-inventory.selectType' }), value: '' }, { label: 'Check in note', value: 'Check in' }, @@ -115,10 +113,5 @@ CirculationNotesFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -CirculationNotesFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default CirculationNotesFields; diff --git a/src/edit/items/repeatableFields/FormerIdentifierFields.js b/src/edit/items/repeatableFields/FormerIdentifierFields.js index e878b70d7..d8710c98a 100644 --- a/src/edit/items/repeatableFields/FormerIdentifierFields.js +++ b/src/edit/items/repeatableFields/FormerIdentifierFields.js @@ -14,9 +14,9 @@ import { } from '@folio/stripes/components'; const FormerIdentifierFields = ({ - canAdd, - canEdit, - canDelete, + canAdd = true, + canEdit = true, + canDelete = true, }) => { const { formatMessage } = useIntl(); @@ -57,10 +57,4 @@ FormerIdentifierFields.propTypes = { canDelete: PropTypes.bool, }; -FormerIdentifierFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; - export default FormerIdentifierFields; diff --git a/src/edit/items/repeatableFields/YearCaptionFields.js b/src/edit/items/repeatableFields/YearCaptionFields.js index 28db287fc..6a3c9461d 100644 --- a/src/edit/items/repeatableFields/YearCaptionFields.js +++ b/src/edit/items/repeatableFields/YearCaptionFields.js @@ -14,9 +14,9 @@ import { } from '@folio/stripes/components'; const YearCaptionFields = ({ - canAdd, - canEdit, - canDelete, + canAdd = true, + canEdit = true, + canDelete = true, }) => { const { formatMessage } = useIntl(); @@ -57,10 +57,4 @@ YearCaptionFields.propTypes = { canDelete: PropTypes.bool, }; -YearCaptionFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; - export default YearCaptionFields; diff --git a/src/edit/languageFields.js b/src/edit/languageFields.js index 27e9d0dcd..da3fb8ce4 100644 --- a/src/edit/languageFields.js +++ b/src/edit/languageFields.js @@ -15,13 +15,11 @@ import { Label, } from '@folio/stripes/components'; -const LanguageFields = props => { - const { - canAdd, - canEdit, - canDelete, - } = props; - +const LanguageFields = ({ + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const intl = useIntl(); const stripes = useStripes(); const langOptions = languageOptions(intl, stripes.locale); @@ -68,10 +66,5 @@ LanguageFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -LanguageFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default LanguageFields; diff --git a/src/edit/natureOfContentFields.js b/src/edit/natureOfContentFields.js index e8109a6e6..3a783deb9 100644 --- a/src/edit/natureOfContentFields.js +++ b/src/edit/natureOfContentFields.js @@ -13,16 +13,14 @@ import { Select, } from '@folio/stripes/components'; -const NatureOfContentFields = props => { +const NatureOfContentFields = ({ + natureOfContentTerms = [], + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const { formatMessage } = useIntl(); - const { - canAdd, - canEdit, - canDelete, - natureOfContentTerms, - } = props; - const natureOfContentTermOptions = natureOfContentTerms ? natureOfContentTerms.map(it => ({ label: it.name, @@ -66,15 +64,10 @@ const NatureOfContentFields = props => { }; NatureOfContentFields.propTypes = { + natureOfContentTerms: PropTypes.arrayOf(PropTypes.object), canAdd: PropTypes.bool, canEdit: PropTypes.bool, canDelete: PropTypes.bool, - natureOfContentTerms: PropTypes.arrayOf(PropTypes.object), -}; -NatureOfContentFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, }; export default NatureOfContentFields; diff --git a/src/edit/noteFields.js b/src/edit/noteFields.js index debda500c..a8f5829f3 100644 --- a/src/edit/noteFields.js +++ b/src/edit/noteFields.js @@ -25,19 +25,17 @@ import { NOTE_CHARS_MAX_LENGTH } from '../constants'; -const NoteFields = props => { +const NoteFields = ({ + noteTypeIdField, + noteTypeOptions = [], + requiredFields = [], + renderLegend = true, + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const { formatMessage } = useIntl(); - const { - noteTypeOptions, - noteTypeIdField, - requiredFields, - renderLegend, - canAdd, - canEdit, - canDelete, - } = props; - const noteTypeLabel = formatMessage({ id: 'ui-inventory.noteType' }); const noteLabel = formatMessage({ id: 'ui-inventory.note' }); const staffOnlyLabel = formatMessage({ id: 'ui-inventory.staffOnly' }); @@ -134,13 +132,5 @@ NoteFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -NoteFields.defaultProps = { - noteTypeOptions: [], - requiredFields: [], - renderLegend: true, - canAdd: true, - canEdit: true, - canDelete: true, -}; export default NoteFields; diff --git a/src/edit/precedingTitleFields.js b/src/edit/precedingTitleFields.js index bef88aa7b..7f4148aa8 100644 --- a/src/edit/precedingTitleFields.js +++ b/src/edit/precedingTitleFields.js @@ -7,7 +7,12 @@ import { RepeatableField } from '@folio/stripes/components'; import TitleField from '../components/TitleField'; -const PrecedingTitles = ({ canAdd, canEdit, canDelete, isDisabled }) => ( +const PrecedingTitles = ({ + canAdd = true, + canEdit = true, + canDelete = true, + isDisabled = false, +}) => ( } legend={} @@ -36,11 +41,4 @@ PrecedingTitles.propTypes = { isDisabled: PropTypes.bool, }; -PrecedingTitles.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, - isDisabled: false, -}; - export default PrecedingTitles; diff --git a/src/edit/publicationFields.js b/src/edit/publicationFields.js index 192b3d6c7..28b6f53b3 100644 --- a/src/edit/publicationFields.js +++ b/src/edit/publicationFields.js @@ -16,15 +16,13 @@ import { Label, } from '@folio/stripes/components'; -const PublicationFields = props => { +const PublicationFields = ({ + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const { formatMessage } = useIntl(); - const { - canAdd, - canEdit, - canDelete, - } = props; - const publisherLabel = formatMessage({ id: 'ui-inventory.publisher' }); const publisherRoleLabel = formatMessage({ id: 'ui-inventory.publisherRole' }); const placeLabel = formatMessage({ id: 'ui-inventory.place' }); @@ -119,10 +117,5 @@ PublicationFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -PublicationFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default PublicationFields; diff --git a/src/edit/publicationFrequencyFields.js b/src/edit/publicationFrequencyFields.js index c42a7b26a..c266aea1a 100644 --- a/src/edit/publicationFrequencyFields.js +++ b/src/edit/publicationFrequencyFields.js @@ -13,15 +13,13 @@ import { TextArea, } from '@folio/stripes/components'; -const PublicationFrequencyFields = props => { +const PublicationFrequencyFields = ({ + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const { formatMessage } = useIntl(); - const { - canAdd, - canEdit, - canDelete, - } = props; - const publicationFrequencyLabel = formatMessage({ id: 'ui-inventory.publicationFrequency' }); const legend = ( @@ -60,10 +58,5 @@ PublicationFrequencyFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -PublicationFrequencyFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default PublicationFrequencyFields; diff --git a/src/edit/publicationRangeFields.js b/src/edit/publicationRangeFields.js index 578b61cc7..61c5bb679 100644 --- a/src/edit/publicationRangeFields.js +++ b/src/edit/publicationRangeFields.js @@ -13,15 +13,13 @@ import { TextArea, } from '@folio/stripes/components'; -const PublicationRangeFields = props => { +const PublicationRangeFields = ({ + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const { formatMessage } = useIntl(); - const { - canAdd, - canEdit, - canDelete, - } = props; - const publicationRangeLabel = formatMessage({ id: 'ui-inventory.publicationRange' }); const legend = ( @@ -60,10 +58,5 @@ PublicationRangeFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -PublicationRangeFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default PublicationRangeFields; diff --git a/src/edit/seriesFields.js b/src/edit/seriesFields.js index 02f685de7..3c053825b 100644 --- a/src/edit/seriesFields.js +++ b/src/edit/seriesFields.js @@ -13,15 +13,13 @@ import { TextArea, } from '@folio/stripes/components'; -const SeriesFields = props => { +const SeriesFields = ({ + canAdd = true, + canEdit = true, + canDelete = true, +}) => { const { formatMessage } = useIntl(); - const { - canAdd, - canEdit, - canDelete, - } = props; - const seriesStatementsLabel = formatMessage({ id: 'ui-inventory.seriesStatements' }); const legend = ( @@ -60,10 +58,5 @@ SeriesFields.propTypes = { canEdit: PropTypes.bool, canDelete: PropTypes.bool, }; -SeriesFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; export default SeriesFields; diff --git a/src/edit/statisticalCodeFields.js b/src/edit/statisticalCodeFields.js index e9f0d060a..49a05ff04 100644 --- a/src/edit/statisticalCodeFields.js +++ b/src/edit/statisticalCodeFields.js @@ -15,10 +15,10 @@ import { } from '@folio/stripes/components'; const StatisticalCodeFields = ({ - canAdd, - canEdit, - canDelete, - statisticalCodeOptions, + canAdd = true, + canEdit = true, + canDelete = true, + statisticalCodeOptions = [], }) => { const { formatMessage } = useIntl(); @@ -66,10 +66,4 @@ StatisticalCodeFields.propTypes = { canDelete: PropTypes.bool, }; -StatisticalCodeFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, -}; - export default StatisticalCodeFields; diff --git a/src/edit/succeedingTitleFields.js b/src/edit/succeedingTitleFields.js index 854597a72..d7618f272 100644 --- a/src/edit/succeedingTitleFields.js +++ b/src/edit/succeedingTitleFields.js @@ -7,7 +7,12 @@ import { RepeatableField } from '@folio/stripes/components'; import { TitleField } from '../components'; -const SucceedingTitles = ({ canAdd, canEdit, canDelete, isDisabled }) => ( +const SucceedingTitles = ({ + canAdd = true, + canEdit = true, + canDelete = true, + isDisabled = false, +}) => ( } legend={} @@ -36,11 +41,4 @@ SucceedingTitles.propTypes = { isDisabled: PropTypes.bool, }; -SucceedingTitles.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, - isDisabled: false, -}; - export default SucceedingTitles; diff --git a/src/views/ItemStatus/ItemStatus.js b/src/views/ItemStatus/ItemStatus.js index 41ddd520c..c116d8c9c 100644 --- a/src/views/ItemStatus/ItemStatus.js +++ b/src/views/ItemStatus/ItemStatus.js @@ -19,7 +19,12 @@ import { getDateWithTime } from '../../utils'; const label = ; -const ItemStatus = ({ itemId, status, openLoan, mutator }) => { +const ItemStatus = ({ + itemId, + status, + mutator, + openLoan = {}, +}) => { const [servicePoint, setServicePoint] = useState(); useEffect( @@ -94,12 +99,8 @@ ItemStatus.manifest = Object.freeze({ ItemStatus.propTypes = { itemId: PropTypes.string.isRequired, status: PropTypes.object.isRequired, - openLoan: PropTypes.object, mutator: PropTypes.object.isRequired, -}; - -ItemStatus.defaultProps = { - openLoan: {}, + openLoan: PropTypes.object, }; export default stripesConnect(ItemStatus);