actions-copy-project.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { useCallback, useState } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import { assign } from '../../../shared/components/location'
  4. import EditorCloneProjectModalWrapper from '../../clone-project-modal/components/editor-clone-project-modal-wrapper'
  5. import LeftMenuButton from './left-menu-button'
  6. type ProjectCopyResponse = {
  7. project_id: string
  8. }
  9. export default function ActionsCopyProject() {
  10. const [showModal, setShowModal] = useState(false)
  11. const { t } = useTranslation()
  12. const openProject = useCallback(
  13. ({ project_id: projectId }: ProjectCopyResponse) => {
  14. assign(`/project/${projectId}`)
  15. },
  16. []
  17. )
  18. return (
  19. <>
  20. <LeftMenuButton
  21. onClick={() => setShowModal(true)}
  22. icon={{
  23. type: 'copy',
  24. fw: true,
  25. }}
  26. >
  27. {t('copy_project')}
  28. </LeftMenuButton>
  29. <EditorCloneProjectModalWrapper
  30. show={showModal}
  31. handleHide={() => setShowModal(false)}
  32. openProject={openProject}
  33. />
  34. </>
  35. )
  36. }