2021-09-14 04:54:21 -04:00
|
|
|
import React, { useCallback, useState } from 'react'
|
2021-01-06 05:30:08 -05:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import CloneProjectModalContent from './clone-project-modal-content'
|
2021-09-14 04:54:21 -04:00
|
|
|
import AccessibleModal from '../../../shared/components/accessible-modal'
|
|
|
|
import withErrorBoundary from '../../../infrastructure/error-boundary'
|
2021-01-06 05:30:08 -05:00
|
|
|
|
2021-09-14 04:54:21 -04:00
|
|
|
const CloneProjectModal = React.memo(function CloneProjectModal({
|
2021-03-05 08:00:13 -05:00
|
|
|
show,
|
|
|
|
handleHide,
|
2021-04-27 03:52:58 -04:00
|
|
|
openProject,
|
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 (
|
2021-09-14 04:54:21 -04:00
|
|
|
<AccessibleModal
|
|
|
|
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"
|
|
|
|
backdrop="static"
|
|
|
|
>
|
|
|
|
<CloneProjectModalContent
|
|
|
|
handleHide={onHide}
|
|
|
|
inFlight={inFlight}
|
|
|
|
setInFlight={setInFlight}
|
|
|
|
openProject={openProject}
|
|
|
|
/>
|
|
|
|
</AccessibleModal>
|
2021-01-06 05:30:08 -05:00
|
|
|
)
|
2021-09-14 04:54:21 -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,
|
2021-09-14 04:54:21 -04:00
|
|
|
openProject: PropTypes.func.isRequired,
|
2021-01-06 05:30:08 -05:00
|
|
|
}
|
|
|
|
|
2021-09-14 04:54:21 -04:00
|
|
|
export default withErrorBoundary(CloneProjectModal)
|