clone-project-modal.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React, { memo, useCallback, useState } from 'react'
  2. import CloneProjectModalContent from './clone-project-modal-content'
  3. import { OLModal } from '@/shared/components/ol/ol-modal'
  4. import { ClonedProject } from '../../../../../types/project/dashboard/api'
  5. import { Tag } from '../../../../../app/src/Features/Tags/types'
  6. function CloneProjectModal({
  7. show,
  8. handleHide,
  9. handleAfterCloned,
  10. projectId,
  11. projectName,
  12. projectTags,
  13. }: {
  14. show: boolean
  15. handleHide: () => void
  16. handleAfterCloned: (clonedProject: ClonedProject, tags: Tag[]) => void
  17. projectId: string
  18. projectName: string
  19. projectTags: Tag[]
  20. }) {
  21. const [inFlight, setInFlight] = useState(false)
  22. const onHide = useCallback(() => {
  23. if (!inFlight) {
  24. handleHide()
  25. }
  26. }, [handleHide, inFlight])
  27. return (
  28. <OLModal
  29. animation
  30. show={show}
  31. onHide={onHide}
  32. id="clone-project-modal"
  33. // backdrop="static" will disable closing the modal by clicking
  34. // outside of the modal element
  35. backdrop={inFlight ? 'static' : undefined}
  36. >
  37. <CloneProjectModalContent
  38. handleHide={onHide}
  39. inFlight={inFlight}
  40. setInFlight={setInFlight}
  41. handleAfterCloned={handleAfterCloned}
  42. projectId={projectId}
  43. projectName={projectName}
  44. projectTags={projectTags}
  45. />
  46. </OLModal>
  47. )
  48. }
  49. export default memo(CloneProjectModal)