From 0529a494ae6b541f917522a20de92e3d36615f65 Mon Sep 17 00:00:00 2001
From: =Corey Hulen <corey@hulen.com>
Date: Mon, 21 Sep 2015 17:34:13 -0700
Subject: Adding image properties

---
 .../components/admin_console/image_settings.jsx    | 417 +++++++++++++++++++++
 1 file changed, 417 insertions(+)
 create mode 100644 web/react/components/admin_console/image_settings.jsx

(limited to 'web/react/components/admin_console/image_settings.jsx')

diff --git a/web/react/components/admin_console/image_settings.jsx b/web/react/components/admin_console/image_settings.jsx
new file mode 100644
index 000000000..9a7de266d
--- /dev/null
+++ b/web/react/components/admin_console/image_settings.jsx
@@ -0,0 +1,417 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+var Client = require('../../utils/client.jsx');
+var AsyncClient = require('../../utils/async_client.jsx');
+
+export default class ImageSettings extends React.Component {
+    constructor(props) {
+        super(props);
+
+        this.handleChange = this.handleChange.bind(this);
+        this.handleSubmit = this.handleSubmit.bind(this);
+
+        this.state = {
+            saveNeeded: false,
+            serverError: null,
+            DriverName: this.props.config.ImageSettings.DriverName
+        };
+    }
+
+    handleChange(action) {
+        var s = {saveNeeded: true, serverError: this.state.serverError};
+
+        if (action === 'DriverName') {
+            s.DriverName = React.findDOMNode(this.refs.DriverName).value;
+        }
+
+        this.setState(s);
+    }
+
+    handleSubmit(e) {
+        e.preventDefault();
+        $('#save-button').button('loading');
+
+        var config = this.props.config;
+        config.ImageSettings.DriverName = React.findDOMNode(this.refs.DriverName).value;
+        config.ImageSettings.Directory = React.findDOMNode(this.refs.Directory).value;
+        config.ImageSettings.AmazonS3AccessKeyId = React.findDOMNode(this.refs.AmazonS3AccessKeyId).value;
+        config.ImageSettings.AmazonS3SecretAccessKey = React.findDOMNode(this.refs.AmazonS3SecretAccessKey).value;
+        config.ImageSettings.AmazonS3Bucket = React.findDOMNode(this.refs.AmazonS3Bucket).value;
+        config.ImageSettings.AmazonS3Region = React.findDOMNode(this.refs.AmazonS3Region).value;
+
+        var thumbnailWidth = 120;
+        if (!isNaN(parseInt(React.findDOMNode(this.refs.ThumbnailWidth).value, 10))) {
+            thumbnailWidth = parseInt(React.findDOMNode(this.refs.ThumbnailWidth).value, 10);
+        }
+        config.ImageSettings.ThumbnailWidth = thumbnailWidth;
+        React.findDOMNode(this.refs.ThumbnailWidth).value = thumbnailWidth;
+
+        var thumbnailHeight = 100;
+        if (!isNaN(parseInt(React.findDOMNode(this.refs.ThumbnailHeight).value, 10))) {
+            thumbnailHeight = parseInt(React.findDOMNode(this.refs.ThumbnailHeight).value, 10);
+        }
+        config.ImageSettings.ThumbnailHeight = thumbnailHeight;
+        React.findDOMNode(this.refs.ThumbnailHeight).value = thumbnailHeight;
+
+        var previewWidth = 1024;
+        if (!isNaN(parseInt(React.findDOMNode(this.refs.PreviewWidth).value, 10))) {
+            previewWidth = parseInt(React.findDOMNode(this.refs.PreviewWidth).value, 10);
+        }
+        config.ImageSettings.PreviewWidth = previewWidth;
+        React.findDOMNode(this.refs.PreviewWidth).value = previewWidth;
+
+        var previewHeight = 0;
+        if (!isNaN(parseInt(React.findDOMNode(this.refs.PreviewHeight).value, 10))) {
+            previewHeight = parseInt(React.findDOMNode(this.refs.PreviewHeight).value, 10);
+        }
+        config.ImageSettings.PreviewHeight = previewHeight;
+        React.findDOMNode(this.refs.PreviewHeight).value = previewHeight;
+
+        var profileWidth = 128;
+        if (!isNaN(parseInt(React.findDOMNode(this.refs.ProfileWidth).value, 10))) {
+            profileWidth = parseInt(React.findDOMNode(this.refs.ProfileWidth).value, 10);
+        }
+        config.ImageSettings.ProfileWidth = profileWidth;
+        React.findDOMNode(this.refs.ProfileWidth).value = profileWidth;
+
+        var profileHeight = 128;
+        if (!isNaN(parseInt(React.findDOMNode(this.refs.ProfileHeight).value, 10))) {
+            profileHeight = parseInt(React.findDOMNode(this.refs.ProfileHeight).value, 10);
+        }
+        config.ImageSettings.ProfileHeight = profileHeight;
+        React.findDOMNode(this.refs.ProfileHeight).value = profileHeight;
+
+        Client.saveConfig(
+            config,
+            () => {
+                AsyncClient.getConfig();
+                this.setState({
+                    serverError: null,
+                    saveNeeded: false
+                });
+                $('#save-button').button('reset');
+            },
+            (err) => {
+                this.setState({
+                    serverError: err.message,
+                    saveNeeded: true
+                });
+                $('#save-button').button('reset');
+            }
+        );
+    }
+
+    render() {
+        var serverError = '';
+        if (this.state.serverError) {
+            serverError = <div className='form-group has-error'><label className='control-label'>{this.state.serverError}</label></div>;
+        }
+
+        var saveClass = 'btn';
+        if (this.state.saveNeeded) {
+            saveClass = 'btn btn-primary';
+        }
+
+        var enableFile = false;
+        var enableS3 = false;
+
+        if (this.state.DriverName === 'local') {
+            enableFile = true;
+        }
+
+        if (this.state.DriverName === 'amazons3') {
+            enableS3 = true;
+        }
+
+        return (
+            <div className='wrapper--fixed'>
+                <h3>{'Image Settings'}</h3>
+                <form
+                    className='form-horizontal'
+                    role='form'
+                >
+
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='DriverName'
+                        >
+                            {'Store Files In:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <select
+                                className='form-control'
+                                id='DriverName'
+                                ref='DriverName'
+                                defaultValue={this.props.config.ImageSettings.DriverName}
+                                onChange={this.handleChange.bind(this, 'DriverName')}
+                            >
+                                <option value=''>{'Disable File Storage'}</option>
+                                <option value='local'>{'Local File System'}</option>
+                                <option value='amazons3'>{'Amazon S3'}</option>
+                            </select>
+                        </div>
+                    </div>
+
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='Directory'
+                        >
+                            {'Local Directory Location:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <input
+                                type='text'
+                                className='form-control'
+                                id='Directory'
+                                ref='Directory'
+                                placeholder='Ex "./data/"'
+                                defaultValue={this.props.config.ImageSettings.Directory}
+                                onChange={this.handleChange}
+                                disabled={!enableFile}
+                            />
+                            <p className='help-text'>{'Directory to which image files are written. If blank, will be set to ./data/.'}</p>
+                        </div>
+                    </div>
+
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='AmazonS3AccessKeyId'
+                        >
+                            {'Amazon S3 Access Key Id:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <input
+                                type='text'
+                                className='form-control'
+                                id='AmazonS3AccessKeyId'
+                                ref='AmazonS3AccessKeyId'
+                                placeholder='Ex "AKIADTOVBGERKLCBV"'
+                                defaultValue={this.props.config.ImageSettings.AmazonS3AccessKeyId}
+                                onChange={this.handleChange}
+                                disabled={!enableS3}
+                            />
+                            <p className='help-text'>{'Obtain this credential from your Amazon EC2 administrator.'}</p>
+                        </div>
+                    </div>
+
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='AmazonS3SecretAccessKey'
+                        >
+                            {'Amazon S3 Secret Access Key:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <input
+                                type='text'
+                                className='form-control'
+                                id='AmazonS3SecretAccessKey'
+                                ref='AmazonS3SecretAccessKey'
+                                placeholder='Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"'
+                                defaultValue={this.props.config.ImageSettings.AmazonS3SecretAccessKey}
+                                onChange={this.handleChange}
+                                disabled={!enableS3}
+                            />
+                            <p className='help-text'>{'Obtain this credential from your Amazon EC2 administrator.'}</p>
+                        </div>
+                    </div>
+
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='AmazonS3Bucket'
+                        >
+                            {'Amazon S3 Bucket:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <input
+                                type='text'
+                                className='form-control'
+                                id='AmazonS3Bucket'
+                                ref='AmazonS3Bucket'
+                                placeholder='Ex "mattermost-media"'
+                                defaultValue={this.props.config.ImageSettings.AmazonS3Bucket}
+                                onChange={this.handleChange}
+                                disabled={!enableS3}
+                            />
+                            <p className='help-text'>{'Name you selected for your S3 bucket in AWS.'}</p>
+                        </div>
+                    </div>
+
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='AmazonS3Region'
+                        >
+                            {'Amazon S3 Region:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <input
+                                type='text'
+                                className='form-control'
+                                id='AmazonS3Region'
+                                ref='AmazonS3Region'
+                                placeholder='Ex "us-east-1"'
+                                defaultValue={this.props.config.ImageSettings.AmazonS3Region}
+                                onChange={this.handleChange}
+                                disabled={!enableS3}
+                            />
+                            <p className='help-text'>{'AWS region you selected for creating your S3 bucket.'}</p>
+                        </div>
+                    </div>
+
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='ThumbnailWidth'
+                        >
+                            {'Thumbnail Width:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <input
+                                type='text'
+                                className='form-control'
+                                id='ThumbnailWidth'
+                                ref='ThumbnailWidth'
+                                placeholder='Ex "120"'
+                                defaultValue={this.props.config.ImageSettings.ThumbnailWidth}
+                                onChange={this.handleChange}
+                            />
+                            <p className='help-text'>{'Width of thumbnails generated from uploaded images. Updating this value changes how thumbnail images render in future, but does not change images created in the past.'}</p>
+                        </div>
+                    </div>
+
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='ThumbnailHeight'
+                        >
+                            {'Thumbnail Height:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <input
+                                type='text'
+                                className='form-control'
+                                id='ThumbnailHeight'
+                                ref='ThumbnailHeight'
+                                placeholder='Ex "100"'
+                                defaultValue={this.props.config.ImageSettings.ThumbnailHeight}
+                                onChange={this.handleChange}
+                            />
+                            <p className='help-text'>{'Height of thumbnails generated from uploaded images. Updating this value changes how thumbnail images render in future, but does not change images created in the past.'}</p>
+                        </div>
+                    </div>
+
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='PreviewWidth'
+                        >
+                            {'Preview Width:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <input
+                                type='text'
+                                className='form-control'
+                                id='PreviewWidth'
+                                ref='PreviewWidth'
+                                placeholder='Ex "1024"'
+                                defaultValue={this.props.config.ImageSettings.PreviewWidth}
+                                onChange={this.handleChange}
+                            />
+                            <p className='help-text'>{'Maximum width of preview image. Updating this value changes how preview images render in future, but does not change images created in the past.'}</p>
+                        </div>
+                    </div>
+
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='PreviewHeight'
+                        >
+                            {'Preview Height:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <input
+                                type='text'
+                                className='form-control'
+                                id='PreviewHeight'
+                                ref='PreviewHeight'
+                                placeholder='Ex "0"'
+                                defaultValue={this.props.config.ImageSettings.PreviewHeight}
+                                onChange={this.handleChange}
+                            />
+                            <p className='help-text'>{'Maximum height of preview image ("0": Sets to auto-size). Updating this value changes how preview images render in future, but does not change images created in the past.'}</p>
+                        </div>
+                    </div>
+
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='ProfileWidth'
+                        >
+                            {'Profile Width:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <input
+                                type='text'
+                                className='form-control'
+                                id='ProfileWidth'
+                                ref='ProfileWidth'
+                                placeholder='Ex "1024"'
+                                defaultValue={this.props.config.ImageSettings.ProfileWidth}
+                                onChange={this.handleChange}
+                            />
+                            <p className='help-text'>{'Width of profile picture.'}</p>
+                        </div>
+                    </div>
+
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='ProfileHeight'
+                        >
+                            {'Profile Height:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <input
+                                type='text'
+                                className='form-control'
+                                id='ProfileHeight'
+                                ref='ProfileHeight'
+                                placeholder='Ex "0"'
+                                defaultValue={this.props.config.ImageSettings.ProfileHeight}
+                                onChange={this.handleChange}
+                            />
+                            <p className='help-text'>{'Height of profile picture.'}</p>
+                        </div>
+                    </div>
+
+                    <div className='form-group'>
+                        <div className='col-sm-12'>
+                            {serverError}
+                            <button
+                                disabled={!this.state.saveNeeded}
+                                type='submit'
+                                className={saveClass}
+                                onClick={this.handleSubmit}
+                                id='save-button'
+                                data-loading-text={'<span class=\'glyphicon glyphicon-refresh glyphicon-refresh-animate\'></span> Saving Config...'}
+                            >
+                                {'Save'}
+                            </button>
+                        </div>
+                    </div>
+
+                </form>
+            </div>
+        );
+    }
+}
+
+ImageSettings.propTypes = {
+    config: React.PropTypes.object
+};
-- 
cgit v1.2.3-1-g7c22


From 08a3acbb44b043b9bb56f9b96e91432352d06d1a Mon Sep 17 00:00:00 2001
From: =Corey Hulen <corey@hulen.com>
Date: Tue, 22 Sep 2015 01:15:41 -0700
Subject: Adding team settings to admin console

---
 .../components/admin_console/image_settings.jsx    | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)

(limited to 'web/react/components/admin_console/image_settings.jsx')

diff --git a/web/react/components/admin_console/image_settings.jsx b/web/react/components/admin_console/image_settings.jsx
index 9a7de266d..c0cbb5aa6 100644
--- a/web/react/components/admin_console/image_settings.jsx
+++ b/web/react/components/admin_console/image_settings.jsx
@@ -39,6 +39,7 @@ export default class ImageSettings extends React.Component {
         config.ImageSettings.AmazonS3SecretAccessKey = React.findDOMNode(this.refs.AmazonS3SecretAccessKey).value;
         config.ImageSettings.AmazonS3Bucket = React.findDOMNode(this.refs.AmazonS3Bucket).value;
         config.ImageSettings.AmazonS3Region = React.findDOMNode(this.refs.AmazonS3Region).value;
+        config.ImageSettings.EnablePublicLink = React.findDOMNode(this.refs.EnablePublicLink).checked;
 
         var thumbnailWidth = 120;
         if (!isNaN(parseInt(React.findDOMNode(this.refs.ThumbnailWidth).value, 10))) {
@@ -390,6 +391,39 @@ export default class ImageSettings extends React.Component {
                         </div>
                     </div>
 
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='EnablePublicLink'
+                        >
+                            {'Share Public File Link: '}
+                        </label>
+                        <div className='col-sm-8'>
+                            <label className='radio-inline'>
+                                <input
+                                    type='radio'
+                                    name='EnablePublicLink'
+                                    value='true'
+                                    ref='EnablePublicLink'
+                                    defaultChecked={this.props.config.ImageSettings.EnablePublicLink}
+                                    onChange={this.handleChange}
+                                />
+                                    {'true'}
+                            </label>
+                            <label className='radio-inline'>
+                                <input
+                                    type='radio'
+                                    name='EnablePublicLink'
+                                    value='false'
+                                    defaultChecked={!this.props.config.ImageSettings.EnablePublicLink}
+                                    onChange={this.handleChange}
+                                />
+                                    {'false'}
+                            </label>
+                            <p className='help-text'>{'Allow users to share public links to files and images.'}</p>
+                        </div>
+                    </div>
+
                     <div className='form-group'>
                         <div className='col-sm-12'>
                             {serverError}
-- 
cgit v1.2.3-1-g7c22


From 88e5a71e8c93b495cedaa07931a4f8052d9f12ed Mon Sep 17 00:00:00 2001
From: =Corey Hulen <corey@hulen.com>
Date: Tue, 22 Sep 2015 12:12:50 -0700
Subject: Adding service settings to admin console

---
 .../components/admin_console/image_settings.jsx    | 45 ++++++++++++++++++++++
 1 file changed, 45 insertions(+)

(limited to 'web/react/components/admin_console/image_settings.jsx')

diff --git a/web/react/components/admin_console/image_settings.jsx b/web/react/components/admin_console/image_settings.jsx
index c0cbb5aa6..80da0a47f 100644
--- a/web/react/components/admin_console/image_settings.jsx
+++ b/web/react/components/admin_console/image_settings.jsx
@@ -3,6 +3,7 @@
 
 var Client = require('../../utils/client.jsx');
 var AsyncClient = require('../../utils/async_client.jsx');
+var crypto = require('crypto');
 
 export default class ImageSettings extends React.Component {
     constructor(props) {
@@ -10,6 +11,7 @@ export default class ImageSettings extends React.Component {
 
         this.handleChange = this.handleChange.bind(this);
         this.handleSubmit = this.handleSubmit.bind(this);
+        this.handleGenerate = this.handleGenerate.bind(this);
 
         this.state = {
             saveNeeded: false,
@@ -28,6 +30,13 @@ export default class ImageSettings extends React.Component {
         this.setState(s);
     }
 
+    handleGenerate(e) {
+        e.preventDefault();
+        React.findDOMNode(this.refs.PublicLinkSalt).value = crypto.randomBytes(256).toString('base64').substring(0, 31);
+        var s = {saveNeeded: true, serverError: this.state.serverError};
+        this.setState(s);
+    }
+
     handleSubmit(e) {
         e.preventDefault();
         $('#save-button').button('loading');
@@ -41,6 +50,13 @@ export default class ImageSettings extends React.Component {
         config.ImageSettings.AmazonS3Region = React.findDOMNode(this.refs.AmazonS3Region).value;
         config.ImageSettings.EnablePublicLink = React.findDOMNode(this.refs.EnablePublicLink).checked;
 
+        config.ImageSettings.PublicLinkSalt = React.findDOMNode(this.refs.PublicLinkSalt).value.trim();
+
+        if (config.ImageSettings.PublicLinkSalt === '') {
+            config.ImageSettings.PublicLinkSalt = crypto.randomBytes(256).toString('base64').substring(0, 31);
+            React.findDOMNode(this.refs.PublicLinkSalt).value = config.ImageSettings.PublicLinkSalt;
+        }
+
         var thumbnailWidth = 120;
         if (!isNaN(parseInt(React.findDOMNode(this.refs.ThumbnailWidth).value, 10))) {
             thumbnailWidth = parseInt(React.findDOMNode(this.refs.ThumbnailWidth).value, 10);
@@ -424,6 +440,35 @@ export default class ImageSettings extends React.Component {
                         </div>
                     </div>
 
+                    <div className='form-group'>
+                        <label
+                            className='control-label col-sm-4'
+                            htmlFor='PublicLinkSalt'
+                        >
+                            {'Public Link Salt:'}
+                        </label>
+                        <div className='col-sm-8'>
+                            <input
+                                type='text'
+                                className='form-control'
+                                id='PublicLinkSalt'
+                                ref='PublicLinkSalt'
+                                placeholder='Ex "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6"'
+                                defaultValue={this.props.config.ImageSettings.PublicLinkSalt}
+                                onChange={this.handleChange}
+                            />
+                            <p className='help-text'>{'32-character salt added to signing of public image links.'}</p>
+                            <div className='help-text'>
+                                <button
+                                    className='help-link'
+                                    onClick={this.handleGenerate}
+                                >
+                                    {'Re-Generate'}
+                                </button>
+                            </div>
+                        </div>
+                    </div>
+
                     <div className='form-group'>
                         <div className='col-sm-12'>
                             {serverError}
-- 
cgit v1.2.3-1-g7c22


From e22e7b8b7b66f342c2df693bbfc06a85980d253e Mon Sep 17 00:00:00 2001
From: =Corey Hulen <corey@hulen.com>
Date: Tue, 22 Sep 2015 12:31:01 -0700
Subject: Fixing bug in generating key length

---
 web/react/components/admin_console/image_settings.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'web/react/components/admin_console/image_settings.jsx')

diff --git a/web/react/components/admin_console/image_settings.jsx b/web/react/components/admin_console/image_settings.jsx
index 80da0a47f..f84f1c735 100644
--- a/web/react/components/admin_console/image_settings.jsx
+++ b/web/react/components/admin_console/image_settings.jsx
@@ -32,7 +32,7 @@ export default class ImageSettings extends React.Component {
 
     handleGenerate(e) {
         e.preventDefault();
-        React.findDOMNode(this.refs.PublicLinkSalt).value = crypto.randomBytes(256).toString('base64').substring(0, 31);
+        React.findDOMNode(this.refs.PublicLinkSalt).value = crypto.randomBytes(256).toString('base64').substring(0, 32);
         var s = {saveNeeded: true, serverError: this.state.serverError};
         this.setState(s);
     }
@@ -53,7 +53,7 @@ export default class ImageSettings extends React.Component {
         config.ImageSettings.PublicLinkSalt = React.findDOMNode(this.refs.PublicLinkSalt).value.trim();
 
         if (config.ImageSettings.PublicLinkSalt === '') {
-            config.ImageSettings.PublicLinkSalt = crypto.randomBytes(256).toString('base64').substring(0, 31);
+            config.ImageSettings.PublicLinkSalt = crypto.randomBytes(256).toString('base64').substring(0, 32);
             React.findDOMNode(this.refs.PublicLinkSalt).value = config.ImageSettings.PublicLinkSalt;
         }
 
-- 
cgit v1.2.3-1-g7c22


From ccf2e6e4e74fc249a094c2c27de675644f1065cb Mon Sep 17 00:00:00 2001
From: =Corey Hulen <corey@hulen.com>
Date: Wed, 23 Sep 2015 13:47:10 -0700
Subject: Changing image settings to file settings

---
 .../components/admin_console/image_settings.jsx    | 76 +++++++++++-----------
 1 file changed, 38 insertions(+), 38 deletions(-)

(limited to 'web/react/components/admin_console/image_settings.jsx')

diff --git a/web/react/components/admin_console/image_settings.jsx b/web/react/components/admin_console/image_settings.jsx
index f84f1c735..25d5ad857 100644
--- a/web/react/components/admin_console/image_settings.jsx
+++ b/web/react/components/admin_console/image_settings.jsx
@@ -5,7 +5,7 @@ var Client = require('../../utils/client.jsx');
 var AsyncClient = require('../../utils/async_client.jsx');
 var crypto = require('crypto');
 
-export default class ImageSettings extends React.Component {
+export default class FileSettings extends React.Component {
     constructor(props) {
         super(props);
 
@@ -16,7 +16,7 @@ export default class ImageSettings extends React.Component {
         this.state = {
             saveNeeded: false,
             serverError: null,
-            DriverName: this.props.config.ImageSettings.DriverName
+            DriverName: this.props.config.FileSettings.DriverName
         };
     }
 
@@ -42,61 +42,61 @@ export default class ImageSettings extends React.Component {
         $('#save-button').button('loading');
 
         var config = this.props.config;
-        config.ImageSettings.DriverName = React.findDOMNode(this.refs.DriverName).value;
-        config.ImageSettings.Directory = React.findDOMNode(this.refs.Directory).value;
-        config.ImageSettings.AmazonS3AccessKeyId = React.findDOMNode(this.refs.AmazonS3AccessKeyId).value;
-        config.ImageSettings.AmazonS3SecretAccessKey = React.findDOMNode(this.refs.AmazonS3SecretAccessKey).value;
-        config.ImageSettings.AmazonS3Bucket = React.findDOMNode(this.refs.AmazonS3Bucket).value;
-        config.ImageSettings.AmazonS3Region = React.findDOMNode(this.refs.AmazonS3Region).value;
-        config.ImageSettings.EnablePublicLink = React.findDOMNode(this.refs.EnablePublicLink).checked;
-
-        config.ImageSettings.PublicLinkSalt = React.findDOMNode(this.refs.PublicLinkSalt).value.trim();
-
-        if (config.ImageSettings.PublicLinkSalt === '') {
-            config.ImageSettings.PublicLinkSalt = crypto.randomBytes(256).toString('base64').substring(0, 32);
-            React.findDOMNode(this.refs.PublicLinkSalt).value = config.ImageSettings.PublicLinkSalt;
+        config.FileSettings.DriverName = React.findDOMNode(this.refs.DriverName).value;
+        config.FileSettings.Directory = React.findDOMNode(this.refs.Directory).value;
+        config.FileSettings.AmazonS3AccessKeyId = React.findDOMNode(this.refs.AmazonS3AccessKeyId).value;
+        config.FileSettings.AmazonS3SecretAccessKey = React.findDOMNode(this.refs.AmazonS3SecretAccessKey).value;
+        config.FileSettings.AmazonS3Bucket = React.findDOMNode(this.refs.AmazonS3Bucket).value;
+        config.FileSettings.AmazonS3Region = React.findDOMNode(this.refs.AmazonS3Region).value;
+        config.FileSettings.EnablePublicLink = React.findDOMNode(this.refs.EnablePublicLink).checked;
+
+        config.FileSettings.PublicLinkSalt = React.findDOMNode(this.refs.PublicLinkSalt).value.trim();
+
+        if (config.FileSettings.PublicLinkSalt === '') {
+            config.FileSettings.PublicLinkSalt = crypto.randomBytes(256).toString('base64').substring(0, 32);
+            React.findDOMNode(this.refs.PublicLinkSalt).value = config.FileSettings.PublicLinkSalt;
         }
 
         var thumbnailWidth = 120;
         if (!isNaN(parseInt(React.findDOMNode(this.refs.ThumbnailWidth).value, 10))) {
             thumbnailWidth = parseInt(React.findDOMNode(this.refs.ThumbnailWidth).value, 10);
         }
-        config.ImageSettings.ThumbnailWidth = thumbnailWidth;
+        config.FileSettings.ThumbnailWidth = thumbnailWidth;
         React.findDOMNode(this.refs.ThumbnailWidth).value = thumbnailWidth;
 
         var thumbnailHeight = 100;
         if (!isNaN(parseInt(React.findDOMNode(this.refs.ThumbnailHeight).value, 10))) {
             thumbnailHeight = parseInt(React.findDOMNode(this.refs.ThumbnailHeight).value, 10);
         }
-        config.ImageSettings.ThumbnailHeight = thumbnailHeight;
+        config.FileSettings.ThumbnailHeight = thumbnailHeight;
         React.findDOMNode(this.refs.ThumbnailHeight).value = thumbnailHeight;
 
         var previewWidth = 1024;
         if (!isNaN(parseInt(React.findDOMNode(this.refs.PreviewWidth).value, 10))) {
             previewWidth = parseInt(React.findDOMNode(this.refs.PreviewWidth).value, 10);
         }
-        config.ImageSettings.PreviewWidth = previewWidth;
+        config.FileSettings.PreviewWidth = previewWidth;
         React.findDOMNode(this.refs.PreviewWidth).value = previewWidth;
 
         var previewHeight = 0;
         if (!isNaN(parseInt(React.findDOMNode(this.refs.PreviewHeight).value, 10))) {
             previewHeight = parseInt(React.findDOMNode(this.refs.PreviewHeight).value, 10);
         }
-        config.ImageSettings.PreviewHeight = previewHeight;
+        config.FileSettings.PreviewHeight = previewHeight;
         React.findDOMNode(this.refs.PreviewHeight).value = previewHeight;
 
         var profileWidth = 128;
         if (!isNaN(parseInt(React.findDOMNode(this.refs.ProfileWidth).value, 10))) {
             profileWidth = parseInt(React.findDOMNode(this.refs.ProfileWidth).value, 10);
         }
-        config.ImageSettings.ProfileWidth = profileWidth;
+        config.FileSettings.ProfileWidth = profileWidth;
         React.findDOMNode(this.refs.ProfileWidth).value = profileWidth;
 
         var profileHeight = 128;
         if (!isNaN(parseInt(React.findDOMNode(this.refs.ProfileHeight).value, 10))) {
             profileHeight = parseInt(React.findDOMNode(this.refs.ProfileHeight).value, 10);
         }
-        config.ImageSettings.ProfileHeight = profileHeight;
+        config.FileSettings.ProfileHeight = profileHeight;
         React.findDOMNode(this.refs.ProfileHeight).value = profileHeight;
 
         Client.saveConfig(
@@ -143,7 +143,7 @@ export default class ImageSettings extends React.Component {
 
         return (
             <div className='wrapper--fixed'>
-                <h3>{'Image Settings'}</h3>
+                <h3>{'File Settings'}</h3>
                 <form
                     className='form-horizontal'
                     role='form'
@@ -161,7 +161,7 @@ export default class ImageSettings extends React.Component {
                                 className='form-control'
                                 id='DriverName'
                                 ref='DriverName'
-                                defaultValue={this.props.config.ImageSettings.DriverName}
+                                defaultValue={this.props.config.FileSettings.DriverName}
                                 onChange={this.handleChange.bind(this, 'DriverName')}
                             >
                                 <option value=''>{'Disable File Storage'}</option>
@@ -185,7 +185,7 @@ export default class ImageSettings extends React.Component {
                                 id='Directory'
                                 ref='Directory'
                                 placeholder='Ex "./data/"'
-                                defaultValue={this.props.config.ImageSettings.Directory}
+                                defaultValue={this.props.config.FileSettings.Directory}
                                 onChange={this.handleChange}
                                 disabled={!enableFile}
                             />
@@ -207,7 +207,7 @@ export default class ImageSettings extends React.Component {
                                 id='AmazonS3AccessKeyId'
                                 ref='AmazonS3AccessKeyId'
                                 placeholder='Ex "AKIADTOVBGERKLCBV"'
-                                defaultValue={this.props.config.ImageSettings.AmazonS3AccessKeyId}
+                                defaultValue={this.props.config.FileSettings.AmazonS3AccessKeyId}
                                 onChange={this.handleChange}
                                 disabled={!enableS3}
                             />
@@ -229,7 +229,7 @@ export default class ImageSettings extends React.Component {
                                 id='AmazonS3SecretAccessKey'
                                 ref='AmazonS3SecretAccessKey'
                                 placeholder='Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"'
-                                defaultValue={this.props.config.ImageSettings.AmazonS3SecretAccessKey}
+                                defaultValue={this.props.config.FileSettings.AmazonS3SecretAccessKey}
                                 onChange={this.handleChange}
                                 disabled={!enableS3}
                             />
@@ -251,7 +251,7 @@ export default class ImageSettings extends React.Component {
                                 id='AmazonS3Bucket'
                                 ref='AmazonS3Bucket'
                                 placeholder='Ex "mattermost-media"'
-                                defaultValue={this.props.config.ImageSettings.AmazonS3Bucket}
+                                defaultValue={this.props.config.FileSettings.AmazonS3Bucket}
                                 onChange={this.handleChange}
                                 disabled={!enableS3}
                             />
@@ -273,7 +273,7 @@ export default class ImageSettings extends React.Component {
                                 id='AmazonS3Region'
                                 ref='AmazonS3Region'
                                 placeholder='Ex "us-east-1"'
-                                defaultValue={this.props.config.ImageSettings.AmazonS3Region}
+                                defaultValue={this.props.config.FileSettings.AmazonS3Region}
                                 onChange={this.handleChange}
                                 disabled={!enableS3}
                             />
@@ -295,7 +295,7 @@ export default class ImageSettings extends React.Component {
                                 id='ThumbnailWidth'
                                 ref='ThumbnailWidth'
                                 placeholder='Ex "120"'
-                                defaultValue={this.props.config.ImageSettings.ThumbnailWidth}
+                                defaultValue={this.props.config.FileSettings.ThumbnailWidth}
                                 onChange={this.handleChange}
                             />
                             <p className='help-text'>{'Width of thumbnails generated from uploaded images. Updating this value changes how thumbnail images render in future, but does not change images created in the past.'}</p>
@@ -316,7 +316,7 @@ export default class ImageSettings extends React.Component {
                                 id='ThumbnailHeight'
                                 ref='ThumbnailHeight'
                                 placeholder='Ex "100"'
-                                defaultValue={this.props.config.ImageSettings.ThumbnailHeight}
+                                defaultValue={this.props.config.FileSettings.ThumbnailHeight}
                                 onChange={this.handleChange}
                             />
                             <p className='help-text'>{'Height of thumbnails generated from uploaded images. Updating this value changes how thumbnail images render in future, but does not change images created in the past.'}</p>
@@ -337,7 +337,7 @@ export default class ImageSettings extends React.Component {
                                 id='PreviewWidth'
                                 ref='PreviewWidth'
                                 placeholder='Ex "1024"'
-                                defaultValue={this.props.config.ImageSettings.PreviewWidth}
+                                defaultValue={this.props.config.FileSettings.PreviewWidth}
                                 onChange={this.handleChange}
                             />
                             <p className='help-text'>{'Maximum width of preview image. Updating this value changes how preview images render in future, but does not change images created in the past.'}</p>
@@ -358,7 +358,7 @@ export default class ImageSettings extends React.Component {
                                 id='PreviewHeight'
                                 ref='PreviewHeight'
                                 placeholder='Ex "0"'
-                                defaultValue={this.props.config.ImageSettings.PreviewHeight}
+                                defaultValue={this.props.config.FileSettings.PreviewHeight}
                                 onChange={this.handleChange}
                             />
                             <p className='help-text'>{'Maximum height of preview image ("0": Sets to auto-size). Updating this value changes how preview images render in future, but does not change images created in the past.'}</p>
@@ -379,7 +379,7 @@ export default class ImageSettings extends React.Component {
                                 id='ProfileWidth'
                                 ref='ProfileWidth'
                                 placeholder='Ex "1024"'
-                                defaultValue={this.props.config.ImageSettings.ProfileWidth}
+                                defaultValue={this.props.config.FileSettings.ProfileWidth}
                                 onChange={this.handleChange}
                             />
                             <p className='help-text'>{'Width of profile picture.'}</p>
@@ -400,7 +400,7 @@ export default class ImageSettings extends React.Component {
                                 id='ProfileHeight'
                                 ref='ProfileHeight'
                                 placeholder='Ex "0"'
-                                defaultValue={this.props.config.ImageSettings.ProfileHeight}
+                                defaultValue={this.props.config.FileSettings.ProfileHeight}
                                 onChange={this.handleChange}
                             />
                             <p className='help-text'>{'Height of profile picture.'}</p>
@@ -421,7 +421,7 @@ export default class ImageSettings extends React.Component {
                                     name='EnablePublicLink'
                                     value='true'
                                     ref='EnablePublicLink'
-                                    defaultChecked={this.props.config.ImageSettings.EnablePublicLink}
+                                    defaultChecked={this.props.config.FileSettings.EnablePublicLink}
                                     onChange={this.handleChange}
                                 />
                                     {'true'}
@@ -431,7 +431,7 @@ export default class ImageSettings extends React.Component {
                                     type='radio'
                                     name='EnablePublicLink'
                                     value='false'
-                                    defaultChecked={!this.props.config.ImageSettings.EnablePublicLink}
+                                    defaultChecked={!this.props.config.FileSettings.EnablePublicLink}
                                     onChange={this.handleChange}
                                 />
                                     {'false'}
@@ -454,7 +454,7 @@ export default class ImageSettings extends React.Component {
                                 id='PublicLinkSalt'
                                 ref='PublicLinkSalt'
                                 placeholder='Ex "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6"'
-                                defaultValue={this.props.config.ImageSettings.PublicLinkSalt}
+                                defaultValue={this.props.config.FileSettings.PublicLinkSalt}
                                 onChange={this.handleChange}
                             />
                             <p className='help-text'>{'32-character salt added to signing of public image links.'}</p>
@@ -491,6 +491,6 @@ export default class ImageSettings extends React.Component {
     }
 }
 
-ImageSettings.propTypes = {
+FileSettings.propTypes = {
     config: React.PropTypes.object
 };
-- 
cgit v1.2.3-1-g7c22

