From 7b6e8d788b3edc444e84579558092974b163eb1e Mon Sep 17 00:00:00 2001 From: David Lu Date: Wed, 6 Jul 2016 17:16:53 -0400 Subject: Added new segment analytics (#3511) --- .../user_settings/import_theme_modal.jsx | 2 +- .../components/user_settings/manage_languages.jsx | 3 ++- .../user_settings/user_settings_general.jsx | 29 +++++++++++++++++----- .../user_settings/user_settings_theme.jsx | 2 +- webapp/package.json | 2 +- webapp/utils/constants.jsx | 9 +++++++ 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/webapp/components/user_settings/import_theme_modal.jsx b/webapp/components/user_settings/import_theme_modal.jsx index f743feee6..552659c4c 100644 --- a/webapp/components/user_settings/import_theme_modal.jsx +++ b/webapp/components/user_settings/import_theme_modal.jsx @@ -84,7 +84,7 @@ class ImportThemeModal extends React.Component { const user = UserStore.getCurrentUser(); user.theme_props = theme; - Client.updateUser(user, + Client.updateUser(user, Constants.UserUpdateEvents.THEME, (data) => { AppDispatcher.handleServerAction({ type: ActionTypes.RECEIVED_ME, diff --git a/webapp/components/user_settings/manage_languages.jsx b/webapp/components/user_settings/manage_languages.jsx index 269181922..f6e2aaa6d 100644 --- a/webapp/components/user_settings/manage_languages.jsx +++ b/webapp/components/user_settings/manage_languages.jsx @@ -6,6 +6,7 @@ import SettingItemMax from '../setting_item_max.jsx'; import Client from 'utils/web_client.jsx'; import * as I18n from 'i18n/i18n.jsx'; import * as GlobalActions from 'actions/global_actions.jsx'; +import Constants from 'utils/constants.jsx'; import {FormattedMessage} from 'react-intl'; @@ -41,7 +42,7 @@ export default class ManageLanguage extends React.Component { this.submitUser(user); } submitUser(user) { - Client.updateUser(user, + Client.updateUser(user, Constants.UserUpdateEvents.LANGUAGE, () => { GlobalActions.newLocalizationSelected(user.locale); }, diff --git a/webapp/components/user_settings/user_settings_general.jsx b/webapp/components/user_settings/user_settings_general.jsx index 5e821a26a..a449c7d01 100644 --- a/webapp/components/user_settings/user_settings_general.jsx +++ b/webapp/components/user_settings/user_settings_general.jsx @@ -97,6 +97,7 @@ class UserSettingsGeneralTab extends React.Component { this.state = this.setupInitialState(props); this.setState({maxFileSize: global.window.mm_config.MaxFileSize}); } + submitUsername(e) { e.preventDefault(); @@ -120,8 +121,9 @@ class UserSettingsGeneralTab extends React.Component { user.username = username; - this.submitUser(user, false); + this.submitUser(user, Constants.UserUpdateEvents.USERNAME, false); } + submitNickname(e) { e.preventDefault(); @@ -135,8 +137,9 @@ class UserSettingsGeneralTab extends React.Component { user.nickname = nickname; - this.submitUser(user, false); + this.submitUser(user, Constants.UserUpdateEvents.NICKNAME, false); } + submitName(e) { e.preventDefault(); @@ -152,8 +155,9 @@ class UserSettingsGeneralTab extends React.Component { user.first_name = firstName; user.last_name = lastName; - this.submitUser(user, false); + this.submitUser(user, Constants.UserUpdateEvents.FULLNAME, false); } + submitEmail(e) { e.preventDefault(); @@ -179,10 +183,11 @@ class UserSettingsGeneralTab extends React.Component { } user.email = email; - this.submitUser(user, true); + this.submitUser(user, Constants.UserUpdateEvents.EMAIL, true); } - submitUser(user, emailUpdated) { - Client.updateUser(user, + + submitUser(user, type, emailUpdated) { + Client.updateUser(user, type, () => { this.updateSection(''); AsyncClient.getMe(); @@ -205,6 +210,7 @@ class UserSettingsGeneralTab extends React.Component { } ); } + submitPicture(e) { e.preventDefault(); @@ -242,24 +248,31 @@ class UserSettingsGeneralTab extends React.Component { } ); } + updateUsername(e) { this.setState({username: e.target.value}); } + updateFirstName(e) { this.setState({firstName: e.target.value}); } + updateLastName(e) { this.setState({lastName: e.target.value}); } + updateNickname(e) { this.setState({nickname: e.target.value}); } + updateEmail(e) { this.setState({email: e.target.value}); } + updateConfirmEmail(e) { this.setState({confirmEmail: e.target.value}); } + updatePicture(e) { if (e.target.files && e.target.files[0]) { this.setState({picture: e.target.files[0]}); @@ -270,6 +283,7 @@ class UserSettingsGeneralTab extends React.Component { this.setState({picture: null}); } } + updateSection(section) { $('.settings-modal .modal-body').scrollTop(0).perfectScrollbar('update'); const emailChangeInProgress = this.state.emailChangeInProgress; @@ -277,12 +291,14 @@ class UserSettingsGeneralTab extends React.Component { this.submitActive = false; this.props.updateSection(section); } + setupInitialState(props) { const user = props.user; return {username: user.username, firstName: user.first_name, lastName: user.last_name, nickname: user.nickname, email: user.email, confirmEmail: '', picture: null, loadingPicture: false, emailChangeInProgress: false}; } + createEmailSection() { let emailSection; @@ -526,6 +542,7 @@ class UserSettingsGeneralTab extends React.Component { return emailSection; } + render() { const user = this.props.user; const {formatMessage} = this.props.intl; diff --git a/webapp/components/user_settings/user_settings_theme.jsx b/webapp/components/user_settings/user_settings_theme.jsx index 811f4d8e4..94516ec8c 100644 --- a/webapp/components/user_settings/user_settings_theme.jsx +++ b/webapp/components/user_settings/user_settings_theme.jsx @@ -111,7 +111,7 @@ export default class ThemeSetting extends React.Component { var user = UserStore.getCurrentUser(); user.theme_props = this.state.theme; - Client.updateUser(user, + Client.updateUser(user, Constants.UserUpdateEvents.THEME, (data) => { AppDispatcher.handleServerAction({ type: ActionTypes.RECEIVED_ME, diff --git a/webapp/package.json b/webapp/package.json index 62e8b0bc1..b3066542e 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -18,7 +18,7 @@ "keymirror": "0.1.1", "marked": "mattermost/marked#12d2be4cdf54d4ec95fead934e18840b6a2c1a7b", "match-at": "0.1.0", - "mattermost": "mattermost/mattermost-javascript#798c39c5d302d2d109e768a35575ebdbf2a8ee6a", + "mattermost": "mattermost/mattermost-javascript#18527e6c4a9aea69aa7845a62d9618b357faa4e7", "object-assign": "4.1.0", "perfect-scrollbar": "0.6.11", "react": "15.0.2", diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index 0191edcf0..efae8a050 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -167,6 +167,15 @@ export default { EPHEMERAL_MESSAGE: 'ephemeral_message' }, + UserUpdateEvents: { + USERNAME: 'username', + FULLNAME: 'fullname', + NICKNAME: 'nickname', + EMAIL: 'email', + THEME: 'theme', + LANGUAGE: 'language' + }, + ScrollTypes: { FREE: 1, BOTTOM: 2, -- cgit v1.2.3-1-g7c22