AwsSetting.tsx 4.6 KB

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