-
-
- { asset.status && asset.statusBadgeVariant && (
-
- {asset.status}
-
- )}
- { asset.duration >= 0 && (
-
- {formatDuration(asset.duration)}
-
- )}
-
-
-
{asset.displayName}
- { asset.transcripts && (
-
-
{
+ const [thumbnailError, setThumbnailError] = React.useState(false);
+ return (
+
+
+
+ {(thumbnailError && thumbnailFallback) ? (
+
+ { thumbnailFallback }
+
+ ) : (
+
setThumbnailError(true))}
+ />
+ )}
+ { asset.status && asset.statusBadgeVariant && (
+
+ {asset.status}
+
+ )}
+ { asset.duration >= 0 && (
+
+ {formatDuration(asset.duration)}
+
+ )}
+
+
+
{asset.displayName}
+ { asset.transcripts && (
+
+
+
+ )}
+
+ ,
+ time: ,
+ }}
/>
-
- )}
-
- ,
- time: ,
- }}
- />
-
+
+
-
-
-);
+
+ );
+};
+GalleryCard.defaultProps = {
+ thumbnailFallback: undefined,
+};
GalleryCard.propTypes = {
asset: PropTypes.shape({
contentType: PropTypes.string,
@@ -91,6 +105,7 @@ GalleryCard.propTypes = {
statusBadgeVariant: PropTypes.string,
transcripts: PropTypes.arrayOf(PropTypes.string),
}).isRequired,
+ thumbnailFallback: PropTypes.element,
};
export default GalleryCard;
diff --git a/src/editors/sharedComponents/SelectionModal/GalleryCard.test.jsx b/src/editors/sharedComponents/SelectionModal/GalleryCard.test.jsx
index 5eb49456f..4b3ec843c 100644
--- a/src/editors/sharedComponents/SelectionModal/GalleryCard.test.jsx
+++ b/src/editors/sharedComponents/SelectionModal/GalleryCard.test.jsx
@@ -10,6 +10,7 @@ describe('GalleryCard component', () => {
displayName: 'props.img.displayName',
dateAdded: 12345,
};
+ const thumbnailFallback = (
Image failed to load);
let el;
beforeEach(() => {
el = shallow(
);
@@ -20,6 +21,15 @@ describe('GalleryCard component', () => {
it('loads Image with src from image external url', () => {
expect(el.find(Image).props().src).toEqual(asset.externalUrl);
});
+ it('snapshot with thumbnail fallback and load error', () => {
+ el = shallow(
);
+ el.find(Image).props().onError();
+ expect(el).toMatchSnapshot();
+ });
+ it('snapshot with thumbnail fallback and no error', () => {
+ el = shallow(
);
+ expect(el).toMatchSnapshot();
+ });
it('snapshot with status badge', () => {
el = shallow(
);
expect(el).toMatchSnapshot();
diff --git a/src/editors/sharedComponents/SelectionModal/__snapshots__/GalleryCard.test.jsx.snap b/src/editors/sharedComponents/SelectionModal/__snapshots__/GalleryCard.test.jsx.snap
index 769e70144..810913c68 100644
--- a/src/editors/sharedComponents/SelectionModal/__snapshots__/GalleryCard.test.jsx.snap
+++ b/src/editors/sharedComponents/SelectionModal/__snapshots__/GalleryCard.test.jsx.snap
@@ -253,6 +253,151 @@ exports[`GalleryCard component snapshot with status badge 1`] = `
`;
+exports[`GalleryCard component snapshot with thumbnail fallback and load error 1`] = `
+
+
+
+
+
+ Image failed to load
+
+
+
+
+
+ props.img.displayName
+
+
+ ,
+ "time": ,
+ }
+ }
+ />
+
+
+
+
+`;
+
+exports[`GalleryCard component snapshot with thumbnail fallback and no error 1`] = `
+
+
+
+
+
+
+
+ props.img.displayName
+
+
+ ,
+ "time": ,
+ }
+ }
+ />
+
+
+
+
+`;
+
exports[`GalleryCard component snapshot: dateAdded=12345 1`] = `