Skip to content
Open
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 @@ -8,7 +8,7 @@
* @license Pimcore Open Core License (POCL)
*/

import React, { type ReactElement, useState } from 'react'
import React, { type ReactElement } from 'react'
import { IconButton } from '@Pimcore/components/icon-button/icon-button'
import {
type VideoType,
Expand All @@ -17,8 +17,8 @@ import {
import { useTranslation } from 'react-i18next'
import { ButtonGroup } from '@Pimcore/components/button-group/button-group'
import { Tooltip } from '@Pimcore/components/tooltip/tooltip'
import { VideoModal } from '@Pimcore/modules/element/components/video-modal/video-modal'
import { isEmpty } from 'lodash'
import { useVideoModal } from '@Pimcore/modules/element/components/video-modal/hooks/use-video-modal'
import { isEmpty, isNull } from 'lodash'

interface VideoFooterProps {
emptyValue?: () => void
Expand All @@ -31,19 +31,18 @@ interface VideoFooterProps {

export const VideoFooter = (props: VideoFooterProps): React.JSX.Element => {
const { t } = useTranslation()
const [isModalVisible, setIsModalVisible] = useState(false)
const { openModal } = useVideoModal({
allowedVideoTypes: props.allowedVideoTypes,
disabled: props.disabled,
onChange: (value: VideoValue | null): void => {
if (!isNull(value)) {
props.onSave?.(value)
}
}
})

const showModal = (): void => {
setIsModalVisible(true)
}

const handleModalOk = (value: VideoValue): void => {
props.onSave?.(value)
setIsModalVisible(false)
}

const handleModalCancel = (): void => {
setIsModalVisible(false)
openModal(props.value)
}

const buttons: ReactElement[] = []
Expand Down Expand Up @@ -104,19 +103,9 @@ export const VideoFooter = (props: VideoFooterProps): React.JSX.Element => {
}

return (
<>
<ButtonGroup
items={ buttons }
noSpacing
/>
<VideoModal
allowedVideoTypes={ props.allowedVideoTypes }
disabled={ props.disabled }
onCancel={ handleModalCancel }
onOk={ handleModalOk }
open={ isModalVisible }
value={ props.value }
/>
</>
<ButtonGroup
items={ buttons }
noSpacing
/>
)
}
Loading