From f4dd8e579639637057e8717067bb0627d9eb1de3 Mon Sep 17 00:00:00 2001
From: Thomas Balthazar <tbalthazar@users.noreply.github.com>
Date: Tue, 5 Jul 2016 21:37:21 +0200
Subject: PLT-1316/PLT-3280 Change client-side max file size limit (#3354)

* Change client-side max file size limit

It now relies on the value set in config.json.
Re-enable and tweak the max file size setting in system console.

* Update file upload error message
---
 .../components/admin_console/storage_settings.jsx  | 41 +++++++++++-----------
 1 file changed, 20 insertions(+), 21 deletions(-)

(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 e4efd433c..a3d4122b5 100644
--- a/webapp/components/admin_console/storage_settings.jsx
+++ b/webapp/components/admin_console/storage_settings.jsx
@@ -22,8 +22,8 @@ export default class StorageSettings extends AdminSettings {
 
         this.renderSettings = this.renderSettings.bind(this);
 
-        //maxFileSize: props.config.FileSettings.MaxFileSize,
         this.state = Object.assign(this.state, {
+            maxFileSize: props.config.FileSettings.MaxFileSize / 1024 / 1024,
             driverName: props.config.FileSettings.DriverName,
             directory: props.config.FileSettings.Directory,
             amazonS3AccessKeyId: props.config.FileSettings.AmazonS3AccessKeyId,
@@ -34,7 +34,7 @@ export default class StorageSettings extends AdminSettings {
     }
 
     getConfigFromState(config) {
-        //config.FileSettings.MaxFileSize = this.parseInt(this.state.maxFileSize);
+        config.FileSettings.MaxFileSize = this.parseInt(this.state.maxFileSize) * 1024 * 1024;
         config.FileSettings.DriverName = this.state.driverName;
         config.FileSettings.Directory = this.state.directory;
         config.FileSettings.AmazonS3AccessKeyId = this.state.amazonS3AccessKeyId;
@@ -57,25 +57,6 @@ export default class StorageSettings extends AdminSettings {
     }
 
     renderSettings() {
-        /*<TextSetting
-            id='maxFileSize'
-            label={
-                <FormattedMessage
-                    id='admin.image.maxFileSizeTitle'
-                    defaultMessage='Max File Size:'
-                />
-            }
-            placeholder={Utils.localizeMessage('admin.image.maxFileSizeExample', 'Ex "52428800"')}
-            helpText={
-                <FormattedMessage
-                    id='admin.image.maxFileSizeDescription'
-                    defaultMessage='Max File Size in bytes. If blank, will be set to 52428800 (50MB).'
-                />
-            }
-            value={this.state.maxFileSize}
-            onChange={this.handleChange}
-        />*/
-
         return (
             <SettingsGroup>
                 <DropdownSetting
@@ -196,6 +177,24 @@ export default class StorageSettings extends AdminSettings {
                     onChange={this.handleChange}
                     disabled={this.state.driverName !== DRIVER_S3}
                 />
+                <TextSetting
+                    id='maxFileSize'
+                    label={
+                        <FormattedMessage
+                            id='admin.image.maxFileSizeTitle'
+                            defaultMessage='Maximum File Size:'
+                        />
+                    }
+                    placeholder={Utils.localizeMessage('admin.image.maxFileSizeExample', '50')}
+                    helpText={
+                        <FormattedMessage
+                            id='admin.image.maxFileSizeDescription'
+                            defaultMessage='Maximum file size for message attachments in megabytes. Caution: Verify server memory can support your setting choice. Large file sizes increase the risk of server crashes and failed uploads due to network interruptions.'
+                        />
+                    }
+                    value={this.state.maxFileSize}
+                    onChange={this.handleChange}
+                />
             </SettingsGroup>
         );
     }
-- 
cgit v1.2.3-1-g7c22

