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 --- .../components/admin_console/gitlab_settings.jsx | 514 +++++++-------------- 1 file changed, 159 insertions(+), 355 deletions(-) (limited to 'webapp/components/admin_console/gitlab_settings.jsx') diff --git a/webapp/components/admin_console/gitlab_settings.jsx b/webapp/components/admin_console/gitlab_settings.jsx index 510fd0887..bd3cd8dec 100644 --- a/webapp/components/admin_console/gitlab_settings.jsx +++ b/webapp/components/admin_console/gitlab_settings.jsx @@ -1,382 +1,186 @@ // 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 {injectIntl, intlShape, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'react-intl'; +import React from 'react'; -const holders = defineMessages({ - clientIdExample: { - id: 'admin.gitlab.clientIdExample', - defaultMessage: 'Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"' - }, - clientSecretExample: { - id: 'admin.gitlab.clientSecretExample', - defaultMessage: 'Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"' - }, - authExample: { - id: 'admin.gitlab.authExample', - defaultMessage: 'Ex ""' - }, - tokenExample: { - id: 'admin.gitlab.tokenExample', - defaultMessage: 'Ex ""' - }, - userExample: { - id: 'admin.gitlab.userExample', - defaultMessage: 'Ex ""' - }, - saving: { - id: 'admin.gitlab.saving', - defaultMessage: 'Saving Config...' - } -}); +import * as Utils from 'utils/utils.jsx'; -import React from 'react'; +import AdminSettings from './admin_settings.jsx'; +import BooleanSetting from './boolean_setting.jsx'; +import {FormattedHTMLMessage, FormattedMessage} from 'react-intl'; +import SettingsGroup from './settings_group.jsx'; +import TextSetting from './text_setting.jsx'; -class GitLabSettings extends React.Component { +export default class GitLabSettings extends AdminSettings { constructor(props) { super(props); - this.handleChange = this.handleChange.bind(this); - this.handleSubmit = this.handleSubmit.bind(this); - - this.state = { - Enable: this.props.config.GitLabSettings.Enable, - saveNeeded: false, - serverError: null - }; - } + this.getConfigFromState = this.getConfigFromState.bind(this); - handleChange(action) { - var s = {saveNeeded: true, serverError: this.state.serverError}; + this.renderSettings = this.renderSettings.bind(this); - if (action === 'EnableTrue') { - s.Enable = true; - } - - if (action === 'EnableFalse') { - s.Enable = false; - } - - this.setState(s); + this.state = Object.assign(this.state, { + enable: props.config.GitLabSettings.Enable, + id: props.config.GitLabSettings.Id, + secret: props.config.GitLabSettings.Secret, + userApiEndpoint: props.config.GitLabSettings.UserApiEndpoint, + authEndpoint: props.config.GitLabSettings.AuthEndpoint, + tokenEndpoint: props.config.GitLabSettings.TokenEndpoint + }); } - handleSubmit(e) { - e.preventDefault(); - $('#save-button').button('loading'); + getConfigFromState(config) { + config.GitLabSettings.Enable = this.state.enable; + config.GitLabSettings.Id = this.state.id; + config.GitLabSettings.Secret = this.state.secret; + config.GitLabSettings.UserApiEndpoint = this.state.userApiEndpoint; + config.GitLabSettings.AuthEndpoint = this.state.authEndpoint; + config.GitLabSettings.TokenEndpoint = this.state.tokenEndpoint; - var config = this.props.config; - config.GitLabSettings.Enable = ReactDOM.findDOMNode(this.refs.Enable).checked; - config.GitLabSettings.Secret = ReactDOM.findDOMNode(this.refs.Secret).value.trim(); - config.GitLabSettings.Id = ReactDOM.findDOMNode(this.refs.Id).value.trim(); - config.GitLabSettings.AuthEndpoint = ReactDOM.findDOMNode(this.refs.AuthEndpoint).value.trim(); - config.GitLabSettings.TokenEndpoint = ReactDOM.findDOMNode(this.refs.TokenEndpoint).value.trim(); - config.GitLabSettings.UserApiEndpoint = ReactDOM.findDOMNode(this.refs.UserApiEndpoint).value.trim(); + 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'; - } - + renderSettings() { return ( -
- -

+ -

-
-
- -
- - -

- -
-

-
- -
-
-
- -
- -
- -

- -

-
-
- -
-
+ } + value={this.state.enable} + onChange={this.handleChange} + /> + + } + placeholder={Utils.localizeMessage('admin.gitlab.clientIdExample', 'Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"')} + helpText={ + + } + value={this.state.id} + onChange={this.handleChange} + disabled={!this.state.enable} + /> + + } + placeholder={Utils.localizeMessage('admin.gitlab.clientSecretExample', 'Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"')} + helpText={ + + } + value={this.state.secret} + onChange={this.handleChange} + disabled={!this.state.enable} + /> + + } + placeholder={Utils.localizeMessage('admin.gitlab.userExample', 'Ex ""')} + helpText={ + + } + value={this.state.userApiEndpoint} + onChange={this.handleChange} + disabled={!this.state.enable} + /> + + } + placeholder={Utils.localizeMessage('admin.gitlab.authExample', 'Ex ""')} + helpText={ + + } + value={this.state.authEndpoint} + onChange={this.handleChange} + disabled={!this.state.enable} + /> + + } + placeholder={Utils.localizeMessage('admin.gitlab.tokenExample', 'Ex ""')} + helpText={ + + } + value={this.state.tokenEndpoint} + onChange={this.handleChange} + disabled={!this.state.enable} + /> + ); } -} - -//config.GitLabSettings.Scope = ReactDOM.findDOMNode(this.refs.Scope).value.trim(); -//
-// -//
-// -//

{'This field is not yet used by GitLab OAuth. Other OAuth providers may use this field to specify the scope of account data from OAuth provider that is sent to Mattermost.'}

-//
-//
- -GitLabSettings.propTypes = { - intl: intlShape.isRequired, - config: React.PropTypes.object -}; - -export default injectIntl(GitLabSettings); +} \ No newline at end of file -- cgit v1.2.3-1-g7c22