AwsSetting.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import { useTranslation } from 'next-i18next';
  2. export type AwsSettingMoleculeProps = {
  3. s3ReferenceFileWithRelayMode
  4. s3Region
  5. s3CustomEndpoint
  6. s3Bucket
  7. s3AccessKeyId
  8. s3SecretAccessKey
  9. onChangeS3ReferenceFileWithRelayMode: (val: boolean) => void
  10. onChangeS3Region: (val: string) => void
  11. onChangeS3CustomEndpoint: (val: string) => void
  12. onChangeS3Bucket: (val: string) => void
  13. onChangeS3AccessKeyId: (val: string) => void
  14. onChangeS3SecretAccessKey: (val: string) => void
  15. };
  16. export const AwsSettingMolecule = (props: AwsSettingMoleculeProps): JSX.Element => {
  17. const { t } = useTranslation();
  18. return (
  19. <>
  20. <div className="row my-3">
  21. <label className="text-start text-md-end col-md-3 col-form-label">
  22. {t('admin:app_setting.file_delivery_method')}
  23. </label>
  24. <div className="col-md-6">
  25. <div className="dropdown">
  26. <button
  27. className="btn btn-outline-secondary dropdown-toggle"
  28. type="button"
  29. id="ddS3ReferenceFileWithRelayMode"
  30. data-bs-toggle="dropdown"
  31. aria-haspopup="true"
  32. aria-expanded="true"
  33. >
  34. {props.s3ReferenceFileWithRelayMode && t('admin:app_setting.file_delivery_method_relay')}
  35. {!props.s3ReferenceFileWithRelayMode && t('admin:app_setting.file_delivery_method_redirect')}
  36. </button>
  37. <div className="dropdown-menu" aria-labelledby="ddS3ReferenceFileWithRelayMode">
  38. <button
  39. className="dropdown-item"
  40. type="button"
  41. onClick={() => { props?.onChangeS3ReferenceFileWithRelayMode(true) }}
  42. >
  43. {t('admin:app_setting.file_delivery_method_relay')}
  44. </button>
  45. <button
  46. className="dropdown-item"
  47. type="button"
  48. onClick={() => { props?.onChangeS3ReferenceFileWithRelayMode(false) }}
  49. >
  50. { t('admin:app_setting.file_delivery_method_redirect')}
  51. </button>
  52. </div>
  53. <p className="form-text text-muted small">
  54. {t('admin:app_setting.file_delivery_method_redirect_info')}
  55. <br />
  56. {t('admin:app_setting.file_delivery_method_relay_info')}
  57. </p>
  58. </div>
  59. </div>
  60. </div>
  61. <div className="row">
  62. <label className="text-start text-md-end col-md-3 col-form-label">
  63. {t('admin:app_setting.region')}
  64. </label>
  65. <div className="col-md-6">
  66. <input
  67. className="form-control"
  68. placeholder={`${t('eg')} ap-northeast-1`}
  69. defaultValue={props.s3Region || ''}
  70. onChange={(e) => {
  71. props?.onChangeS3Region(e.target.value);
  72. }}
  73. />
  74. </div>
  75. </div>
  76. <div className="row">
  77. <label className="text-start text-md-end col-md-3 col-form-label">
  78. {t('admin:app_setting.custom_endpoint')}
  79. </label>
  80. <div className="col-md-6">
  81. <input
  82. className="form-control"
  83. type="text"
  84. placeholder={`${t('eg')} http://localhost:9000`}
  85. defaultValue={props.s3CustomEndpoint || ''}
  86. onChange={(e) => {
  87. props?.onChangeS3CustomEndpoint(e.target.value);
  88. }}
  89. />
  90. <p className="form-text text-muted">{t('admin:app_setting.custom_endpoint_change')}</p>
  91. </div>
  92. </div>
  93. <div className="row">
  94. <label className="text-start text-md-end col-md-3 col-form-label">
  95. {t('admin:app_setting.bucket_name')}
  96. </label>
  97. <div className="col-md-6">
  98. <input
  99. className="form-control"
  100. type="text"
  101. placeholder={`${t('eg')} crowi`}
  102. defaultValue={props.s3Bucket || ''}
  103. onChange={(e) => {
  104. props.onChangeS3Bucket(e.target.value);
  105. }}
  106. />
  107. </div>
  108. </div>
  109. <div className="row">
  110. <label className="text-start text-md-end col-md-3 col-form-label">
  111. Access key ID
  112. </label>
  113. <div className="col-md-6">
  114. <input
  115. className="form-control"
  116. type="text"
  117. defaultValue={props.s3AccessKeyId || ''}
  118. onChange={(e) => {
  119. props?.onChangeS3AccessKeyId(e.target.value);
  120. }}
  121. />
  122. </div>
  123. </div>
  124. <div className="row">
  125. <label className="text-start text-md-end col-md-3 col-form-label">
  126. Secret access key
  127. </label>
  128. <div className="col-md-6">
  129. <input
  130. className="form-control"
  131. type="text"
  132. onChange={(e) => {
  133. props?.onChangeS3SecretAccessKey(e.target.value);
  134. }}
  135. />
  136. <p className="form-text text-muted">{t('admin:app_setting.s3_secret_access_key_input_description')}</p>
  137. </div>
  138. </div>
  139. </>
  140. );
  141. };