From fd53e3b7868234af328cd73150318fc8e7a26b89 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 17 May 2016 07:21:39 -0400 Subject: PLT-2257 Reorganized System Console (#3003) * Reorganized system console * Fixed the names of some components * Fixed timestamp for BrandImageSetting * Fixed merge issues * Updated push notification settings to match master branch * Removed top level setting pages and moved enable Gitlab/LDAP settings onto their respective pages * Re-added restrictDirectMessage setting to system console * Re-added email connection test and fixed some margins * Fixed ESLint errors * Renamed Authentication > Onboarding to Authentication > Email in the system console * Renamed Customization > Whitelabeling to Customization > Custom Branding in System Console * Re-added EnableOpenServer to system console --- webapp/components/admin_console/image_settings.jsx | 820 ++++----------------- 1 file changed, 151 insertions(+), 669 deletions(-) (limited to 'webapp/components/admin_console/image_settings.jsx') diff --git a/webapp/components/admin_console/image_settings.jsx b/webapp/components/admin_console/image_settings.jsx index 64a7663c6..86d8795cc 100644 --- a/webapp/components/admin_console/image_settings.jsx +++ b/webapp/components/admin_console/image_settings.jsx @@ -1,692 +1,174 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import $ from 'jquery'; -import ReactDOM from 'react-dom'; -import Client from 'utils/web_client.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; -import crypto from 'crypto'; - -import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'react-intl'; +import React from 'react'; -const holders = defineMessages({ - storeLocal: { - id: 'admin.image.storeLocal', - defaultMessage: 'Local File System' - }, - storeAmazonS3: { - id: 'admin.image.storeAmazonS3', - defaultMessage: 'Amazon S3' - }, - localExample: { - id: 'admin.image.localExample', - defaultMessage: 'Ex "./data/"' - }, - amazonS3IdExample: { - id: 'admin.image.amazonS3IdExample', - defaultMessage: 'Ex "AKIADTOVBGERKLCBV"' - }, - amazonS3SecretExample: { - id: 'admin.image.amazonS3SecretExample', - defaultMessage: 'Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"' - }, - amazonS3BucketExample: { - id: 'admin.image.amazonS3BucketExample', - defaultMessage: 'Ex "mattermost-media"' - }, - amazonS3RegionExample: { - id: 'admin.image.amazonS3RegionExample', - defaultMessage: 'Ex "us-east-1"' - }, - thumbWidthExample: { - id: 'admin.image.thumbWidthExample', - defaultMessage: 'Ex "120"' - }, - thumbHeightExample: { - id: 'admin.image.thumbHeightExample', - defaultMessage: 'Ex "100"' - }, - previewWidthExample: { - id: 'admin.image.previewWidthExample', - defaultMessage: 'Ex "1024"' - }, - previewHeightExample: { - id: 'admin.image.previewHeightExample', - defaultMessage: 'Ex "0"' - }, - profileWidthExample: { - id: 'admin.image.profileWidthExample', - defaultMessage: 'Ex "1024"' - }, - profileHeightExample: { - id: 'admin.image.profileHeightExample', - defaultMessage: 'Ex "0"' - }, - publicLinkExample: { - id: 'admin.image.publicLinkExample', - defaultMessage: 'Ex "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6"' - }, - saving: { - id: 'admin.image.saving', - defaultMessage: 'Saving Config...' - } -}); +import * as Utils from 'utils/utils.jsx'; -import React from 'react'; +import AdminSettings from './admin_settings.jsx'; +import {FormattedMessage} from 'react-intl'; +import SettingsGroup from './settings_group.jsx'; +import TextSetting from './text_setting.jsx'; -class FileSettings extends React.Component { +export default class ImageSettings extends AdminSettings { constructor(props) { super(props); - this.handleChange = this.handleChange.bind(this); - this.handleSubmit = this.handleSubmit.bind(this); - this.handleGenerate = this.handleGenerate.bind(this); - - this.state = { - saveNeeded: false, - serverError: null, - DriverName: this.props.config.FileSettings.DriverName - }; - } + this.getConfigFromState = this.getConfigFromState.bind(this); - handleChange(action) { - var s = {saveNeeded: true, serverError: this.state.serverError}; + this.renderSettings = this.renderSettings.bind(this); - if (action === 'DriverName') { - s.DriverName = ReactDOM.findDOMNode(this.refs.DriverName).value; - } - - this.setState(s); - } - - handleGenerate(e) { - e.preventDefault(); - ReactDOM.findDOMNode(this.refs.PublicLinkSalt).value = crypto.randomBytes(256).toString('base64').substring(0, 32); - var s = {saveNeeded: true, serverError: this.state.serverError}; - this.setState(s); + this.state = Object.assign(this.state, { + thumbnailWidth: props.config.FileSettings.ThumbnailWidth, + thumbnailHeight: props.config.FileSettings.ThumbnailHeight, + profileWidth: props.config.FileSettings.ProfileWidth, + profileHeight: props.config.FileSettings.ProfileHeight, + previewWidth: props.config.FileSettings.PreviewWidth, + previewHeight: props.config.FileSettings.PreviewHeight + }); } - handleSubmit(e) { - e.preventDefault(); - $('#save-button').button('loading'); - - var config = this.props.config; - config.FileSettings.DriverName = ReactDOM.findDOMNode(this.refs.DriverName).value; - config.FileSettings.Directory = ReactDOM.findDOMNode(this.refs.Directory).value; - config.FileSettings.AmazonS3AccessKeyId = ReactDOM.findDOMNode(this.refs.AmazonS3AccessKeyId).value; - config.FileSettings.AmazonS3SecretAccessKey = ReactDOM.findDOMNode(this.refs.AmazonS3SecretAccessKey).value; - config.FileSettings.AmazonS3Bucket = ReactDOM.findDOMNode(this.refs.AmazonS3Bucket).value; - config.FileSettings.AmazonS3Region = ReactDOM.findDOMNode(this.refs.AmazonS3Region).value; - config.FileSettings.EnablePublicLink = ReactDOM.findDOMNode(this.refs.EnablePublicLink).checked; - - config.FileSettings.PublicLinkSalt = ReactDOM.findDOMNode(this.refs.PublicLinkSalt).value.trim(); + getConfigFromState(config) { + config.FileSettings.ThumbnailWidth = this.parseInt(this.state.thumbnailWidth); + config.FileSettings.ThumbnailHeight = this.parseInt(this.state.thumbnailHeight); + config.FileSettings.ProfileWidth = this.parseInt(this.state.profileWidth); + config.FileSettings.ProfileHeight = this.parseInt(this.state.profileHeight); + config.FileSettings.PreviewWidth = this.parseInt(this.state.previewWidth); + config.FileSettings.PreviewHeight = this.parseInt(this.state.previewHeight); - if (config.FileSettings.PublicLinkSalt === '') { - config.FileSettings.PublicLinkSalt = crypto.randomBytes(256).toString('base64').substring(0, 32); - ReactDOM.findDOMNode(this.refs.PublicLinkSalt).value = config.FileSettings.PublicLinkSalt; - } - - var thumbnailWidth = 120; - if (!isNaN(parseInt(ReactDOM.findDOMNode(this.refs.ThumbnailWidth).value, 10))) { - thumbnailWidth = parseInt(ReactDOM.findDOMNode(this.refs.ThumbnailWidth).value, 10); - } - config.FileSettings.ThumbnailWidth = thumbnailWidth; - ReactDOM.findDOMNode(this.refs.ThumbnailWidth).value = thumbnailWidth; - - var thumbnailHeight = 100; - if (!isNaN(parseInt(ReactDOM.findDOMNode(this.refs.ThumbnailHeight).value, 10))) { - thumbnailHeight = parseInt(ReactDOM.findDOMNode(this.refs.ThumbnailHeight).value, 10); - } - config.FileSettings.ThumbnailHeight = thumbnailHeight; - ReactDOM.findDOMNode(this.refs.ThumbnailHeight).value = thumbnailHeight; - - var previewWidth = 1024; - if (!isNaN(parseInt(ReactDOM.findDOMNode(this.refs.PreviewWidth).value, 10))) { - previewWidth = parseInt(ReactDOM.findDOMNode(this.refs.PreviewWidth).value, 10); - } - config.FileSettings.PreviewWidth = previewWidth; - ReactDOM.findDOMNode(this.refs.PreviewWidth).value = previewWidth; - - var previewHeight = 0; - if (!isNaN(parseInt(ReactDOM.findDOMNode(this.refs.PreviewHeight).value, 10))) { - previewHeight = parseInt(ReactDOM.findDOMNode(this.refs.PreviewHeight).value, 10); - } - config.FileSettings.PreviewHeight = previewHeight; - ReactDOM.findDOMNode(this.refs.PreviewHeight).value = previewHeight; - - var profileWidth = 128; - if (!isNaN(parseInt(ReactDOM.findDOMNode(this.refs.ProfileWidth).value, 10))) { - profileWidth = parseInt(ReactDOM.findDOMNode(this.refs.ProfileWidth).value, 10); - } - config.FileSettings.ProfileWidth = profileWidth; - ReactDOM.findDOMNode(this.refs.ProfileWidth).value = profileWidth; - - var profileHeight = 128; - if (!isNaN(parseInt(ReactDOM.findDOMNode(this.refs.ProfileHeight).value, 10))) { - profileHeight = parseInt(ReactDOM.findDOMNode(this.refs.ProfileHeight).value, 10); - } - config.FileSettings.ProfileHeight = profileHeight; - ReactDOM.findDOMNode(this.refs.ProfileHeight).value = profileHeight; + return config; + } - 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'); - } + renderTitle() { + return ( +

+ +

); } - render() { - const {formatMessage} = this.props.intl; - var serverError = ''; - if (this.state.serverError) { - serverError =
; - } - - 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; - } - + renderSettings() { return ( -
-

+ -

-
- -
- -
- -
-
- -
- -
- -

- -

-
-
- -
- -
- -

- -

-
-
- -
- -
- -

- -

-
-
- -
- -
- -

- -

-
-
- -
- -
- -

- -

-
-
- -
- -
- -

- -

-
-
- -
- -
- -

- -

-
-
- -
- -
- -

- -

-
-
- -
- -
- -

- -

-
-
- -
- -
- -

- -

-
-
- -
- -
- -

- -

-
-
- -
- -
- - -

- -

-
-
- -
- -
- -

- -

-
- -
-
-
- -
-
- {serverError} - -
-
- -
-
+ } + > + + } + placeholder={Utils.localizeMessage('admin.image.thumbWidthExample', 'Ex "120"')} + helpText={ + + } + value={this.state.thumbnailWidth} + onChange={this.handleChange} + /> + + } + placeholder={Utils.localizeMessage('admin.image.thumbHeightExample', 'Ex "100"')} + helpText={ + + } + value={this.state.thumbnailHeight} + onChange={this.handleChange} + /> + + } + placeholder={Utils.localizeMessage('admin.image.profileWidthExample', 'Ex "1024"')} + helpText={ + + } + value={this.state.profileWidth} + onChange={this.handleChange} + /> + + } + placeholder={Utils.localizeMessage('admin.image.profileHeightExample', 'Ex "0"')} + helpText={ + + } + value={this.state.profileHeight} + onChange={this.handleChange} + /> + + } + placeholder={Utils.localizeMessage('admin.image.previewWidthExample', 'Ex "1024"')} + helpText={ + + } + value={this.state.previewWidth} + onChange={this.handleChange} + /> + + } + placeholder={Utils.localizeMessage('admin.image.previewHeightExample', 'Ex "0"')} + helpText={ + + } + value={this.state.previewHeight} + onChange={this.handleChange} + /> + ); } -} - -FileSettings.propTypes = { - intl: intlShape.isRequired, - config: React.PropTypes.object -}; - -export default injectIntl(FileSettings); +} \ No newline at end of file -- cgit v1.2.3-1-g7c22