| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- import type { JSX } from 'react';
- import { useTranslation } from 'next-i18next';
- import type { UseFormRegister } from 'react-hook-form';
- import type { FileUploadFormValues } from './FileUploadSetting.types';
- export type GcsSettingMoleculeProps = {
- register: UseFormRegister<FileUploadFormValues>;
- gcsReferenceFileWithRelayMode: boolean;
- gcsUseOnlyEnvVars: boolean;
- envGcsApiKeyJsonPath?: string;
- envGcsBucket?: string;
- envGcsUploadNamespace?: string;
- onChangeGcsReferenceFileWithRelayMode: (val: boolean) => void;
- isCloud: boolean;
- };
- export const GcsSettingMolecule = (
- props: GcsSettingMoleculeProps,
- ): JSX.Element => {
- const { t } = useTranslation();
- const {
- gcsReferenceFileWithRelayMode,
- gcsUseOnlyEnvVars,
- envGcsApiKeyJsonPath,
- envGcsBucket,
- envGcsUploadNamespace,
- isCloud,
- } = props;
- return (
- <>
- <div className="row my-3">
- <span className="text-start text-md-end col-md-3 col-form-label">
- {t('admin:app_setting.file_delivery_method')}
- </span>
- <div className="col-md-6">
- <div className="dropdown">
- <button
- className="btn btn-outline-secondary dropdown-toggle"
- type="button"
- id="ddGcsReferenceFileWithRelayMode"
- data-bs-toggle="dropdown"
- aria-haspopup="true"
- aria-expanded="true"
- >
- {gcsReferenceFileWithRelayMode &&
- t('admin:app_setting.file_delivery_method_relay')}
- {!gcsReferenceFileWithRelayMode &&
- t('admin:app_setting.file_delivery_method_redirect')}
- </button>
- <div className="dropdown-menu">
- <button
- className="dropdown-item"
- type="button"
- onClick={() => {
- props.onChangeGcsReferenceFileWithRelayMode(true);
- }}
- >
- {t('admin:app_setting.file_delivery_method_relay')}
- </button>
- <button
- className="dropdown-item"
- type="button"
- onClick={() => {
- props.onChangeGcsReferenceFileWithRelayMode(false);
- }}
- >
- {t('admin:app_setting.file_delivery_method_redirect')}
- </button>
- </div>
- <p className="form-text text-muted small">
- {t('admin:app_setting.file_delivery_method_redirect_info')}
- <br />
- {t('admin:app_setting.file_delivery_method_relay_info')}
- </p>
- </div>
- </div>
- </div>
- {gcsUseOnlyEnvVars &&
- (isCloud ? (
- <p className="alert alert-info">
- {t('admin:app_setting.note_for_the_only_env_option_cloud')}
- </p>
- ) : (
- <p
- className="alert alert-info"
- // biome-ignore lint/security/noDangerouslySetInnerHtml: includes markup from i18n strings
- dangerouslySetInnerHTML={{
- __html: t('admin:app_setting.note_for_the_only_env_option', {
- env: 'GCS_USES_ONLY_ENV_VARS_FOR_SOME_OPTIONS',
- }),
- }}
- />
- ))}
- <table
- className={`table settings-table ${gcsUseOnlyEnvVars && 'use-only-env-vars'}`}
- >
- <colgroup>
- <col className="item-name" />
- <col className="from-db" />
- <col className="from-env-vars" />
- </colgroup>
- <thead>
- <tr>
- <th></th>
- <th>Database</th>
- <th>Environment variables</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <th>Api Key Json Path</th>
- <td>
- <input
- className="form-control"
- type="text"
- readOnly={gcsUseOnlyEnvVars}
- {...props.register('gcsApiKeyJsonPath')}
- />
- </td>
- <td>
- <input
- className="form-control"
- type="text"
- value={envGcsApiKeyJsonPath || ''}
- readOnly
- tabIndex={-1}
- />
- <p className="form-text text-muted">
- <small
- // biome-ignore lint/security/noDangerouslySetInnerHtml: includes markup from i18n strings
- dangerouslySetInnerHTML={{
- __html: t('admin:app_setting.use_env_var_if_empty', {
- variable: 'GCS_API_KEY_JSON_PATH',
- }),
- }}
- />
- </p>
- </td>
- </tr>
- <tr>
- <th>{t('admin:app_setting.bucket_name')}</th>
- <td>
- <input
- className="form-control"
- type="text"
- readOnly={gcsUseOnlyEnvVars}
- {...props.register('gcsBucket')}
- />
- </td>
- <td>
- <input
- className="form-control"
- type="text"
- value={envGcsBucket || ''}
- readOnly
- tabIndex={-1}
- />
- <p className="form-text text-muted">
- <small
- // biome-ignore lint/security/noDangerouslySetInnerHtml: includes markup from i18n strings
- dangerouslySetInnerHTML={{
- __html: t('admin:app_setting.use_env_var_if_empty', {
- variable: 'GCS_BUCKET',
- }),
- }}
- />
- </p>
- </td>
- </tr>
- <tr>
- <th>Name Space</th>
- <td>
- <input
- className="form-control"
- type="text"
- readOnly={gcsUseOnlyEnvVars}
- {...props.register('gcsUploadNamespace')}
- />
- </td>
- <td>
- <input
- className="form-control"
- type="text"
- value={envGcsUploadNamespace || ''}
- readOnly
- tabIndex={-1}
- />
- <p className="form-text text-muted">
- <small
- // biome-ignore lint/security/noDangerouslySetInnerHtml: includes markup from i18n strings
- dangerouslySetInnerHTML={{
- __html: t('admin:app_setting.use_env_var_if_empty', {
- variable: 'GCS_UPLOAD_NAMESPACE',
- }),
- }}
- />
- </p>
- </td>
- </tr>
- </tbody>
- </table>
- </>
- );
- };
|