diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/__snapshots__/index.test.jsx.snap b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/__snapshots__/index.test.jsx.snap index 87b43324f1..fd175bb110 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/__snapshots__/index.test.jsx.snap +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/__snapshots__/index.test.jsx.snap @@ -1,46 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ThumbnailWidget snapshots snapshots: renders as expected where thumbnail uploads are allowed 1`] = ` - - - - - - - - - Image used as thumbnail for video - - -`; +exports[`ThumbnailWidget snapshots snapshots: renders as expected where thumbnail uploads are allowed 1`] = `null`; exports[`ThumbnailWidget snapshots snapshots: renders as expected where videoId is valid 1`] = ` `; -exports[`ThumbnailWidget snapshots snapshots: renders as expected with default props 1`] = ` - - - - - - - - -
- -
- -
-
- - -
-
-`; +exports[`ThumbnailWidget snapshots snapshots: renders as expected with default props 1`] = `null`; exports[`ThumbnailWidget snapshots snapshots: renders as expected with isLibrary true 1`] = `null`; diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/index.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/index.jsx index 72226c50cf..47e66306c4 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/index.jsx +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/index.jsx @@ -61,7 +61,7 @@ const ThumbnailWidget = ({ } return intl.formatMessage(messages.unavailableSubtitle); }; - return (!isLibrary ? ( + return (!isLibrary && edxVideo ? ( - {(allowThumbnailUpload && edxVideo) ? null : ( + {!allowThumbnailUpload && ( @@ -90,7 +90,7 @@ const ThumbnailWidget = ({ src={thumbnailSrc || thumbnail} alt={intl.formatMessage(messages.thumbnailAltText)} /> - {(allowThumbnailUpload && edxVideo) ? ( + {allowThumbnailUpload && ( - ) : null } + )} ) : ( @@ -115,7 +115,7 @@ const ThumbnailWidget = ({ iconBefore={FileUpload} onClick={fileInput.click} variant="link" - disabled={!(allowThumbnailUpload && edxVideo)} + disabled={!allowThumbnailUpload} > diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoSourceWidget/hooks.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoSourceWidget/hooks.jsx index fc3100c38f..a527e3404d 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoSourceWidget/hooks.jsx +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoSourceWidget/hooks.jsx @@ -39,8 +39,16 @@ export const sourceHooks = ({ dispatch, previousVideoId, setAlert }) => ({ export const fallbackHooks = ({ fallbackVideos, dispatch }) => ({ addFallbackVideo: () => dispatch(actions.video.updateField({ fallbackVideos: [...fallbackVideos, ''] })), + /** + * Deletes the first occurrence of the given videoUrl from the fallbackVideos list + * @param {string} videoUrl - the video URL to delete + */ deleteFallbackVideo: (videoUrl) => { - const updatedFallbackVideos = fallbackVideos.splice(fallbackVideos.indexOf(videoUrl), 1); + const index = fallbackVideos.findIndex(video => video === videoUrl); + const updatedFallbackVideos = [ + ...fallbackVideos.slice(0, index), + ...fallbackVideos.slice(index + 1), + ]; dispatch(actions.video.updateField({ fallbackVideos: updatedFallbackVideos })); }, });