itizawa 5 ani în urmă
părinte
comite
e571884966

+ 11 - 11
src/client/js/components/Admin/App/AwsSetting.jsx

@@ -25,7 +25,7 @@ class AwsSetting extends React.Component {
 
 
     try {
     try {
       await adminAppContainer.updateAwsSettingHandler();
       await adminAppContainer.updateAwsSettingHandler();
-      toastSuccess(t('toaster.update_successed', { target: t('admin:app_setting.aws_settings') }));
+      toastSuccess(t('toaster.update_successed', { target: t('admin:app_setting.aws_label') }));
     }
     }
     catch (err) {
     catch (err) {
       toastError(err);
       toastError(err);
@@ -46,9 +46,9 @@ class AwsSetting extends React.Component {
             <input
             <input
               className="form-control"
               className="form-control"
               placeholder={`${t('eg')} ap-northeast-1`}
               placeholder={`${t('eg')} ap-northeast-1`}
-              defaultValue={adminAppContainer.state.awsS3Region || ''}
+              defaultValue={adminAppContainer.state.s3Region || ''}
               onChange={(e) => {
               onChange={(e) => {
-                adminAppContainer.changeAwsS3Region(e.target.value);
+                adminAppContainer.changeS3Region(e.target.value);
               }}
               }}
             />
             />
           </div>
           </div>
@@ -63,9 +63,9 @@ class AwsSetting extends React.Component {
               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.awsCustomEndpoint || ''}
+              defaultValue={adminAppContainer.state.s3CustomEndpoint || ''}
               onChange={(e) => {
               onChange={(e) => {
-                adminAppContainer.changeAwsCustomEndpoint(e.target.value);
+                adminAppContainer.changeS3CustomEndpoint(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>
@@ -81,9 +81,9 @@ class AwsSetting extends React.Component {
               className="form-control"
               className="form-control"
               type="text"
               type="text"
               placeholder={`${t('eg')} crowi`}
               placeholder={`${t('eg')} crowi`}
-              defaultValue={adminAppContainer.state.awsBucket || ''}
+              defaultValue={adminAppContainer.state.s3Bucket || ''}
               onChange={(e) => {
               onChange={(e) => {
-                adminAppContainer.changeAwsBucket(e.target.value);
+                adminAppContainer.changeS3Bucket(e.target.value);
               }}
               }}
             />
             />
           </div>
           </div>
@@ -97,9 +97,9 @@ class AwsSetting extends React.Component {
             <input
             <input
               className="form-control"
               className="form-control"
               type="text"
               type="text"
-              defaultValue={adminAppContainer.state.awsAccessKeyId || ''}
+              defaultValue={adminAppContainer.state.s3AccessKeyId || ''}
               onChange={(e) => {
               onChange={(e) => {
-                adminAppContainer.changeAwsAccessKeyId(e.target.value);
+                adminAppContainer.changeS3AccessKeyId(e.target.value);
               }}
               }}
             />
             />
           </div>
           </div>
@@ -113,9 +113,9 @@ class AwsSetting extends React.Component {
             <input
             <input
               className="form-control"
               className="form-control"
               type="text"
               type="text"
-              defaultValue={adminAppContainer.state.awsSecretAccessKey || ''}
+              defaultValue={adminAppContainer.state.s3SecretAccessKey || ''}
               onChange={(e) => {
               onChange={(e) => {
-                adminAppContainer.changeAwsSecretAccessKey(e.target.value);
+                adminAppContainer.changeS3SecretAccessKey(e.target.value);
               }}
               }}
             />
             />
           </div>
           </div>

+ 27 - 27
src/client/js/services/AdminAppContainer.js

@@ -44,11 +44,11 @@ export default class AdminAppContainer extends Container {
       gcsUploadNamespace: '',
       gcsUploadNamespace: '',
       envGcsUploadNamespace: '',
       envGcsUploadNamespace: '',
 
 
-      awsS3Region: '',
-      awsCustomEndpoint: '',
-      awsBucket: '',
-      awsAccessKeyId: '',
-      awsSecretAccessKey: '',
+      s3Region: '',
+      s3CustomEndpoint: '',
+      s3Bucket: '',
+      s3AccessKeyId: '',
+      s3SecretAccessKey: '',
 
 
       isEnabledPlugins: true,
       isEnabledPlugins: true,
     };
     };
@@ -86,11 +86,11 @@ export default class AdminAppContainer extends Container {
       smtpPassword: appSettingsParams.smtpPassword,
       smtpPassword: appSettingsParams.smtpPassword,
       sesAccessKeyId: appSettingsParams.sesAccessKeyId,
       sesAccessKeyId: appSettingsParams.sesAccessKeyId,
       sesSecretAccessKey: appSettingsParams.sesSecretAccessKey,
       sesSecretAccessKey: appSettingsParams.sesSecretAccessKey,
-      awsS3Region: appSettingsParams.awsS3Region,
-      awsCustomEndpoint: appSettingsParams.awsCustomEndpoint,
-      awsBucket: appSettingsParams.awsBucket,
-      awsAccessKeyId: appSettingsParams.awsAccessKeyId,
-      awsSecretAccessKey: appSettingsParams.awsSecretAccessKey,
+      s3Region: appSettingsParams.s3Region,
+      s3CustomEndpoint: appSettingsParams.s3CustomEndpoint,
+      s3Bucket: appSettingsParams.s3Bucket,
+      s3AccessKeyId: appSettingsParams.s3AccessKeyId,
+      s3SecretAccessKey: appSettingsParams.s3SecretAccessKey,
       isEnabledPlugins: appSettingsParams.isEnabledPlugins,
       isEnabledPlugins: appSettingsParams.isEnabledPlugins,
     });
     });
   }
   }
@@ -174,17 +174,17 @@ export default class AdminAppContainer extends Container {
   }
   }
 
 
   /**
   /**
-   * Change awsS3Region
+   * Change s3Region
    */
    */
-  changeAwsS3Region(awsS3Region) {
-    this.setState({ awsS3Region });
+  changeS3Region(s3Region) {
+    this.setState({ s3Region });
   }
   }
 
 
   /**
   /**
-   * Change awsCustomEndpoint
+   * Change s3CustomEndpoint
    */
    */
-  changeAwsCustomEndpoint(awsCustomEndpoint) {
-    this.setState({ awsCustomEndpoint });
+  changeS3CustomEndpoint(s3CustomEndpoint) {
+    this.setState({ s3CustomEndpoint });
   }
   }
 
 
   /**
   /**
@@ -197,22 +197,22 @@ export default class AdminAppContainer extends Container {
   /**
   /**
    * Change region
    * Change region
    */
    */
-  changeAwsBucket(awsBucket) {
-    this.setState({ awsBucket });
+  changeS3Bucket(s3Bucket) {
+    this.setState({ s3Bucket });
   }
   }
 
 
   /**
   /**
    * Change access key id
    * Change access key id
    */
    */
-  changeAwsAccessKeyId(awsAccessKeyId) {
-    this.setState({ awsAccessKeyId });
+  changeS3AccessKeyId(s3AccessKeyId) {
+    this.setState({ s3AccessKeyId });
   }
   }
 
 
   /**
   /**
    * Change secret access key
    * Change secret access key
    */
    */
-  changeAwsSecretAccessKey(awsSecretAccessKey) {
-    this.setState({ awsSecretAccessKey });
+  changeS3SecretAccessKey(s3SecretAccessKey) {
+    this.setState({ s3SecretAccessKey });
   }
   }
 
 
   /**
   /**
@@ -336,11 +336,11 @@ export default class AdminAppContainer extends Container {
    */
    */
   async updateAwsSettingHandler() {
   async updateAwsSettingHandler() {
     const response = await this.appContainer.apiv3.put('/app-settings/aws-setting', {
     const response = await this.appContainer.apiv3.put('/app-settings/aws-setting', {
-      awsS3Region: this.state.awsS3Region,
-      awsCustomEndpoint: this.state.awsCustomEndpoint,
-      awsBucket: this.state.awsBucket,
-      awsAccessKeyId: this.state.awsAccessKeyId,
-      awsSecretAccessKey: this.state.awsSecretAccessKey,
+      s3Region: this.state.s3Region,
+      s3CustomEndpoint: this.state.s3CustomEndpoint,
+      s3Bucket: this.state.s3Bucket,
+      s3AccessKeyId: this.state.s3AccessKeyId,
+      s3SecretAccessKey: this.state.s3SecretAccessKey,
     });
     });
     const { awsSettingParams } = response.data;
     const { awsSettingParams } = response.data;
     return awsSettingParams;
     return awsSettingParams;

+ 20 - 20
src/server/routes/apiv3/app-settings.js

@@ -160,11 +160,11 @@ module.exports = (crowi) => {
       body('sesSecretAccessKey').trim(),
       body('sesSecretAccessKey').trim(),
     ],
     ],
     awsSetting: [
     awsSetting: [
-      body('awsS3Region').trim().matches(/^[a-z]+-[a-z]+-\d+$/).withMessage((value, { req }) => req.t('validation.aws_region')),
-      body('awsCustomEndpoint').trim().matches(/^(https?:\/\/[^/]+|)$/).withMessage((value, { req }) => req.t('validation.aws_custom_endpoint')),
-      body('awsBucket').trim(),
-      body('awsAccessKeyId').trim().if(value => value !== '').matches(/^[\da-zA-Z]+$/),
-      body('awsSecretAccessKey').trim(),
+      body('s3Region').trim().matches(/^[a-z]+-[a-z]+-\d+$/).withMessage((value, { req }) => req.t('validation.aws_region')),
+      body('s3CustomEndpoint').trim().matches(/^(https?:\/\/[^/]+|)$/).withMessage((value, { req }) => req.t('validation.aws_custom_endpoint')),
+      body('s3Bucket').trim(),
+      body('s3AccessKeyId').trim().if(value => value !== '').matches(/^[\da-zA-Z]+$/),
+      body('s3SecretAccessKey').trim(),
     ],
     ],
     gcpSetting: [
     gcpSetting: [
       body('gcsApiKeyJsonPath').trim(),
       body('gcsApiKeyJsonPath').trim(),
@@ -213,11 +213,11 @@ module.exports = (crowi) => {
       smtpPassword: crowi.configManager.getConfig('crowi', 'mail:smtpPassword'),
       smtpPassword: crowi.configManager.getConfig('crowi', 'mail:smtpPassword'),
       sesAccessKeyId: crowi.configManager.getConfig('crowi', 'mail:sesAccessKeyId'),
       sesAccessKeyId: crowi.configManager.getConfig('crowi', 'mail:sesAccessKeyId'),
       sesSecretAccessKey: crowi.configManager.getConfig('crowi', 'mail:sesSecretAccessKey'),
       sesSecretAccessKey: crowi.configManager.getConfig('crowi', 'mail:sesSecretAccessKey'),
-      awsS3Region: crowi.configManager.getConfig('crowi', 'aws:region'),
-      awsCustomEndpoint: crowi.configManager.getConfig('crowi', 'aws:customEndpoint'),
-      awsBucket: crowi.configManager.getConfig('crowi', 'aws:bucket'),
-      awsAccessKeyId: crowi.configManager.getConfig('crowi', 'aws:accessKeyId'),
-      awsSecretAccessKey: crowi.configManager.getConfig('crowi', 'aws:secretAccessKey'),
+      s3Region: crowi.configManager.getConfig('crowi', 'aws:region'),
+      s3CustomEndpoint: crowi.configManager.getConfig('crowi', 'aws:customEndpoint'),
+      s3Bucket: crowi.configManager.getConfig('crowi', 'aws:bucket'),
+      s3AccessKeyId: crowi.configManager.getConfig('crowi', 'aws:accessKeyId'),
+      s3SecretAccessKey: crowi.configManager.getConfig('crowi', 'aws:secretAccessKey'),
       isEnabledPlugins: crowi.configManager.getConfig('crowi', 'plugin:isEnabledPlugins'),
       isEnabledPlugins: crowi.configManager.getConfig('crowi', 'plugin:isEnabledPlugins'),
     };
     };
     return res.apiv3({ appSettingsParams });
     return res.apiv3({ appSettingsParams });
@@ -550,11 +550,11 @@ module.exports = (crowi) => {
    */
    */
   router.put('/aws-setting', loginRequiredStrictly, adminRequired, csrf, validator.awsSetting, apiV3FormValidator, async(req, res) => {
   router.put('/aws-setting', loginRequiredStrictly, adminRequired, csrf, validator.awsSetting, apiV3FormValidator, async(req, res) => {
     const requestAwsSettingParams = {
     const requestAwsSettingParams = {
-      'aws:region': req.body.awsS3Region,
-      'aws:customEndpoint': req.body.awsCustomEndpoint,
-      'aws:bucket': req.body.awsBucket,
-      'aws:accessKeyId': req.body.awsAccessKeyId,
-      'aws:secretAccessKey': req.body.awsSecretAccessKey,
+      'aws:region': req.body.s3Region,
+      'aws:customEndpoint': req.body.s3CustomEndpoint,
+      'aws:bucket': req.body.s3Bucket,
+      'aws:accessKeyId': req.body.s3AccessKeyId,
+      'aws:secretAccessKey': req.body.s3SecretAccessKey,
     };
     };
 
 
     try {
     try {
@@ -563,11 +563,11 @@ module.exports = (crowi) => {
       // TODO GW-3797 re-setup file uploader
       // TODO GW-3797 re-setup file uploader
 
 
       const awsSettingParams = {
       const awsSettingParams = {
-        awsS3Region: crowi.configManager.getConfig('crowi', 'aws:region'),
-        awsCustomEndpoint: crowi.configManager.getConfig('crowi', 'aws:customEndpoint'),
-        awsBucket: crowi.configManager.getConfig('crowi', 'aws:bucket'),
-        awsAccessKeyId: crowi.configManager.getConfig('crowi', 'aws:accessKeyId'),
-        awsSecretAccessKey: crowi.configManager.getConfig('crowi', 'aws:secretAccessKey'),
+        s3Region: crowi.configManager.getConfig('crowi', 'aws:region'),
+        s3CustomEndpoint: crowi.configManager.getConfig('crowi', 'aws:customEndpoint'),
+        s3Bucket: crowi.configManager.getConfig('crowi', 'aws:bucket'),
+        s3AccessKeyId: crowi.configManager.getConfig('crowi', 'aws:accessKeyId'),
+        s3SecretAccessKey: crowi.configManager.getConfig('crowi', 'aws:secretAccessKey'),
       };
       };
       return res.apiv3({ awsSettingParams });
       return res.apiv3({ awsSettingParams });
     }
     }