2022-10-27 12:19:50 -04:00
|
|
|
import { useCallback, useState } from 'react'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import EditorCloneProjectModalWrapper from '../../clone-project-modal/components/editor-clone-project-modal-wrapper'
|
|
|
|
import LeftMenuButton from './left-menu-button'
|
2023-03-16 08:32:48 -04:00
|
|
|
import { useLocation } from '../../../shared/hooks/use-location'
|
2023-08-22 09:33:19 -04:00
|
|
|
import * as eventTracking from '../../../infrastructure/event-tracking'
|
2024-10-11 05:22:38 -04:00
|
|
|
import { bsVersionIcon } from '@/features/utils/bootstrap-5'
|
2022-10-27 12:19:50 -04:00
|
|
|
|
|
|
|
type ProjectCopyResponse = {
|
|
|
|
project_id: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function ActionsCopyProject() {
|
|
|
|
const [showModal, setShowModal] = useState(false)
|
|
|
|
const { t } = useTranslation()
|
2023-03-16 08:32:48 -04:00
|
|
|
const location = useLocation()
|
2022-10-27 12:19:50 -04:00
|
|
|
|
|
|
|
const openProject = useCallback(
|
|
|
|
({ project_id: projectId }: ProjectCopyResponse) => {
|
2023-03-16 08:32:48 -04:00
|
|
|
location.assign(`/project/${projectId}`)
|
2022-10-27 12:19:50 -04:00
|
|
|
},
|
2023-03-16 08:32:48 -04:00
|
|
|
[location]
|
2022-10-27 12:19:50 -04:00
|
|
|
)
|
|
|
|
|
2023-08-22 09:33:19 -04:00
|
|
|
const handleShowModal = useCallback(() => {
|
|
|
|
eventTracking.sendMB('left-menu-copy')
|
|
|
|
setShowModal(true)
|
|
|
|
}, [])
|
|
|
|
|
2022-10-27 12:19:50 -04:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<LeftMenuButton
|
2023-08-22 09:33:19 -04:00
|
|
|
onClick={handleShowModal}
|
2024-10-11 05:22:38 -04:00
|
|
|
icon={bsVersionIcon({
|
|
|
|
bs5: { type: 'file_copy' },
|
|
|
|
bs3: { type: 'copy', fw: true },
|
|
|
|
})}
|
2022-10-27 12:19:50 -04:00
|
|
|
>
|
|
|
|
{t('copy_project')}
|
|
|
|
</LeftMenuButton>
|
|
|
|
<EditorCloneProjectModalWrapper
|
|
|
|
show={showModal}
|
|
|
|
handleHide={() => setShowModal(false)}
|
|
|
|
openProject={openProject}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|