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'
|
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
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<LeftMenuButton
|
|
|
|
onClick={() => setShowModal(true)}
|
|
|
|
icon={{
|
|
|
|
type: 'copy',
|
|
|
|
fw: true,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{t('copy_project')}
|
|
|
|
</LeftMenuButton>
|
|
|
|
<EditorCloneProjectModalWrapper
|
|
|
|
show={showModal}
|
|
|
|
handleHide={() => setShowModal(false)}
|
|
|
|
openProject={openProject}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|