clone-project-modal-content.js 2.5 KB

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