From f56bb0d4b7f4c9be9855ca52fc2d6a44e3c883bb Mon Sep 17 00:00:00 2001 From: "Erin E. Sullivan" Date: Tue, 19 Nov 2024 12:30:19 -0500 Subject: [PATCH 1/2] Adding `TrimString` to `author` metadata. Replacing `kind` with `viewType`. --- .../components/RecordMetadata/index.js | 5 ++--- .../records/components/RecordPreview/index.js | 2 +- .../reusable/components/Metadata/index.js | 20 ++++++++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/modules/records/components/RecordMetadata/index.js b/src/modules/records/components/RecordMetadata/index.js index 66cf1a0a..1117715c 100644 --- a/src/modules/records/components/RecordMetadata/index.js +++ b/src/modules/records/components/RecordMetadata/index.js @@ -2,7 +2,7 @@ import { ContextProvider, Metadata } from '../../../reusable'; import PropTypes from 'prop-types'; import React from 'react'; -const RecordMetadata = ({ kind, record }) => { +const RecordMetadata = ({ record }) => { const { metadata } = record; if (!metadata) { @@ -17,14 +17,13 @@ const RecordMetadata = ({ kind, record }) => { Medium: metadata.medium, Preview: metadata.preview }; - return ; + return ; }} /> ); }; RecordMetadata.propTypes = { - kind: PropTypes.string, record: PropTypes.object }; diff --git a/src/modules/records/components/RecordPreview/index.js b/src/modules/records/components/RecordPreview/index.js index 87f9598b..148c3814 100644 --- a/src/modules/records/components/RecordPreview/index.js +++ b/src/modules/records/components/RecordPreview/index.js @@ -109,7 +109,7 @@ const RecordPreview = ({ datastoreUid, record, searchQuery }) => { return (
- +
diff --git a/src/modules/reusable/components/Metadata/index.js b/src/modules/reusable/components/Metadata/index.js index 12f784ed..431c5b4b 100644 --- a/src/modules/reusable/components/Metadata/index.js +++ b/src/modules/reusable/components/Metadata/index.js @@ -10,6 +10,7 @@ import { BrowseLink } from '../../../browse'; import PropTypes from 'prop-types'; import React from 'react'; import { stringifySearch } from '../../../search'; +import { TrimString } from '../../../core'; import { useSelector } from 'react-redux'; const DescriptionItem = ({ browse, children, href, search }) => { @@ -63,7 +64,7 @@ DescriptionItem.propTypes = { search: PropTypes.object }; -const Description = ({ data }) => { +const Description = ({ data, viewType }) => { if (Array.isArray(data)) { return (
    @@ -79,7 +80,7 @@ const Description = ({ data }) => { ); } - const { icon, image, text } = data; + const { icon, image, search: { scope } = {}, text } = data; return ( @@ -91,7 +92,7 @@ const Description = ({ data }) => { className='margin-right__2xs text-grey__light' /> )} - {text} + {scope === 'author' && viewType !== 'Full' ? : text} {image && ( {data.map((datum, datumIndex) => { const { description, term, termPlural } = datum; const isExpandable = description.length > 5; return ( -
    +
    -
    +
    {term}
    {description.map((descriptor, index) => { return (
    - +
    ); })} @@ -143,5 +145,5 @@ export default function Metadata ({ data, kind }) { Metadata.propTypes = { data: PropTypes.array, - kind: PropTypes.string + viewType: PropTypes.string }; From d5c50a258231c148e0d2fd74733f4544b3c14dd0 Mon Sep 17 00:00:00 2001 From: "Erin E. Sullivan" Date: Tue, 19 Nov 2024 13:58:04 -0500 Subject: [PATCH 2/2] Reducing the amount of data being pulled into components, from the full `record` to just certain properties. --- .../components/RecommendedResource/index.js | 8 ++++---- .../records/components/Record/index.js | 6 +++--- .../records/components/RecordFull/index.js | 6 +++--- .../components/RecordMetadata/index.js | 19 +++++++++---------- .../records/components/RecordPreview/index.js | 6 +++--- .../records/components/Zotero/index.js | 6 +++--- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/modules/records/components/RecommendedResource/index.js b/src/modules/records/components/RecommendedResource/index.js index 7c797e1d..774f0662 100644 --- a/src/modules/records/components/RecommendedResource/index.js +++ b/src/modules/records/components/RecommendedResource/index.js @@ -1,16 +1,16 @@ import PropTypes from 'prop-types'; import React from 'react'; -const RecommendedResource = ({ record }) => { - const isRecommended = record.fields.some((item) => { - return item.uid === 'highly_recommended'; +const RecommendedResource = ({ fields = [] }) => { + const isRecommended = fields.some(({ uid }) => { + return uid === 'highly_recommended'; }); return isRecommended ? Recommended : null; }; RecommendedResource.propTypes = { - record: PropTypes.object + fields: PropTypes.array }; export default RecommendedResource; diff --git a/src/modules/records/components/Record/index.js b/src/modules/records/components/Record/index.js index 536e97f8..1b089ba4 100644 --- a/src/modules/records/components/Record/index.js +++ b/src/modules/records/components/Record/index.js @@ -62,7 +62,7 @@ const Header = ({ datastoreUid, record }) => { ); })} - + ); }; @@ -84,8 +84,8 @@ const Record = ({ datastoreUid, list, record }) => {
    - - + +
    diff --git a/src/modules/records/components/RecordFull/index.js b/src/modules/records/components/RecordFull/index.js index 156ffab4..313d38da 100644 --- a/src/modules/records/components/RecordFull/index.js +++ b/src/modules/records/components/RecordFull/index.js @@ -151,14 +151,14 @@ const FullRecord = () => { ); })} - +
    - +

    Record info:

    - + {inDatastore && (

    The University of Michigan Library aims to describe its collections in a way that respects the people and communities who create, use, and are represented in them. We encourage you to diff --git a/src/modules/records/components/RecordMetadata/index.js b/src/modules/records/components/RecordMetadata/index.js index 1117715c..4f945c19 100644 --- a/src/modules/records/components/RecordMetadata/index.js +++ b/src/modules/records/components/RecordMetadata/index.js @@ -2,29 +2,28 @@ import { ContextProvider, Metadata } from '../../../reusable'; import PropTypes from 'prop-types'; import React from 'react'; -const RecordMetadata = ({ record }) => { - const { metadata } = record; - - if (!metadata) { - return null; - } - +const RecordMetadata = ({ metadata = {} }) => { return ( { + render={({ viewType }) => { + if (!metadata || Object.keys(metadata).length === 0) { + return null; + } + const data = { Full: metadata.full, Medium: metadata.medium, Preview: metadata.preview }; - return ; + + return ; }} /> ); }; RecordMetadata.propTypes = { - record: PropTypes.object + metadata: PropTypes.object }; export default RecordMetadata; diff --git a/src/modules/records/components/RecordPreview/index.js b/src/modules/records/components/RecordPreview/index.js index 148c3814..a980e740 100644 --- a/src/modules/records/components/RecordPreview/index.js +++ b/src/modules/records/components/RecordPreview/index.js @@ -53,7 +53,7 @@ const Header = ({ datastoreUid, record, searchQuery }) => { ); })} - + ); @@ -109,8 +109,8 @@ const RecordPreview = ({ datastoreUid, record, searchQuery }) => { return (

    - - + +
    ); diff --git a/src/modules/records/components/Zotero/index.js b/src/modules/records/components/Zotero/index.js index 8a49d180..1c8362fa 100644 --- a/src/modules/records/components/Zotero/index.js +++ b/src/modules/records/components/Zotero/index.js @@ -20,9 +20,9 @@ import PropTypes from 'prop-types'; * * And tell Zotero COinS was created. */ -const Zotero = ({ record }) => { +const Zotero = ({ fields = [] }) => { const [z3988, setZ3988] = useState(null); - const [value] = getFieldValue(getField(record.fields, 'z3988')); + const [value] = getFieldValue(getField(fields, 'z3988')); useEffect(() => { setZ3988(value); @@ -46,7 +46,7 @@ const Zotero = ({ record }) => { }; Zotero.propTypes = { - record: PropTypes.object + fields: PropTypes.array }; export default Zotero;