clone-project-modal-content.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import PropTypes from 'prop-types'
  2. import { Trans } from 'react-i18next'
  3. import {
  4. Modal,
  5. Alert,
  6. Button,
  7. ControlLabel,
  8. FormControl,
  9. FormGroup,
  10. } from 'react-bootstrap'
  11. import AccessibleModal from '../../../shared/components/accessible-modal'
  12. export default function CloneProjectModalContent({
  13. animation = true,
  14. show,
  15. cancel,
  16. handleSubmit,
  17. clonedProjectName,
  18. setClonedProjectName,
  19. error,
  20. inFlight,
  21. valid,
  22. }) {
  23. return (
  24. <AccessibleModal
  25. animation={animation}
  26. show={show}
  27. onHide={cancel}
  28. id="clone-project-modal"
  29. >
  30. <Modal.Header closeButton>
  31. <Modal.Title>
  32. <Trans i18nKey="copy_project" />
  33. </Modal.Title>
  34. </Modal.Header>
  35. <Modal.Body>
  36. <form id="clone-project-form" onSubmit={handleSubmit}>
  37. <FormGroup>
  38. <ControlLabel htmlFor="clone-project-form-name">
  39. <Trans i18nKey="new_name" />
  40. </ControlLabel>
  41. <FormControl
  42. id="clone-project-form-name"
  43. type="text"
  44. placeholder="New Project Name"
  45. required
  46. value={clonedProjectName}
  47. onChange={event => setClonedProjectName(event.target.value)}
  48. />
  49. </FormGroup>
  50. </form>
  51. {error && (
  52. <Alert bsStyle="danger">
  53. {error.length ? (
  54. error
  55. ) : (
  56. <Trans i18nKey="generic_something_went_wrong" />
  57. )}
  58. </Alert>
  59. )}
  60. </Modal.Body>
  61. <Modal.Footer>
  62. <Button type="button" disabled={inFlight} onClick={cancel}>
  63. <Trans i18nKey="cancel" />
  64. </Button>
  65. <Button
  66. form="clone-project-form"
  67. type="submit"
  68. bsStyle="primary"
  69. disabled={inFlight || !valid}
  70. >
  71. {inFlight ? (
  72. <>
  73. <Trans i18nKey="copying" />…
  74. </>
  75. ) : (
  76. <Trans i18nKey="copy" />
  77. )}
  78. </Button>
  79. </Modal.Footer>
  80. </AccessibleModal>
  81. )
  82. }
  83. CloneProjectModalContent.propTypes = {
  84. animation: PropTypes.bool,
  85. show: PropTypes.bool.isRequired,
  86. cancel: PropTypes.func.isRequired,
  87. handleSubmit: PropTypes.func.isRequired,
  88. clonedProjectName: PropTypes.string,
  89. setClonedProjectName: PropTypes.func.isRequired,
  90. error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
  91. inFlight: PropTypes.bool.isRequired,
  92. valid: PropTypes.bool.isRequired,
  93. }