AwsSetting.tsx 5.0 KB

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