|
@@ -1,17 +1,29 @@
|
|
|
-import React from 'react';
|
|
|
|
|
|
|
+import React, { useCallback } from 'react';
|
|
|
|
|
|
|
|
-import PropTypes from 'prop-types';
|
|
|
|
|
import { useTranslation } from 'next-i18next';
|
|
import { useTranslation } from 'next-i18next';
|
|
|
|
|
+import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import AdminAppContainer from '~/client/services/AdminAppContainer';
|
|
import AdminAppContainer from '~/client/services/AdminAppContainer';
|
|
|
|
|
|
|
|
import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
|
|
|
|
|
|
|
|
+type AwsSettingMoleculeProps = {
|
|
|
|
|
+ s3ReferenceFileWithRelayMode
|
|
|
|
|
+ s3Region
|
|
|
|
|
+ s3CustomEndpoint
|
|
|
|
|
+ s3Bucket
|
|
|
|
|
+ s3AccessKeyId
|
|
|
|
|
+ s3SecretAccessKey
|
|
|
|
|
+ onChangeS3ReferenceFileWithRelayMode: (val: boolean) => void
|
|
|
|
|
+ onChangeS3Region: (val: string) => void
|
|
|
|
|
+ onChangeS3CustomEndpoint: (val: string) => void
|
|
|
|
|
+ onChangeS3Bucket: (val: string) => void
|
|
|
|
|
+ onChangeS3AccessKeyId: (val: string) => void
|
|
|
|
|
+ onChangeS3SecretAccessKey: (val: string) => void
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
-function AwsSetting(props) {
|
|
|
|
|
|
|
+export const AwsSettingMolecule = (props: AwsSettingMoleculeProps): JSX.Element => {
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
- const { adminAppContainer } = props;
|
|
|
|
|
- const { s3ReferenceFileWithRelayMode } = adminAppContainer.state;
|
|
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<React.Fragment>
|
|
<React.Fragment>
|
|
@@ -31,21 +43,21 @@ function AwsSetting(props) {
|
|
|
aria-haspopup="true"
|
|
aria-haspopup="true"
|
|
|
aria-expanded="true"
|
|
aria-expanded="true"
|
|
|
>
|
|
>
|
|
|
- {s3ReferenceFileWithRelayMode && t('admin:app_setting.file_delivery_method_relay')}
|
|
|
|
|
- {!s3ReferenceFileWithRelayMode && t('admin:app_setting.file_delivery_method_redirect')}
|
|
|
|
|
|
|
+ {props.s3ReferenceFileWithRelayMode && t('admin:app_setting.file_delivery_method_relay')}
|
|
|
|
|
+ {!props.s3ReferenceFileWithRelayMode && t('admin:app_setting.file_delivery_method_redirect')}
|
|
|
</button>
|
|
</button>
|
|
|
<div className="dropdown-menu" aria-labelledby="ddS3ReferenceFileWithRelayMode">
|
|
<div className="dropdown-menu" aria-labelledby="ddS3ReferenceFileWithRelayMode">
|
|
|
<button
|
|
<button
|
|
|
className="dropdown-item"
|
|
className="dropdown-item"
|
|
|
type="button"
|
|
type="button"
|
|
|
- onClick={() => { adminAppContainer.changeS3ReferenceFileWithRelayMode(true) }}
|
|
|
|
|
|
|
+ onClick={() => { props?.onChangeS3ReferenceFileWithRelayMode(true) }}
|
|
|
>
|
|
>
|
|
|
{t('admin:app_setting.file_delivery_method_relay')}
|
|
{t('admin:app_setting.file_delivery_method_relay')}
|
|
|
</button>
|
|
</button>
|
|
|
<button
|
|
<button
|
|
|
className="dropdown-item"
|
|
className="dropdown-item"
|
|
|
type="button"
|
|
type="button"
|
|
|
- onClick={() => { adminAppContainer.changeS3ReferenceFileWithRelayMode(false) }}
|
|
|
|
|
|
|
+ onClick={() => { props?.onChangeS3ReferenceFileWithRelayMode(false) }}
|
|
|
>
|
|
>
|
|
|
{ t('admin:app_setting.file_delivery_method_redirect')}
|
|
{ t('admin:app_setting.file_delivery_method_redirect')}
|
|
|
</button>
|
|
</button>
|
|
@@ -68,9 +80,9 @@ function AwsSetting(props) {
|
|
|
<input
|
|
<input
|
|
|
className="form-control"
|
|
className="form-control"
|
|
|
placeholder={`${t('eg')} ap-northeast-1`}
|
|
placeholder={`${t('eg')} ap-northeast-1`}
|
|
|
- defaultValue={adminAppContainer.state.s3Region || ''}
|
|
|
|
|
|
|
+ defaultValue={props.s3Region || ''}
|
|
|
onChange={(e) => {
|
|
onChange={(e) => {
|
|
|
- adminAppContainer.changeS3Region(e.target.value);
|
|
|
|
|
|
|
+ props?.onChangeS3Region(e.target.value);
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
@@ -85,9 +97,9 @@ function AwsSetting(props) {
|
|
|
className="form-control"
|
|
className="form-control"
|
|
|
type="text"
|
|
type="text"
|
|
|
placeholder={`${t('eg')} http://localhost:9000`}
|
|
placeholder={`${t('eg')} http://localhost:9000`}
|
|
|
- defaultValue={adminAppContainer.state.s3CustomEndpoint || ''}
|
|
|
|
|
|
|
+ defaultValue={props.s3CustomEndpoint || ''}
|
|
|
onChange={(e) => {
|
|
onChange={(e) => {
|
|
|
- adminAppContainer.changeS3CustomEndpoint(e.target.value);
|
|
|
|
|
|
|
+ props?.onChangeS3CustomEndpoint(e.target.value);
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
<p className="form-text text-muted">{t('admin:app_setting.custom_endpoint_change')}</p>
|
|
<p className="form-text text-muted">{t('admin:app_setting.custom_endpoint_change')}</p>
|
|
@@ -103,9 +115,9 @@ function AwsSetting(props) {
|
|
|
className="form-control"
|
|
className="form-control"
|
|
|
type="text"
|
|
type="text"
|
|
|
placeholder={`${t('eg')} crowi`}
|
|
placeholder={`${t('eg')} crowi`}
|
|
|
- defaultValue={adminAppContainer.state.s3Bucket || ''}
|
|
|
|
|
|
|
+ defaultValue={props.s3Bucket || ''}
|
|
|
onChange={(e) => {
|
|
onChange={(e) => {
|
|
|
- adminAppContainer.changeS3Bucket(e.target.value);
|
|
|
|
|
|
|
+ props.onChangeS3Bucket(e.target.value);
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
@@ -119,9 +131,9 @@ function AwsSetting(props) {
|
|
|
<input
|
|
<input
|
|
|
className="form-control"
|
|
className="form-control"
|
|
|
type="text"
|
|
type="text"
|
|
|
- defaultValue={adminAppContainer.state.s3AccessKeyId || ''}
|
|
|
|
|
|
|
+ defaultValue={props.s3AccessKeyId || ''}
|
|
|
onChange={(e) => {
|
|
onChange={(e) => {
|
|
|
- adminAppContainer.changeS3AccessKeyId(e.target.value);
|
|
|
|
|
|
|
+ props?.onChangeS3AccessKeyId(e.target.value);
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
@@ -135,9 +147,9 @@ function AwsSetting(props) {
|
|
|
<input
|
|
<input
|
|
|
className="form-control"
|
|
className="form-control"
|
|
|
type="text"
|
|
type="text"
|
|
|
- defaultValue={adminAppContainer.state.s3SecretAccessKey || ''}
|
|
|
|
|
|
|
+ defaultValue={props.s3SecretAccessKey || ''}
|
|
|
onChange={(e) => {
|
|
onChange={(e) => {
|
|
|
- adminAppContainer.changeS3SecretAccessKey(e.target.value);
|
|
|
|
|
|
|
+ props?.onChangeS3SecretAccessKey(e.target.value);
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
@@ -146,7 +158,56 @@ function AwsSetting(props) {
|
|
|
|
|
|
|
|
</React.Fragment>
|
|
</React.Fragment>
|
|
|
);
|
|
);
|
|
|
-}
|
|
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+const AwsSetting = (props) => {
|
|
|
|
|
+ const { adminAppContainer } = props;
|
|
|
|
|
+ const {
|
|
|
|
|
+ s3ReferenceFileWithRelayMode,
|
|
|
|
|
+ s3Region, s3CustomEndpoint, s3Bucket,
|
|
|
|
|
+ s3AccessKeyId, s3SecretAccessKey,
|
|
|
|
|
+ } = adminAppContainer.state;
|
|
|
|
|
+
|
|
|
|
|
+ const onChangeS3ReferenceFileWithRelayModeHandler = useCallback((val: boolean) => {
|
|
|
|
|
+ adminAppContainer.changeS3ReferenceFileWithRelayMode(val);
|
|
|
|
|
+ }, [adminAppContainer]);
|
|
|
|
|
+
|
|
|
|
|
+ const onChangeS3RegionHandler = useCallback((val: string) => {
|
|
|
|
|
+ adminAppContainer.changeS3Region(val);
|
|
|
|
|
+ }, [adminAppContainer]);
|
|
|
|
|
+
|
|
|
|
|
+ const onChangeS3CustomEndpointHandler = useCallback((val: string) => {
|
|
|
|
|
+ adminAppContainer.changeS3CustomEndpoint(val);
|
|
|
|
|
+ }, [adminAppContainer]);
|
|
|
|
|
+
|
|
|
|
|
+ const onChangeS3BucketHandler = useCallback((val: string) => {
|
|
|
|
|
+ adminAppContainer.changeS3Bucket(val);
|
|
|
|
|
+ }, [adminAppContainer]);
|
|
|
|
|
+
|
|
|
|
|
+ const onChangeS3AccessKeyIdHandler = useCallback((val: string) => {
|
|
|
|
|
+ adminAppContainer.changeS3AccessKeyId(val);
|
|
|
|
|
+ }, [adminAppContainer]);
|
|
|
|
|
+
|
|
|
|
|
+ const onChangeS3SecretAccessKeyHandler = useCallback((val: string) => {
|
|
|
|
|
+ adminAppContainer.changeS3SecretAccessKey(val);
|
|
|
|
|
+ }, [adminAppContainer]);
|
|
|
|
|
+
|
|
|
|
|
+ return <AwsSettingMolecule
|
|
|
|
|
+ s3ReferenceFileWithRelayMode={s3ReferenceFileWithRelayMode}
|
|
|
|
|
+ s3Region={s3Region}
|
|
|
|
|
+ s3CustomEndpoint={s3CustomEndpoint}
|
|
|
|
|
+ s3Bucket={s3Bucket}
|
|
|
|
|
+ s3AccessKeyId={s3AccessKeyId}
|
|
|
|
|
+ s3SecretAccessKey={s3SecretAccessKey}
|
|
|
|
|
+ onChangeS3ReferenceFileWithRelayMode={onChangeS3ReferenceFileWithRelayModeHandler}
|
|
|
|
|
+ onChangeS3Region={onChangeS3RegionHandler}
|
|
|
|
|
+ onChangeS3CustomEndpoint={onChangeS3CustomEndpointHandler}
|
|
|
|
|
+ onChangeS3Bucket={onChangeS3BucketHandler}
|
|
|
|
|
+ onChangeS3AccessKeyId={onChangeS3AccessKeyIdHandler}
|
|
|
|
|
+ onChangeS3SecretAccessKey={onChangeS3SecretAccessKeyHandler}
|
|
|
|
|
+ />;
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|