AwsSetting.jsx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import { withUnstatedContainers } from '../../UnstatedUtils';
  5. import AppContainer from '../../../services/AppContainer';
  6. import AdminAppContainer from '../../../services/AdminAppContainer';
  7. function AwsSetting(props) {
  8. const { t, adminAppContainer } = props;
  9. const { s3ReferenceFileWithRelayMode } = adminAppContainer.state;
  10. return (
  11. <React.Fragment>
  12. <div className="row form-group my-3">
  13. <label className="text-left text-md-right col-md-3 col-form-label">
  14. {t('admin:app_setting.file_delivery_method')}
  15. </label>
  16. <div className="col-md-6">
  17. <div className="dropdown">
  18. <button
  19. className="btn btn-outline-secondary dropdown-toggle"
  20. type="button"
  21. id="ddS3ReferenceFileWithRelayMode"
  22. data-toggle="dropdown"
  23. aria-haspopup="true"
  24. aria-expanded="true"
  25. >
  26. {s3ReferenceFileWithRelayMode && t('admin:app_setting.file_delivery_method_relay')}
  27. {!s3ReferenceFileWithRelayMode && t('admin:app_setting.file_delivery_method_redirect')}
  28. </button>
  29. <div className="dropdown-menu" aria-labelledby="ddS3ReferenceFileWithRelayMode">
  30. <button
  31. className="dropdown-item"
  32. type="button"
  33. onClick={() => { adminAppContainer.changeS3ReferenceFileWithRelayMode(true) }}
  34. >
  35. {t('admin:app_setting.file_delivery_method_relay')}
  36. </button>
  37. <button
  38. className="dropdown-item"
  39. type="button"
  40. onClick={() => { adminAppContainer.changeS3ReferenceFileWithRelayMode(false) }}
  41. >
  42. { t('admin:app_setting.file_delivery_method_redirect')}
  43. </button>
  44. </div>
  45. <p className="form-text text-muted small">
  46. {t('admin:app_setting.file_delivery_method_redirect_info')}
  47. <br />
  48. {t('admin:app_setting.file_delivery_method_relay_info')}
  49. </p>
  50. </div>
  51. </div>
  52. </div>
  53. <div className="row form-group">
  54. <label className="text-left text-md-right col-md-3 col-form-label">
  55. {t('admin:app_setting.region')}
  56. </label>
  57. <div className="col-md-6">
  58. <input
  59. className="form-control"
  60. placeholder={`${t('eg')} ap-northeast-1`}
  61. defaultValue={adminAppContainer.state.s3Region || ''}
  62. onChange={(e) => {
  63. adminAppContainer.changeS3Region(e.target.value);
  64. }}
  65. />
  66. </div>
  67. </div>
  68. <div className="row form-group">
  69. <label className="text-left text-md-right col-md-3 col-form-label">
  70. {t('admin:app_setting.custom_endpoint')}
  71. </label>
  72. <div className="col-md-6">
  73. <input
  74. className="form-control"
  75. type="text"
  76. placeholder={`${t('eg')} http://localhost:9000`}
  77. defaultValue={adminAppContainer.state.s3CustomEndpoint || ''}
  78. onChange={(e) => {
  79. adminAppContainer.changeS3CustomEndpoint(e.target.value);
  80. }}
  81. />
  82. <p className="form-text text-muted">{t('admin:app_setting.custom_endpoint_change')}</p>
  83. </div>
  84. </div>
  85. <div className="row form-group">
  86. <label className="text-left text-md-right col-md-3 col-form-label">
  87. {t('admin:app_setting.bucket_name')}
  88. </label>
  89. <div className="col-md-6">
  90. <input
  91. className="form-control"
  92. type="text"
  93. placeholder={`${t('eg')} crowi`}
  94. defaultValue={adminAppContainer.state.s3Bucket || ''}
  95. onChange={(e) => {
  96. adminAppContainer.changeS3Bucket(e.target.value);
  97. }}
  98. />
  99. </div>
  100. </div>
  101. <div className="row form-group">
  102. <label className="text-left text-md-right col-md-3 col-form-label">
  103. Access key ID
  104. </label>
  105. <div className="col-md-6">
  106. <input
  107. className="form-control"
  108. type="text"
  109. defaultValue={adminAppContainer.state.s3AccessKeyId || ''}
  110. onChange={(e) => {
  111. adminAppContainer.changeS3AccessKeyId(e.target.value);
  112. }}
  113. />
  114. </div>
  115. </div>
  116. <div className="row form-group">
  117. <label className="text-left text-md-right col-md-3 col-form-label">
  118. Secret access key
  119. </label>
  120. <div className="col-md-6">
  121. <input
  122. className="form-control"
  123. type="text"
  124. defaultValue={adminAppContainer.state.s3SecretAccessKey || ''}
  125. onChange={(e) => {
  126. adminAppContainer.changeS3SecretAccessKey(e.target.value);
  127. }}
  128. />
  129. </div>
  130. </div>
  131. </React.Fragment>
  132. );
  133. }
  134. /**
  135. * Wrapper component for using unstated
  136. */
  137. const AwsSettingWrapper = withUnstatedContainers(AwsSetting, [AppContainer, AdminAppContainer]);
  138. AwsSetting.propTypes = {
  139. t: PropTypes.func.isRequired, // i18next
  140. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  141. adminAppContainer: PropTypes.instanceOf(AdminAppContainer).isRequired,
  142. };
  143. export default withTranslation()(AwsSettingWrapper);