Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ exports[`VideoSourceWidget snapshots snapshots: renders as expected with default
</div>
<Form.Row
className="mt-3.5 mx-0 flex-nowrap"
key="somEUrL"
>
<Form.Group>
<Form.Control
Expand All @@ -86,7 +87,6 @@ exports[`VideoSourceWidget snapshots snapshots: renders as expected with default
<IconButtonWithTooltip
alt="Delete"
iconAs="Icon"
key="top-delete-somEUrL"
onClick={[Function]}
tooltipContent="Delete"
tooltipPlacement="top"
Expand Down Expand Up @@ -237,6 +237,7 @@ exports[`VideoSourceWidget snapshots snapshots: renders as expected with videoSh
</div>
<Form.Row
className="mt-3.5 mx-0 flex-nowrap"
key="somEUrL"
>
<Form.Group>
<Form.Control
Expand All @@ -245,7 +246,6 @@ exports[`VideoSourceWidget snapshots snapshots: renders as expected with videoSh
<IconButtonWithTooltip
alt="Delete"
iconAs="Icon"
key="top-delete-somEUrL"
onClick={[Function]}
tooltipContent="Delete"
tooltipPlacement="top"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ 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 index = fallbackVideos.findIndex(video => video === videoUrl);
const updatedFallbackVideos = [
...fallbackVideos.slice(0, index),
...fallbackVideos.slice(index + 1),
];
deleteFallbackVideo: (videoIndex) => {
const updatedFallbackVideos = fallbackVideos.toSpliced(videoIndex, 1);

dispatch(actions.video.updateField({ fallbackVideos: updatedFallbackVideos }));
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const VideoSourceWidget = ({
<FormattedMessage {...messages.fallbackVideoMessage} />
</div>
{fallbackVideos.formValue.length > 0 ? fallbackVideos.formValue.map((videoUrl, index) => (
<Form.Row className="mt-3.5 mx-0 flex-nowrap">
<Form.Row className="mt-3.5 mx-0 flex-nowrap" key={videoUrl}>
<Form.Group>
<Form.Control
floatingLabel={intl.formatMessage(messages.fallbackVideoLabel)}
Expand All @@ -110,13 +110,12 @@ const VideoSourceWidget = ({
onBlur={fallbackVideos.onBlur(index)}
/>
<IconButtonWithTooltip
key={`top-delete-${videoUrl}`}
tooltipPlacement="top"
tooltipContent={intl.formatMessage(messages.deleteFallbackVideo)}
src={DeleteOutline}
iconAs={Icon}
alt={intl.formatMessage(messages.deleteFallbackVideo)}
onClick={() => deleteFallbackVideo(videoUrl)}
onClick={() => deleteFallbackVideo(index)}
/>
</Form.Group>
</Form.Row>
Expand Down
Loading