AwsSetting.tsx 4.4 KB

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