2022-09-15 05:59:11 -04:00
|
|
|
import React, { memo, useCallback, useState } from 'react'
|
2021-01-06 05:30:08 -05:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import CloneProjectModalContent from './clone-project-modal-content'
|
2024-07-10 09:34:19 -04:00
|
|
|
import OLModal from '@/features/ui/components/ol/ol-modal'
|
2021-01-06 05:30:08 -05:00
|
|
|
|
2022-09-15 05:59:11 -04:00
|
|
|
function CloneProjectModal({
|
2021-03-05 08:00:13 -05:00
|
|
|
show,
|
|
|
|
handleHide,
|
2022-09-15 05:59:11 -04:00
|
|
|
handleAfterCloned,
|
|
|
|
projectId,
|
|
|
|
projectName,
|
2023-09-28 06:12:18 -04:00
|
|
|
projectTags,
|
2021-03-05 08:00:13 -05:00
|
|
|
}) {
|
2021-01-06 05:30:08 -05:00
|
|
|
const [inFlight, setInFlight] = useState(false)
|
|
|
|
|
2021-09-14 04:54:21 -04:00
|
|
|
const onHide = useCallback(() => {
|
2021-01-06 05:30:08 -05:00
|
|
|
if (!inFlight) {
|
|
|
|
handleHide()
|
|
|
|
}
|
|
|
|
}, [handleHide, inFlight])
|
|
|
|
|
|
|
|
return (
|
2024-07-10 09:34:19 -04:00
|
|
|
<OLModal
|
2021-09-14 04:54:21 -04:00
|
|
|
animation
|
2021-03-05 08:00:13 -05:00
|
|
|
show={show}
|
2021-09-14 04:54:21 -04:00
|
|
|
onHide={onHide}
|
|
|
|
id="clone-project-modal"
|
2022-12-21 21:44:28 -05:00
|
|
|
// backdrop="static" will disable closing the modal by clicking
|
|
|
|
// outside of the modal element
|
|
|
|
backdrop={inFlight ? 'static' : undefined}
|
2021-09-14 04:54:21 -04:00
|
|
|
>
|
|
|
|
<CloneProjectModalContent
|
|
|
|
handleHide={onHide}
|
|
|
|
inFlight={inFlight}
|
|
|
|
setInFlight={setInFlight}
|
2022-09-15 05:59:11 -04:00
|
|
|
handleAfterCloned={handleAfterCloned}
|
|
|
|
projectId={projectId}
|
|
|
|
projectName={projectName}
|
2023-09-28 06:12:18 -04:00
|
|
|
projectTags={projectTags}
|
2021-09-14 04:54:21 -04:00
|
|
|
/>
|
2024-07-10 09:34:19 -04:00
|
|
|
</OLModal>
|
2021-01-06 05:30:08 -05:00
|
|
|
)
|
2022-09-15 05:59:11 -04:00
|
|
|
}
|
2021-01-06 05:30:08 -05:00
|
|
|
|
|
|
|
CloneProjectModal.propTypes = {
|
|
|
|
handleHide: PropTypes.func.isRequired,
|
2021-04-27 03:52:58 -04:00
|
|
|
show: PropTypes.bool.isRequired,
|
2022-09-15 05:59:11 -04:00
|
|
|
handleAfterCloned: PropTypes.func.isRequired,
|
|
|
|
projectId: PropTypes.string,
|
|
|
|
projectName: PropTypes.string,
|
2023-09-28 06:12:18 -04:00
|
|
|
projectTags: PropTypes.arrayOf(
|
|
|
|
PropTypes.shape({
|
|
|
|
_id: PropTypes.string.isRequired,
|
|
|
|
name: PropTypes.string.isRequired,
|
|
|
|
color: PropTypes.string,
|
|
|
|
})
|
|
|
|
),
|
2021-01-06 05:30:08 -05:00
|
|
|
}
|
|
|
|
|
2022-09-15 05:59:11 -04:00
|
|
|
export default memo(CloneProjectModal)
|