Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Fixed delete for additional video url fields #418

Closed
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 @@ -82,7 +82,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 @@ -235,7 +234,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,8 +39,13 @@ export const sourceHooks = ({ dispatch, previousVideoId, setAlert }) => ({

export const fallbackHooks = ({ fallbackVideos, dispatch }) => ({
addFallbackVideo: () => dispatch(actions.video.updateField({ fallbackVideos: [...fallbackVideos, ''] })),
deleteFallbackVideo: (videoUrl) => {
const updatedFallbackVideos = fallbackVideos.splice(fallbackVideos.indexOf(videoUrl), 1);

deleteFallbackVideo: (videoIndex) => {
const updatedFallbackVideos = fallbackVideos.reduce((result, currentItem, index) => {
if (index === videoIndex) { return result; }
return [...result, currentItem];
}, []);

dispatch(actions.video.updateField({ fallbackVideos: updatedFallbackVideos }));
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ export 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.Row>
)) : null}
Expand Down
Loading