itizawa 5 лет назад
Родитель
Сommit
4badb8c9e2

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

@@ -58,9 +58,9 @@ class AwsSetting extends React.Component {
             <input
               className="form-control"
               placeholder={`${t('eg')} ap-northeast-1`}
-              defaultValue={adminAppContainer.state.region || ''}
+              defaultValue={adminAppContainer.state.awsRegion || ''}
               onChange={(e) => {
-                adminAppContainer.changeRegion(e.target.value);
+                adminAppContainer.changeAwsRegion(e.target.value);
               }}
             />
           </div>
@@ -75,9 +75,9 @@ class AwsSetting extends React.Component {
               className="form-control"
               type="text"
               placeholder={`${t('eg')} http://localhost:9000`}
-              defaultValue={adminAppContainer.state.customEndpoint || ''}
+              defaultValue={adminAppContainer.state.awsCustomEndpoint || ''}
               onChange={(e) => {
-                adminAppContainer.changeCustomEndpoint(e.target.value);
+                adminAppContainer.changeAwsCustomEndpoint(e.target.value);
               }}
             />
             <p className="form-text text-muted">{t('admin:app_setting.custom_endpoint_change')}</p>
@@ -93,9 +93,9 @@ class AwsSetting extends React.Component {
               className="form-control"
               type="text"
               placeholder={`${t('eg')} crowi`}
-              defaultValue={adminAppContainer.state.bucket || ''}
+              defaultValue={adminAppContainer.state.awsBucket || ''}
               onChange={(e) => {
-                adminAppContainer.changeBucket(e.target.value);
+                adminAppContainer.changeAwsBucket(e.target.value);
               }}
             />
           </div>
@@ -109,9 +109,9 @@ class AwsSetting extends React.Component {
             <input
               className="form-control"
               type="text"
-              defaultValue={adminAppContainer.state.accessKeyId || ''}
+              defaultValue={adminAppContainer.state.awsAccessKeyId || ''}
               onChange={(e) => {
-                adminAppContainer.changeAccessKeyId(e.target.value);
+                adminAppContainer.changeAwsAccessKeyId(e.target.value);
               }}
             />
           </div>
@@ -125,9 +125,9 @@ class AwsSetting extends React.Component {
             <input
               className="form-control"
               type="text"
-              defaultValue={adminAppContainer.state.secretAccessKey || ''}
+              defaultValue={adminAppContainer.state.awsSecretAccessKey || ''}
               onChange={(e) => {
-                adminAppContainer.changeSecretAccessKey(e.target.value);
+                adminAppContainer.changeAwsSecretAccessKey(e.target.value);
               }}
             />
           </div>

+ 28 - 44
src/client/js/services/AdminAppContainer.js

@@ -28,30 +28,14 @@ export default class AdminAppContainer extends Container {
       smtpPort: '',
       smtpUser: '',
       smtpPassword: '',
-      region: '',
-      customEndpoint: '',
-      bucket: '',
-      accessKeyId: '',
-      secretAccessKey: '',
+      awsRegion: '',
+      awsCustomEndpoint: '',
+      awsBucket: '',
+      awsAccessKeyId: '',
+      awsSecretAccessKey: '',
       isEnabledPlugins: true,
     };
 
-    this.changeTitle = this.changeTitle.bind(this);
-    this.changeConfidential = this.changeConfidential.bind(this);
-    this.changeGlobalLang = this.changeGlobalLang.bind(this);
-    this.changeFileUpload = this.changeFileUpload.bind(this);
-    this.changeSiteUrl = this.changeSiteUrl.bind(this);
-    this.changeFromAddress = this.changeFromAddress.bind(this);
-    this.changeSmtpHost = this.changeSmtpHost.bind(this);
-    this.changeSmtpPort = this.changeSmtpPort.bind(this);
-    this.changeSmtpUser = this.changeSmtpUser.bind(this);
-    this.changeSmtpPassword = this.changeSmtpPassword.bind(this);
-    this.changeRegion = this.changeRegion.bind(this);
-    this.changeCustomEndpoint = this.changeCustomEndpoint.bind(this);
-    this.changeBucket = this.changeBucket.bind(this);
-    this.changeAccessKeyId = this.changeAccessKeyId.bind(this);
-    this.changeSecretAccessKey = this.changeSecretAccessKey.bind(this);
-    this.changeIsEnabledPlugins = this.changeIsEnabledPlugins.bind(this);
     this.updateAppSettingHandler = this.updateAppSettingHandler.bind(this);
     this.updateSiteUrlSettingHandler = this.updateSiteUrlSettingHandler.bind(this);
     this.updateMailSettingHandler = this.updateMailSettingHandler.bind(this);
@@ -86,11 +70,11 @@ export default class AdminAppContainer extends Container {
       smtpPort: appSettingsParams.smtpPort,
       smtpUser: appSettingsParams.smtpUser,
       smtpPassword: appSettingsParams.smtpPassword,
-      region: appSettingsParams.region,
-      customEndpoint: appSettingsParams.customEndpoint,
-      bucket: appSettingsParams.bucket,
-      accessKeyId: appSettingsParams.accessKeyId,
-      secretAccessKey: appSettingsParams.secretAccessKey,
+      awsRegion: appSettingsParams.awsRegion,
+      awsCustomEndpoint: appSettingsParams.awsCustomEndpoint,
+      awsBucket: appSettingsParams.awsBucket,
+      awsAccessKeyId: appSettingsParams.awsAccessKeyId,
+      awsSecretAccessKey: appSettingsParams.awsSecretAccessKey,
       isEnabledPlugins: appSettingsParams.isEnabledPlugins,
     });
   }
@@ -167,38 +151,38 @@ export default class AdminAppContainer extends Container {
   }
 
   /**
-   * Change region
+   * Change awsRegion
    */
-  changeRegion(region) {
-    this.setState({ region });
+  changeAwsRegion(awsRegion) {
+    this.setState({ awsRegion });
   }
 
   /**
-   * Change custom endpoint
+   * Change awsCustomEndpoint
    */
-  changeCustomEndpoint(customEndpoint) {
-    this.setState({ customEndpoint });
+  changeAwsCustomEndpoint(awsCustomEndpoint) {
+    this.setState({ awsCustomEndpoint });
   }
 
   /**
-   * Change bucket name
+   * Change awsBucket name
    */
-  changeBucket(bucket) {
-    this.setState({ bucket });
+  changeAwsBucket(awsBucket) {
+    this.setState({ awsBucket });
   }
 
   /**
    * Change access key id
    */
-  changeAccessKeyId(accessKeyId) {
-    this.setState({ accessKeyId });
+  changeAwsAccessKeyId(awsAccessKeyId) {
+    this.setState({ awsAccessKeyId });
   }
 
   /**
    * Change secret access key
    */
-  changeSecretAccessKey(secretAccessKey) {
-    this.setState({ secretAccessKey });
+  changeAwsSecretAccessKey(awsSecretAccessKey) {
+    this.setState({ awsSecretAccessKey });
   }
 
   /**
@@ -289,11 +273,11 @@ export default class AdminAppContainer extends Container {
    */
   async updateAwsSettingHandler() {
     const response = await this.appContainer.apiv3.put('/app-settings/aws-setting', {
-      region: this.state.region,
-      customEndpoint: this.state.customEndpoint,
-      bucket: this.state.bucket,
-      accessKeyId: this.state.accessKeyId,
-      secretAccessKey: this.state.secretAccessKey,
+      awsRegion: this.state.awsRegion,
+      awsCustomEndpoint: this.state.awsCustomEndpoint,
+      awsBucket: this.state.awsBucket,
+      awsAccessKeyId: this.state.awsAccessKeyId,
+      awsSecretAccessKey: this.state.awsSecretAccessKey,
     });
     const { awsSettingParams } = response.data;
     return awsSettingParams;

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

@@ -129,11 +129,11 @@ module.exports = (crowi) => {
       body('smtpPassword').trim(),
     ],
     awsSetting: [
-      body('region').trim().matches(/^[a-z]+-[a-z]+-\d+$/).withMessage((value, { req }) => req.t('validation.aws_region')),
-      body('customEndpoint').trim().matches(/^(https?:\/\/[^/]+|)$/).withMessage((value, { req }) => req.t('validation.aws_custom_endpoint')),
-      body('bucket').trim(),
-      body('accessKeyId').trim().matches(/^[\da-zA-Z]+$/),
-      body('secretAccessKey').trim(),
+      body('awsRegion').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().matches(/^[\da-zA-Z]+$/),
+      body('awsSecretAccessKey').trim(),
     ],
     pluginSetting: [
       body('isEnabledPlugins').isBoolean(),
@@ -173,11 +173,11 @@ module.exports = (crowi) => {
       smtpPort: crowi.configManager.getConfig('crowi', 'mail:smtpPort'),
       smtpUser: crowi.configManager.getConfig('crowi', 'mail:smtpUser'),
       smtpPassword: crowi.configManager.getConfig('crowi', 'mail:smtpPassword'),
-      region: crowi.configManager.getConfig('crowi', 'aws:region'),
-      customEndpoint: crowi.configManager.getConfig('crowi', 'aws:customEndpoint'),
-      bucket: crowi.configManager.getConfig('crowi', 'aws:bucket'),
-      accessKeyId: crowi.configManager.getConfig('crowi', 'aws:accessKeyId'),
-      secretAccessKey: crowi.configManager.getConfig('crowi', 'aws:secretAccessKey'),
+      awsRegion: 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'),
       isEnabledPlugins: crowi.configManager.getConfig('crowi', 'plugin:isEnabledPlugins'),
     };
     return res.apiv3({ appSettingsParams });
@@ -508,11 +508,11 @@ module.exports = (crowi) => {
    */
   router.put('/aws-setting', loginRequiredStrictly, adminRequired, csrf, validator.awsSetting, apiV3FormValidator, async(req, res) => {
     const requestAwsSettingParams = {
-      'aws:region': req.body.region,
-      'aws:customEndpoint': req.body.customEndpoint,
-      'aws:bucket': req.body.bucket,
-      'aws:accessKeyId': req.body.accessKeyId,
-      'aws:secretAccessKey': req.body.secretAccessKey,
+      'aws:region': req.body.awsRegion,
+      'aws:customEndpoint': req.body.awsCustomEndpoint,
+      'aws:bucket': req.body.awsBucket,
+      'aws:accessKeyId': req.body.awsAccessKeyId,
+      'aws:secretAccessKey': req.body.awsSecretAccessKey,
     };
 
     try {
@@ -525,11 +525,11 @@ module.exports = (crowi) => {
       mailService.publishUpdatedMessage();
 
       const awsSettingParams = {
-        region: crowi.configManager.getConfig('crowi', 'aws:region'),
-        customEndpoint: crowi.configManager.getConfig('crowi', 'aws:customEndpoint'),
-        bucket: crowi.configManager.getConfig('crowi', 'aws:bucket'),
-        accessKeyId: crowi.configManager.getConfig('crowi', 'aws:accessKeyId'),
-        secretAccessKey: crowi.configManager.getConfig('crowi', 'aws:secretAccessKey'),
+        awsRegion: 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'),
       };
       return res.apiv3({ awsSettingParams });
     }