From 8d680cf64ec7fb6c8b242b8048989d0f0550cb68 Mon Sep 17 00:00:00 2001
From: Saturnino Abril <saturnino.abril@gmail.com>
Date: Wed, 6 Sep 2017 03:42:18 +0800
Subject: [PLT-7475] Add S3 region to system console and add S3 validation
 (#7373)

* add S3 region to system console and add S3 validation

* update translation message

* add bool as return value to Validate* functions

* update Validate* functions to be pure
---
 .../components/admin_console/storage_settings.jsx   | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

(limited to 'webapp/components/admin_console/storage_settings.jsx')

diff --git a/webapp/components/admin_console/storage_settings.jsx b/webapp/components/admin_console/storage_settings.jsx
index 4b20a8b93..54bbdb798 100644
--- a/webapp/components/admin_console/storage_settings.jsx
+++ b/webapp/components/admin_console/storage_settings.jsx
@@ -34,6 +34,7 @@ export default class StorageSettings extends AdminSettings {
         config.FileSettings.AmazonS3AccessKeyId = this.state.amazonS3AccessKeyId;
         config.FileSettings.AmazonS3SecretAccessKey = this.state.amazonS3SecretAccessKey;
         config.FileSettings.AmazonS3Bucket = this.state.amazonS3Bucket;
+        config.FileSettings.AmazonS3Region = this.state.amazonS3Region;
         config.FileSettings.AmazonS3Endpoint = this.state.amazonS3Endpoint;
         config.FileSettings.AmazonS3SSL = this.state.amazonS3SSL;
         config.FileSettings.AmazonS3SSE = this.state.amazonS3SSE;
@@ -53,6 +54,7 @@ export default class StorageSettings extends AdminSettings {
             amazonS3AccessKeyId: config.FileSettings.AmazonS3AccessKeyId,
             amazonS3SecretAccessKey: config.FileSettings.AmazonS3SecretAccessKey,
             amazonS3Bucket: config.FileSettings.AmazonS3Bucket,
+            amazonS3Region: config.FileSettings.AmazonS3Region,
             amazonS3Endpoint: config.FileSettings.AmazonS3Endpoint,
             amazonS3SSL: config.FileSettings.AmazonS3SSL,
             amazonS3SSE: config.FileSettings.AmazonS3SSE,
@@ -241,6 +243,25 @@ export default class StorageSettings extends AdminSettings {
                     onChange={this.handleChange}
                     disabled={this.state.driverName !== DRIVER_S3}
                 />
+                <TextSetting
+                    id='amazonS3Region'
+                    label={
+                        <FormattedMessage
+                            id='admin.image.amazonS3RegionTitle'
+                            defaultMessage='Amazon S3 Region:'
+                        />
+                    }
+                    placeholder={Utils.localizeMessage('admin.image.amazonS3RegionExample', 'Ex "us-east-1"')}
+                    helpText={
+                        <FormattedMessage
+                            id='admin.image.amazonS3RegionDescription'
+                            defaultMessage='(Optional) AWS region you selected when creating your S3 bucket. If no region is set, Mattermost attempts to get the appropriate region from AWS, or sets it to "us-east-1" if none found.'
+                        />
+                    }
+                    value={this.state.amazonS3Region}
+                    onChange={this.handleChange}
+                    disabled={this.state.driverName !== DRIVER_S3}
+                />
                 <TextSetting
                     id='amazonS3Endpoint'
                     label={
-- 
cgit v1.2.3-1-g7c22

