2021-03-05 08:00:13 -05:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import { Trans } from 'react-i18next'
|
2021-01-06 05:30:08 -05:00
|
|
|
import {
|
|
|
|
Modal,
|
|
|
|
Alert,
|
|
|
|
Button,
|
|
|
|
ControlLabel,
|
2021-03-05 08:00:13 -05:00
|
|
|
FormControl,
|
2021-04-27 03:52:58 -04:00
|
|
|
FormGroup,
|
2021-01-06 05:30:08 -05:00
|
|
|
} from 'react-bootstrap'
|
2021-03-05 08:00:13 -05:00
|
|
|
import AccessibleModal from '../../../shared/components/accessible-modal'
|
2021-01-06 05:30:08 -05:00
|
|
|
|
2021-03-05 08:00:13 -05:00
|
|
|
export default function CloneProjectModalContent({
|
|
|
|
animation = true,
|
|
|
|
show,
|
2021-01-06 05:30:08 -05:00
|
|
|
cancel,
|
2021-03-05 08:00:13 -05:00
|
|
|
handleSubmit,
|
|
|
|
clonedProjectName,
|
|
|
|
setClonedProjectName,
|
|
|
|
error,
|
|
|
|
inFlight,
|
2021-04-27 03:52:58 -04:00
|
|
|
valid,
|
2021-01-06 05:30:08 -05:00
|
|
|
}) {
|
|
|
|
return (
|
2021-03-05 08:00:13 -05:00
|
|
|
<AccessibleModal
|
|
|
|
animation={animation}
|
|
|
|
show={show}
|
|
|
|
onHide={cancel}
|
|
|
|
id="clone-project-modal"
|
|
|
|
>
|
2021-01-06 05:30:08 -05:00
|
|
|
<Modal.Header closeButton>
|
2021-03-05 08:00:13 -05:00
|
|
|
<Modal.Title>
|
|
|
|
<Trans i18nKey="copy_project" />
|
|
|
|
</Modal.Title>
|
2021-01-06 05:30:08 -05:00
|
|
|
</Modal.Header>
|
|
|
|
|
|
|
|
<Modal.Body>
|
|
|
|
<form id="clone-project-form" onSubmit={handleSubmit}>
|
|
|
|
<FormGroup>
|
2021-03-05 08:00:13 -05:00
|
|
|
<ControlLabel htmlFor="clone-project-form-name">
|
|
|
|
<Trans i18nKey="new_name" />
|
2021-01-06 05:30:08 -05:00
|
|
|
</ControlLabel>
|
|
|
|
|
|
|
|
<FormControl
|
2021-03-05 08:00:13 -05:00
|
|
|
id="clone-project-form-name"
|
2021-01-06 05:30:08 -05:00
|
|
|
type="text"
|
|
|
|
placeholder="New Project Name"
|
|
|
|
required
|
|
|
|
value={clonedProjectName}
|
|
|
|
onChange={event => setClonedProjectName(event.target.value)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
{error && (
|
|
|
|
<Alert bsStyle="danger">
|
2021-03-05 08:00:13 -05:00
|
|
|
{error.length ? (
|
|
|
|
error
|
|
|
|
) : (
|
|
|
|
<Trans i18nKey="generic_something_went_wrong" />
|
|
|
|
)}
|
2021-01-06 05:30:08 -05:00
|
|
|
</Alert>
|
|
|
|
)}
|
|
|
|
</Modal.Body>
|
|
|
|
|
|
|
|
<Modal.Footer>
|
|
|
|
<Button type="button" disabled={inFlight} onClick={cancel}>
|
2021-03-05 08:00:13 -05:00
|
|
|
<Trans i18nKey="cancel" />
|
2021-01-06 05:30:08 -05:00
|
|
|
</Button>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
form="clone-project-form"
|
|
|
|
type="submit"
|
|
|
|
bsStyle="primary"
|
|
|
|
disabled={inFlight || !valid}
|
|
|
|
>
|
2021-03-05 08:00:13 -05:00
|
|
|
{inFlight ? (
|
|
|
|
<>
|
|
|
|
<Trans i18nKey="copying" />…
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<Trans i18nKey="copy" />
|
|
|
|
)}
|
2021-01-06 05:30:08 -05:00
|
|
|
</Button>
|
|
|
|
</Modal.Footer>
|
2021-03-05 08:00:13 -05:00
|
|
|
</AccessibleModal>
|
2021-01-06 05:30:08 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
CloneProjectModalContent.propTypes = {
|
2021-03-05 08:00:13 -05:00
|
|
|
animation: PropTypes.bool,
|
|
|
|
show: PropTypes.bool.isRequired,
|
2021-01-06 05:30:08 -05:00
|
|
|
cancel: PropTypes.func.isRequired,
|
2021-03-05 08:00:13 -05:00
|
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
|
|
clonedProjectName: PropTypes.string,
|
|
|
|
setClonedProjectName: PropTypes.func.isRequired,
|
|
|
|
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
2021-01-06 05:30:08 -05:00
|
|
|
inFlight: PropTypes.bool.isRequired,
|
2021-04-27 03:52:58 -04:00
|
|
|
valid: PropTypes.bool.isRequired,
|
2021-01-06 05:30:08 -05:00
|
|
|
}
|