From 12896bd23eeba79884245c1c29fdc568cf21a7fa Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 14 Mar 2016 08:50:46 -0400 Subject: Converting to Webpack. Stage 1. --- .../user_settings/custom_theme_chooser.jsx | 387 ---------- .../user_settings/import_theme_modal.jsx | 215 ------ .../user_settings/manage_command_hooks.jsx | 679 ----------------- .../user_settings/manage_incoming_hooks.jsx | 223 ------ .../components/user_settings/manage_languages.jsx | 118 --- .../user_settings/manage_outgoing_hooks.jsx | 395 ---------- .../user_settings/premade_theme_chooser.jsx | 58 -- .../components/user_settings/user_settings.jsx | 158 ---- .../user_settings/user_settings_advanced.jsx | 343 --------- .../user_settings/user_settings_developer.jsx | 136 ---- .../user_settings/user_settings_display.jsx | 496 ------------ .../user_settings/user_settings_general.jsx | 815 -------------------- .../user_settings/user_settings_integrations.jsx | 208 ------ .../user_settings/user_settings_modal.jsx | 338 --------- .../user_settings/user_settings_notifications.jsx | 831 --------------------- .../user_settings/user_settings_security.jsx | 472 ------------ .../user_settings/user_settings_theme.jsx | 299 -------- 17 files changed, 6171 deletions(-) delete mode 100644 web/react/components/user_settings/custom_theme_chooser.jsx delete mode 100644 web/react/components/user_settings/import_theme_modal.jsx delete mode 100644 web/react/components/user_settings/manage_command_hooks.jsx delete mode 100644 web/react/components/user_settings/manage_incoming_hooks.jsx delete mode 100644 web/react/components/user_settings/manage_languages.jsx delete mode 100644 web/react/components/user_settings/manage_outgoing_hooks.jsx delete mode 100644 web/react/components/user_settings/premade_theme_chooser.jsx delete mode 100644 web/react/components/user_settings/user_settings.jsx delete mode 100644 web/react/components/user_settings/user_settings_advanced.jsx delete mode 100644 web/react/components/user_settings/user_settings_developer.jsx delete mode 100644 web/react/components/user_settings/user_settings_display.jsx delete mode 100644 web/react/components/user_settings/user_settings_general.jsx delete mode 100644 web/react/components/user_settings/user_settings_integrations.jsx delete mode 100644 web/react/components/user_settings/user_settings_modal.jsx delete mode 100644 web/react/components/user_settings/user_settings_notifications.jsx delete mode 100644 web/react/components/user_settings/user_settings_security.jsx delete mode 100644 web/react/components/user_settings/user_settings_theme.jsx (limited to 'web/react/components/user_settings') diff --git a/web/react/components/user_settings/custom_theme_chooser.jsx b/web/react/components/user_settings/custom_theme_chooser.jsx deleted file mode 100644 index 4ee9fd0e2..000000000 --- a/web/react/components/user_settings/custom_theme_chooser.jsx +++ /dev/null @@ -1,387 +0,0 @@ -// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import Constants from '../../utils/constants.jsx'; - -const OverlayTrigger = ReactBootstrap.OverlayTrigger; -const Popover = ReactBootstrap.Popover; - -import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'mm-intl'; - -const messages = defineMessages({ - sidebarBg: { - id: 'user.settings.custom_theme.sidebarBg', - defaultMessage: 'Sidebar BG' - }, - sidebarText: { - id: 'user.settings.custom_theme.sidebarText', - defaultMessage: 'Sidebar Text' - }, - sidebarHeaderBg: { - id: 'user.settings.custom_theme.sidebarHeaderBg', - defaultMessage: 'Sidebar Header BG' - }, - sidebarHeaderTextColor: { - id: 'user.settings.custom_theme.sidebarHeaderTextColor', - defaultMessage: 'Sidebar Header Text' - }, - sidebarUnreadText: { - id: 'user.settings.custom_theme.sidebarUnreadText', - defaultMessage: 'Sidebar Unread Text' - }, - sidebarTextHoverBg: { - id: 'user.settings.custom_theme.sidebarTextHoverBg', - defaultMessage: 'Sidebar Text Hover BG' - }, - sidebarTextActiveBorder: { - id: 'user.settings.custom_theme.sidebarTextActiveBorder', - defaultMessage: 'Sidebar Text Active Border' - }, - sidebarTextActiveColor: { - id: 'user.settings.custom_theme.sidebarTextActiveColor', - defaultMessage: 'Sidebar Text Active Color' - }, - onlineIndicator: { - id: 'user.settings.custom_theme.onlineIndicator', - defaultMessage: 'Online Indicator' - }, - awayIndicator: { - id: 'user.settings.custom_theme.awayIndicator', - defaultMessage: 'Away Indicator' - }, - mentionBj: { - id: 'user.settings.custom_theme.mentionBj', - defaultMessage: 'Mention Jewel BG' - }, - mentionColor: { - id: 'user.settings.custom_theme.mentionColor', - defaultMessage: 'Mention Jewel Text' - }, - centerChannelBg: { - id: 'user.settings.custom_theme.centerChannelBg', - defaultMessage: 'Center Channel BG' - }, - centerChannelColor: { - id: 'user.settings.custom_theme.centerChannelColor', - defaultMessage: 'Center Channel Text' - }, - newMessageSeparator: { - id: 'user.settings.custom_theme.newMessageSeparator', - defaultMessage: 'New Message Separator' - }, - linkColor: { - id: 'user.settings.custom_theme.linkColor', - defaultMessage: 'Link Color' - }, - buttonBg: { - id: 'user.settings.custom_theme.buttonBg', - defaultMessage: 'Button BG' - }, - buttonColor: { - id: 'user.settings.custom_theme.buttonColor', - defaultMessage: 'Button Text' - }, - mentionHighlightBg: { - id: 'user.settings.custom_theme.mentionHighlightBg', - defaultMessage: 'Mention Highlight BG' - }, - mentionHighlightLink: { - id: 'user.settings.custom_theme.mentionHighlightLink', - defaultMessage: 'Mention Highlight Link' - }, - codeTheme: { - id: 'user.settings.custom_theme.codeTheme', - defaultMessage: 'Code Theme' - } -}); - -class CustomThemeChooser extends React.Component { - constructor(props) { - super(props); - - this.onPickerChange = this.onPickerChange.bind(this); - this.onInputChange = this.onInputChange.bind(this); - this.pasteBoxChange = this.pasteBoxChange.bind(this); - this.toggleContent = this.toggleContent.bind(this); - - this.state = {}; - } - componentDidMount() { - $('.color-picker').colorpicker({ - format: 'hex' - }); - $('.color-picker').on('changeColor', this.onPickerChange); - } - componentDidUpdate() { - const theme = this.props.theme; - Constants.THEME_ELEMENTS.forEach((element) => { - if (theme.hasOwnProperty(element.id) && element.id !== 'codeTheme') { - $('#' + element.id).data('colorpicker').color.setColor(theme[element.id]); - $('#' + element.id).colorpicker('update'); - } - }); - } - onPickerChange(e) { - const theme = this.props.theme; - theme[e.target.id] = e.color.toHex(); - theme.type = 'custom'; - this.props.updateTheme(theme); - } - onInputChange(e) { - const theme = this.props.theme; - theme[e.target.parentNode.id] = e.target.value; - theme.type = 'custom'; - this.props.updateTheme(theme); - } - pasteBoxChange(e) { - const text = e.target.value; - - if (text.length === 0) { - return; - } - - const colors = text.split(','); - - const theme = {type: 'custom'}; - let index = 0; - Constants.THEME_ELEMENTS.forEach((element) => { - if (index < colors.length - 1) { - theme[element.id] = colors[index]; - } - index++; - }); - theme.codeTheme = colors[colors.length - 1]; - - this.props.updateTheme(theme); - } - toggleContent(e) { - e.stopPropagation(); - if ($(e.target).hasClass('theme-elements__header')) { - $(e.target).next().slideToggle(); - $(e.target).toggleClass('open'); - } else { - $(e.target).closest('.theme-elements__header').next().slideToggle(); - $(e.target).closest('.theme-elements__header').toggleClass('open'); - } - } - render() { - const {formatMessage} = this.props.intl; - const theme = this.props.theme; - - const sidebarElements = []; - const centerChannelElements = []; - const linkAndButtonElements = []; - let colors = ''; - Constants.THEME_ELEMENTS.forEach((element, index) => { - if (element.id === 'codeTheme') { - const codeThemeOptions = []; - - element.themes.forEach((codeTheme, codeThemeIndex) => { - codeThemeOptions.push( - - ); - }); - - var popoverContent = ( - - - - ); - - centerChannelElements.push( -
- -
- - - - - - -
-
- ); - } else if (element.group === 'centerChannelElements') { - centerChannelElements.push( -
- -
- - -
-
- ); - - colors += theme[element.id] + ','; - } else if (element.group === 'sidebarElements') { - sidebarElements.push( -
- -
- - -
-
- ); - - colors += theme[element.id] + ','; - } else { - linkAndButtonElements.push( -
- -
- - -
-
- ); - - colors += theme[element.id] + ','; - } - }); - - colors += theme.codeTheme; - - const pasteBox = ( -
- - -
- ); - - return ( -
-
-
- {'Sidebar Styles'} -
- - -
-
-
- {sidebarElements} -
-
-
-
- {'Center Channel Styles'} -
- - -
-
-
- {centerChannelElements} -
-
-
-
- {'Link and Button Styles'} -
- - -
-
-
- {linkAndButtonElements} -
-
-
- {pasteBox} -
-
- ); - } -} - -CustomThemeChooser.propTypes = { - intl: intlShape.isRequired, - theme: React.PropTypes.object.isRequired, - updateTheme: React.PropTypes.func.isRequired -}; - -export default injectIntl(CustomThemeChooser); diff --git a/web/react/components/user_settings/import_theme_modal.jsx b/web/react/components/user_settings/import_theme_modal.jsx deleted file mode 100644 index e9e90a936..000000000 --- a/web/react/components/user_settings/import_theme_modal.jsx +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import ModalStore from '../../stores/modal_store.jsx'; -import UserStore from '../../stores/user_store.jsx'; -import * as Utils from '../../utils/utils.jsx'; -import * as Client from '../../utils/client.jsx'; -const Modal = ReactBootstrap.Modal; - -import AppDispatcher from '../../dispatcher/app_dispatcher.jsx'; -import Constants from '../../utils/constants.jsx'; - -import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'mm-intl'; - -const holders = defineMessages({ - submitError: { - id: 'user.settings.import_theme.submitError', - defaultMessage: 'Invalid format, please try copying and pasting in again.' - } -}); - -const ActionTypes = Constants.ActionTypes; - -class ImportThemeModal extends React.Component { - constructor(props) { - super(props); - - this.updateShow = this.updateShow.bind(this); - this.handleSubmit = this.handleSubmit.bind(this); - this.handleChange = this.handleChange.bind(this); - - this.state = { - inputError: '', - show: false - }; - } - componentDidMount() { - ModalStore.addModalListener(ActionTypes.TOGGLE_IMPORT_THEME_MODAL, this.updateShow); - } - componentWillUnmount() { - ModalStore.removeModalListener(ActionTypes.TOGGLE_IMPORT_THEME_MODAL, this.updateShow); - } - updateShow(show) { - this.setState({show}); - } - handleSubmit(e) { - e.preventDefault(); - - const text = ReactDOM.findDOMNode(this.refs.input).value; - - if (!this.isInputValid(text)) { - this.setState({inputError: this.props.intl.formatMessage(holders.submitError)}); - return; - } - - const colors = text.split(','); - const theme = {type: 'custom'}; - - theme.sidebarBg = colors[0]; - theme.sidebarText = colors[5]; - theme.sidebarUnreadText = colors[5]; - theme.sidebarTextHoverBg = colors[4]; - theme.sidebarTextActiveBorder = colors[2]; - theme.sidebarTextActiveColor = colors[3]; - theme.sidebarHeaderBg = colors[1]; - theme.sidebarHeaderTextColor = colors[5]; - theme.onlineIndicator = colors[6]; - theme.awayIndicator = '#E0B333'; - theme.mentionBj = colors[7]; - theme.mentionColor = '#ffffff'; - theme.centerChannelBg = '#ffffff'; - theme.centerChannelColor = '#333333'; - theme.newMessageSeparator = '#F80'; - theme.linkColor = '#2389d7'; - theme.buttonBg = '#26a970'; - theme.buttonColor = '#ffffff'; - theme.mentionHighlightBg = '#fff2bb'; - theme.mentionHighlightLink = '#2f81b7'; - theme.codeTheme = 'github'; - - let user = UserStore.getCurrentUser(); - user.theme_props = theme; - - Client.updateUser(user, - (data) => { - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_ME, - me: data - }); - - this.setState({show: false}); - Utils.applyTheme(theme); - }, - (err) => { - var state = this.getStateFromStores(); - state.serverError = err; - this.setState(state); - } - ); - } - isInputValid(text) { - if (text.length === 0) { - return false; - } - - if (text.indexOf(' ') !== -1) { - return false; - } - - if (text.length > 0 && text.indexOf(',') === -1) { - return false; - } - - if (text.length > 0) { - const colors = text.split(','); - - if (colors.length !== 8) { - return false; - } - - for (let i = 0; i < colors.length; i++) { - if (colors[i].length !== 7 && colors[i].length !== 4) { - return false; - } - - if (colors[i].charAt(0) !== '#') { - return false; - } - } - } - - return true; - } - handleChange(e) { - if (this.isInputValid(e.target.value)) { - this.setState({inputError: null}); - } else { - this.setState({inputError: this.props.intl.formatMessage(holders.submitError)}); - } - } - render() { - return ( - - this.setState({show: false})} - > - - - - - -
- -

- -

-
-
- -
- {this.state.inputError} -
-
-
-
- - - - -
-
-
- ); - } -} - -ImportThemeModal.propTypes = { - intl: intlShape.isRequired -}; - -export default injectIntl(ImportThemeModal); diff --git a/web/react/components/user_settings/manage_command_hooks.jsx b/web/react/components/user_settings/manage_command_hooks.jsx deleted file mode 100644 index 2947138be..000000000 --- a/web/react/components/user_settings/manage_command_hooks.jsx +++ /dev/null @@ -1,679 +0,0 @@ -// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import LoadingScreen from '../loading_screen.jsx'; - -import * as Client from '../../utils/client.jsx'; - -import {intlShape, injectIntl, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'mm-intl'; - -const holders = defineMessages({ - requestTypePost: { - id: 'user.settings.cmds.request_type_post', - defaultMessage: 'POST' - }, - requestTypeGet: { - id: 'user.settings.cmds.request_type_get', - defaultMessage: 'GET' - }, - addDisplayNamePlaceholder: { - id: 'user.settings.cmds.add_display_name.placeholder', - defaultMessage: 'Example: "Search patient records"' - }, - addUsernamePlaceholder: { - id: 'user.settings.cmds.add_username.placeholder', - defaultMessage: 'Username' - }, - addTriggerPlaceholder: { - id: 'user.settings.cmds.add_trigger.placeholder', - defaultMessage: 'Command trigger e.g. "hello" not including the slash' - }, - addAutoCompleteDescPlaceholder: { - id: 'user.settings.cmds.auto_complete_desc.placeholder', - defaultMessage: 'Example: "Returns search results for patient records"' - }, - addAutoCompleteHintPlaceholder: { - id: 'user.settings.cmds.auto_complete_hint.placeholder', - defaultMessage: 'Example: [Patient Name]' - }, - adUrlPlaceholder: { - id: 'user.settings.cmds.url.placeholder', - defaultMessage: 'Must start with http:// or https://' - }, - autocompleteYes: { - id: 'user.settings.cmds.auto_complete.yes', - defaultMessage: 'yes' - }, - autocompleteNo: { - id: 'user.settings.cmds.auto_complete.no', - defaultMessage: 'no' - } -}); - -export default class ManageCommandCmds extends React.Component { - constructor() { - super(); - - this.getCmds = this.getCmds.bind(this); - this.addNewCmd = this.addNewCmd.bind(this); - this.emptyCmd = this.emptyCmd.bind(this); - this.updateTrigger = this.updateTrigger.bind(this); - this.updateURL = this.updateURL.bind(this); - this.updateMethod = this.updateMethod.bind(this); - this.updateUsername = this.updateUsername.bind(this); - this.updateIconURL = this.updateIconURL.bind(this); - this.updateDisplayName = this.updateDisplayName.bind(this); - this.updateAutoComplete = this.updateAutoComplete.bind(this); - this.updateAutoCompleteDesc = this.updateAutoCompleteDesc.bind(this); - this.updateAutoCompleteHint = this.updateAutoCompleteHint.bind(this); - - this.state = {cmds: [], cmd: this.emptyCmd(), getCmdsComplete: false}; - } - - static propTypes() { - return { - intl: intlShape.isRequired - }; - } - - emptyCmd() { - var cmd = {}; - cmd.url = ''; - cmd.trigger = ''; - cmd.method = 'P'; - cmd.username = ''; - cmd.icon_url = ''; - cmd.auto_complete = false; - cmd.auto_complete_desc = ''; - cmd.auto_complete_hint = ''; - cmd.display_name = ''; - return cmd; - } - - componentDidMount() { - this.getCmds(); - } - - addNewCmd(e) { - e.preventDefault(); - - if (this.state.cmd.trigger === '' || this.state.cmd.url === '') { - return; - } - - var cmd = this.state.cmd; - if (cmd.trigger.length !== 0) { - cmd.trigger = cmd.trigger.trim(); - } - cmd.url = cmd.url.trim(); - - Client.addCommand( - cmd, - (data) => { - let cmds = Object.assign([], this.state.cmds); - if (!cmds) { - cmds = []; - } - cmds.push(data); - this.setState({cmds, addError: null, cmd: this.emptyCmd()}); - }, - (err) => { - this.setState({addError: err.message}); - } - ); - } - - removeCmd(id) { - const data = {}; - data.id = id; - - Client.deleteCommand( - data, - () => { - const cmds = this.state.cmds; - let index = -1; - for (let i = 0; i < cmds.length; i++) { - if (cmds[i].id === id) { - index = i; - break; - } - } - - if (index !== -1) { - cmds.splice(index, 1); - } - - this.setState({cmds}); - }, - (err) => { - this.setState({editError: err.message}); - } - ); - } - - regenToken(id) { - const regenData = {}; - regenData.id = id; - - Client.regenCommandToken( - regenData, - (data) => { - const cmds = Object.assign([], this.state.cmds); - for (let i = 0; i < cmds.length; i++) { - if (cmds[i].id === id) { - cmds[i] = data; - break; - } - } - - this.setState({cmds, editError: null}); - }, - (err) => { - this.setState({editError: err.message}); - } - ); - } - - getCmds() { - Client.listTeamCommands( - (data) => { - if (data) { - this.setState({cmds: data, getCmdsComplete: true, editError: null}); - } - }, - (err) => { - this.setState({editError: err.message}); - } - ); - } - - updateTrigger(e) { - var cmd = this.state.cmd; - cmd.trigger = e.target.value; - this.setState(cmd); - } - - updateURL(e) { - var cmd = this.state.cmd; - cmd.url = e.target.value; - this.setState(cmd); - } - - updateMethod(e) { - var cmd = this.state.cmd; - cmd.method = e.target.value; - this.setState(cmd); - } - - updateUsername(e) { - var cmd = this.state.cmd; - cmd.username = e.target.value; - this.setState(cmd); - } - - updateIconURL(e) { - var cmd = this.state.cmd; - cmd.icon_url = e.target.value; - this.setState(cmd); - } - - updateDisplayName(e) { - var cmd = this.state.cmd; - cmd.display_name = e.target.value; - this.setState(cmd); - } - - updateAutoComplete(e) { - var cmd = this.state.cmd; - cmd.auto_complete = e.target.checked; - this.setState(cmd); - } - - updateAutoCompleteDesc(e) { - var cmd = this.state.cmd; - cmd.auto_complete_desc = e.target.value; - this.setState(cmd); - } - - updateAutoCompleteHint(e) { - var cmd = this.state.cmd; - cmd.auto_complete_hint = e.target.value; - this.setState(cmd); - } - - render() { - let addError; - if (this.state.addError) { - addError = ; - } - - let editError; - if (this.state.editError) { - addError = ; - } - - const cmds = []; - this.state.cmds.forEach((cmd) => { - let triggerDiv; - if (cmd.trigger && cmd.trigger.length !== 0) { - triggerDiv = ( -
- - - {cmd.trigger} -
- ); - } - - cmds.push( -
- {triggerDiv} -
- - - {cmd.url} -
-
- - - - - { - cmd.method === 'P' ? - : - - } - -
-
- - - {cmd.username} -
-
- - - {cmd.icon_url} -
-
- - - {cmd.auto_complete ? this.props.intl.formatMessage(holders.autocompleteYes) : this.props.intl.formatMessage(holders.autocompleteNo)} -
-
- - - {cmd.auto_complete_hint} -
-
- - - {cmd.auto_complete_desc} -
-
- - - {cmd.display_name} -
-
- - - {cmd.token} -
-
- - - - - - -
-
-
- ); - }); - - let displayCmds; - if (!this.state.getCmdsComplete) { - displayCmds = ; - } else if (cmds.length > 0) { - displayCmds = cmds; - } else { - displayCmds = ( -
- -
- ); - } - - const existingCmds = ( -
- -
-
- {displayCmds} -
-
- ); - - const disableButton = this.state.cmd.trigger === '' || this.state.cmd.url === ''; - - return ( -
- -
-
-
- -
- -
- -
-
- -
-
- -
- -
- -
-
- -
-
- -
- -
- -
-
- -
-
- -
- -
- -
-
- -
-
- -
- -
- -
-
- -
-
- -
- -
-
- -
-
-
- -
- -
- -
-
- -
-
- -
- -
- -
-
- -
-
- -
- -
- -
-
- -
- {addError} -
- -
- - - -
-
- {existingCmds} - {editError} -
- ); - } -} - -export default injectIntl(ManageCommandCmds); diff --git a/web/react/components/user_settings/manage_incoming_hooks.jsx b/web/react/components/user_settings/manage_incoming_hooks.jsx deleted file mode 100644 index 79a71b5ac..000000000 --- a/web/react/components/user_settings/manage_incoming_hooks.jsx +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import * as Client from '../../utils/client.jsx'; -import * as Utils from '../../utils/utils.jsx'; -import Constants from '../../utils/constants.jsx'; -import ChannelStore from '../../stores/channel_store.jsx'; -import LoadingScreen from '../loading_screen.jsx'; - -import {FormattedMessage, FormattedHTMLMessage} from 'mm-intl'; - -export default class ManageIncomingHooks extends React.Component { - constructor() { - super(); - - this.getHooks = this.getHooks.bind(this); - this.addNewHook = this.addNewHook.bind(this); - this.updateChannelId = this.updateChannelId.bind(this); - - this.state = {hooks: [], channelId: ChannelStore.getByName(Constants.DEFAULT_CHANNEL).id, getHooksComplete: false}; - } - componentDidMount() { - this.getHooks(); - } - addNewHook() { - const hook = {}; - hook.channel_id = this.state.channelId; - - Client.addIncomingHook( - hook, - (data) => { - let hooks = this.state.hooks; - if (!hooks) { - hooks = []; - } - hooks.push(data); - this.setState({hooks}); - }, - (err) => { - this.setState({serverError: err}); - } - ); - } - removeHook(id) { - const data = {}; - data.id = id; - - Client.deleteIncomingHook( - data, - () => { - const hooks = this.state.hooks; - let index = -1; - for (let i = 0; i < hooks.length; i++) { - if (hooks[i].id === id) { - index = i; - break; - } - } - - if (index !== -1) { - hooks.splice(index, 1); - } - - this.setState({hooks}); - }, - (err) => { - this.setState({serverError: err}); - } - ); - } - getHooks() { - Client.listIncomingHooks( - (data) => { - const state = this.state; - - if (data) { - state.hooks = data; - } - - state.getHooksComplete = true; - this.setState(state); - }, - (err) => { - this.setState({serverError: err}); - } - ); - } - updateChannelId(e) { - this.setState({channelId: e.target.value}); - } - render() { - let serverError; - if (this.state.serverError) { - serverError = ; - } - - const channels = ChannelStore.getAll(); - const options = []; - channels.forEach((channel) => { - if (channel.type !== Constants.DM_CHANNEL) { - options.push( - - ); - } - }); - - let disableButton = ''; - if (this.state.channelId === '') { - disableButton = ' disable'; - } - - const hooks = []; - this.state.hooks.forEach((hook) => { - const c = ChannelStore.get(hook.channel_id); - if (c) { - hooks.push( -
-
- {'URL: '} - {Utils.getWindowLocationOrigin() + '/hooks/' + hook.id} -
-
- - - {c.display_name} -
- - - -
-
- ); - } - }); - - let displayHooks; - if (!this.state.getHooksComplete) { - displayHooks = ; - } else if (hooks.length > 0) { - displayHooks = hooks; - } else { - displayHooks = ( -
- -
- ); - } - - const existingHooks = ( -
- -
-
- {displayHooks} -
-
- ); - - return ( -
- -
-
-
- - {serverError} -
-
- - - -
-
- {existingHooks} -
- ); - } -} diff --git a/web/react/components/user_settings/manage_languages.jsx b/web/react/components/user_settings/manage_languages.jsx deleted file mode 100644 index 6b00a65c7..000000000 --- a/web/react/components/user_settings/manage_languages.jsx +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. -// See License.txt for license information. - -import SettingItemMax from '../setting_item_max.jsx'; - -import * as Client from '../../utils/client.jsx'; -import * as Utils from '../../utils/utils.jsx'; -import * as GlobalActions from '../../action_creators/global_actions.jsx'; - -import {FormattedMessage} from 'mm-intl'; - -export default class ManageLanguage extends React.Component { - constructor(props) { - super(props); - - this.setupInitialState = this.setupInitialState.bind(this); - this.setLanguage = this.setLanguage.bind(this); - this.changeLanguage = this.changeLanguage.bind(this); - this.submitUser = this.submitUser.bind(this); - this.state = this.setupInitialState(props); - } - setupInitialState(props) { - var user = props.user; - return { - languages: Utils.languages(), - locale: user.locale - }; - } - setLanguage(e) { - this.setState({locale: e.target.value}); - } - changeLanguage(e) { - e.preventDefault(); - - var user = this.props.user; - var locale = this.state.locale; - - user.locale = locale; - - this.submitUser(user); - } - submitUser(user) { - Client.updateUser(user, - () => { - GlobalActions.newLocalizationSelected(user.locale); - }, - (err) => { - let serverError; - if (err.message) { - serverError = err.message; - } else { - serverError = err; - } - this.setState({serverError}); - } - ); - } - render() { - let serverError; - if (this.state.serverError) { - serverError = ; - } - - const options = []; - this.state.languages.forEach((lang) => { - options.push( - ); - }); - - const input = ( -
-
- -
- - {serverError} -
-
- ); - - return ( - - } - width='medium' - submit={this.changeLanguage} - inputs={[input]} - updateSection={this.props.updateSection} - /> - ); - } -} - -ManageLanguage.propTypes = { - user: React.PropTypes.object.isRequired, - updateSection: React.PropTypes.func.isRequired -}; diff --git a/web/react/components/user_settings/manage_outgoing_hooks.jsx b/web/react/components/user_settings/manage_outgoing_hooks.jsx deleted file mode 100644 index 487254d15..000000000 --- a/web/react/components/user_settings/manage_outgoing_hooks.jsx +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import LoadingScreen from '../loading_screen.jsx'; - -import ChannelStore from '../../stores/channel_store.jsx'; - -import * as Client from '../../utils/client.jsx'; -import Constants from '../../utils/constants.jsx'; - -import {intlShape, injectIntl, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'mm-intl'; - -const holders = defineMessages({ - optional: { - id: 'user.settings.hooks_out.optional', - defaultMessage: 'Optional if channel selected' - }, - callbackHolder: { - id: 'user.settings.hooks_out.callbackHolder', - defaultMessage: 'Each URL must start with http:// or https://' - }, - select: { - id: 'user.settings.hooks_out.select', - defaultMessage: '--- Select a channel ---' - } -}); - -class ManageOutgoingHooks extends React.Component { - constructor() { - super(); - - this.getHooks = this.getHooks.bind(this); - this.addNewHook = this.addNewHook.bind(this); - this.updateChannelId = this.updateChannelId.bind(this); - this.updateTriggerWords = this.updateTriggerWords.bind(this); - this.updateCallbackURLs = this.updateCallbackURLs.bind(this); - - this.state = {hooks: [], channelId: '', triggerWords: '', callbackURLs: '', getHooksComplete: false}; - } - componentDidMount() { - this.getHooks(); - } - addNewHook(e) { - e.preventDefault(); - - if ((this.state.channelId === '' && this.state.triggerWords === '') || - this.state.callbackURLs === '') { - return; - } - - const hook = {}; - hook.channel_id = this.state.channelId; - if (this.state.triggerWords.length !== 0) { - hook.trigger_words = this.state.triggerWords.trim().split(','); - } - hook.callback_urls = this.state.callbackURLs.split('\n').map((url) => url.trim()); - - Client.addOutgoingHook( - hook, - (data) => { - let hooks = Object.assign([], this.state.hooks); - if (!hooks) { - hooks = []; - } - hooks.push(data); - this.setState({hooks, addError: null, channelId: '', triggerWords: '', callbackURLs: ''}); - }, - (err) => { - this.setState({addError: err.message}); - } - ); - } - removeHook(id) { - const data = {}; - data.id = id; - - Client.deleteOutgoingHook( - data, - () => { - const hooks = this.state.hooks; - let index = -1; - for (let i = 0; i < hooks.length; i++) { - if (hooks[i].id === id) { - index = i; - break; - } - } - - if (index !== -1) { - hooks.splice(index, 1); - } - - this.setState({hooks}); - }, - (err) => { - this.setState({editError: err.message}); - } - ); - } - regenToken(id) { - const regenData = {}; - regenData.id = id; - - Client.regenOutgoingHookToken( - regenData, - (data) => { - const hooks = Object.assign([], this.state.hooks); - for (let i = 0; i < hooks.length; i++) { - if (hooks[i].id === id) { - hooks[i] = data; - break; - } - } - - this.setState({hooks, editError: null}); - }, - (err) => { - this.setState({editError: err.message}); - } - ); - } - getHooks() { - Client.listOutgoingHooks( - (data) => { - if (data) { - this.setState({hooks: data, getHooksComplete: true, editError: null}); - } - }, - (err) => { - this.setState({editError: err.message}); - } - ); - } - updateChannelId(e) { - this.setState({channelId: e.target.value}); - } - updateTriggerWords(e) { - this.setState({triggerWords: e.target.value}); - } - updateCallbackURLs(e) { - this.setState({callbackURLs: e.target.value}); - } - render() { - let addError; - if (this.state.addError) { - addError = ; - } - let editError; - if (this.state.editError) { - addError = ; - } - - const channels = ChannelStore.getAll(); - const options = []; - options.push( - - ); - - channels.forEach((channel) => { - if (channel.type === Constants.OPEN_CHANNEL) { - options.push( - - ); - } - }); - - const hooks = []; - this.state.hooks.forEach((hook) => { - const c = ChannelStore.get(hook.channel_id); - - if (!c && hook.channel_id && hook.channel_id.length !== 0) { - return; - } - - let channelDiv; - if (c) { - channelDiv = ( -
- - - {c.display_name} -
- ); - } - - let triggerDiv; - if (hook.trigger_words && hook.trigger_words.length !== 0) { - triggerDiv = ( -
- - - {hook.trigger_words.join(', ')} -
- ); - } - - hooks.push( -
-
- {'URLs: '}{hook.callback_urls.join(', ')} -
- {channelDiv} - {triggerDiv} -
- {'Token: '}{hook.token} -
- -
-
- ); - }); - - let displayHooks; - if (!this.state.getHooksComplete) { - displayHooks = ; - } else if (hooks.length > 0) { - displayHooks = hooks; - } else { - displayHooks = ( -
- -
- ); - } - - const existingHooks = ( -
- -
-
- {displayHooks} -
-
- ); - - const disableButton = (this.state.channelId === '' && this.state.triggerWords === '') || this.state.callbackURLs === ''; - - return ( -
- -
-
-
-
- -
- -
-
- -
-
-
- -
- -
-
- -
-
-
- -
-