Skip to content

Commit

Permalink
Display the item title on the <SmallMediaCard /> component when ren…
Browse files Browse the repository at this point in the history
…dered in the "Merge Media" > "Export" dialog. (#2238)

I think that the `<SmallMediaCard />` component is consistent. It's a *media* card, not an *item* card, so the information displayed there is for the *media*.

But, under the context of the list of "Export" items under the "Merge Media" modal, it's harder to find a media when searching by the item title, since the card renders the media title, not the item title.

This PR fixes it by allowing the card to receive a custom `title` prop.

Reference: CV2-5868.
  • Loading branch information
caiosba committed Dec 20, 2024
1 parent 139b899 commit cfb08c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/components/cds/media-cards/SmallMediaCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const SmallMediaCard = ({
media,
onClick,
superAdminMask,
title,
}) => {
if (!media) {
return (
Expand Down Expand Up @@ -57,7 +58,7 @@ const SmallMediaCard = ({
<div className={styles.smallMediaCardContent}>
<div className={styles.titleAndUrl}>
<div className={cx('typography-subtitle2', 'small-media-card__title', styles.row, (media.url ? styles.oneLineDescription : styles.twoLinesDescription))}>
<ParsedText text={media.metadata?.title || media.quote || description} />
<ParsedText text={title || media.metadata?.title || media.quote || description} />
</div>
{ media.url ?
<div className={cx(styles.row, 'typography-body2')}>
Expand Down Expand Up @@ -86,16 +87,18 @@ SmallMediaCard.propTypes = {
metadata: PropTypes.object,
}).isRequired,
superAdminMask: PropTypes.bool,
title: PropTypes.string,
onClick: PropTypes.func,
};

SmallMediaCard.defaultProps = {
className: '',
details: null,
description: null,
maskContent: false,
superAdminMask: false,
title: null,
onClick: () => {},
className: '',
};

// eslint-disable-next-line import/no-unused-modules
Expand Down
1 change: 1 addition & 0 deletions src/app/components/media/AutoCompleteMediaItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ const AutoCompleteMediaItem = (props, context) => {
]}
maskContent={projectMedia.show_warning_cover}
media={projectMedia.media}
title={projectMedia.title}
onClick={e => handleClick(e, projectMedia.dbid)}
/>
</Link>
Expand Down

0 comments on commit cfb08c5

Please sign in to comment.