Этот коммит содержится в:
David Lu
2016-07-06 17:16:53 -04:00
коммит произвёл Corey Hulen
родитель 3ebc259f63
Коммит 7b6e8d788b
6 изменённых файлов: 37 добавлений и 10 удалений

Просмотреть файл

@@ -84,7 +84,7 @@ class ImportThemeModal extends React.Component {
const user = UserStore.getCurrentUser(); const user = UserStore.getCurrentUser();
user.theme_props = theme; user.theme_props = theme;
Client.updateUser(user, Client.updateUser(user, Constants.UserUpdateEvents.THEME,
(data) => { (data) => {
AppDispatcher.handleServerAction({ AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_ME, type: ActionTypes.RECEIVED_ME,

Просмотреть файл

@@ -6,6 +6,7 @@ import SettingItemMax from '../setting_item_max.jsx';
import Client from 'utils/web_client.jsx'; import Client from 'utils/web_client.jsx';
import * as I18n from 'i18n/i18n.jsx'; import * as I18n from 'i18n/i18n.jsx';
import * as GlobalActions from 'actions/global_actions.jsx'; import * as GlobalActions from 'actions/global_actions.jsx';
import Constants from 'utils/constants.jsx';
import {FormattedMessage} from 'react-intl'; import {FormattedMessage} from 'react-intl';
@@ -41,7 +42,7 @@ export default class ManageLanguage extends React.Component {
this.submitUser(user); this.submitUser(user);
} }
submitUser(user) { submitUser(user) {
Client.updateUser(user, Client.updateUser(user, Constants.UserUpdateEvents.LANGUAGE,
() => { () => {
GlobalActions.newLocalizationSelected(user.locale); GlobalActions.newLocalizationSelected(user.locale);
}, },

Просмотреть файл

@@ -97,6 +97,7 @@ class UserSettingsGeneralTab extends React.Component {
this.state = this.setupInitialState(props); this.state = this.setupInitialState(props);
this.setState({maxFileSize: global.window.mm_config.MaxFileSize}); this.setState({maxFileSize: global.window.mm_config.MaxFileSize});
} }
submitUsername(e) { submitUsername(e) {
e.preventDefault(); e.preventDefault();
@@ -120,8 +121,9 @@ class UserSettingsGeneralTab extends React.Component {
user.username = username; user.username = username;
this.submitUser(user, false); this.submitUser(user, Constants.UserUpdateEvents.USERNAME, false);
} }
submitNickname(e) { submitNickname(e) {
e.preventDefault(); e.preventDefault();
@@ -135,8 +137,9 @@ class UserSettingsGeneralTab extends React.Component {
user.nickname = nickname; user.nickname = nickname;
this.submitUser(user, false); this.submitUser(user, Constants.UserUpdateEvents.NICKNAME, false);
} }
submitName(e) { submitName(e) {
e.preventDefault(); e.preventDefault();
@@ -152,8 +155,9 @@ class UserSettingsGeneralTab extends React.Component {
user.first_name = firstName; user.first_name = firstName;
user.last_name = lastName; user.last_name = lastName;
this.submitUser(user, false); this.submitUser(user, Constants.UserUpdateEvents.FULLNAME, false);
} }
submitEmail(e) { submitEmail(e) {
e.preventDefault(); e.preventDefault();
@@ -179,10 +183,11 @@ class UserSettingsGeneralTab extends React.Component {
} }
user.email = email; 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(''); this.updateSection('');
AsyncClient.getMe(); AsyncClient.getMe();
@@ -205,6 +210,7 @@ class UserSettingsGeneralTab extends React.Component {
} }
); );
} }
submitPicture(e) { submitPicture(e) {
e.preventDefault(); e.preventDefault();
@@ -242,24 +248,31 @@ class UserSettingsGeneralTab extends React.Component {
} }
); );
} }
updateUsername(e) { updateUsername(e) {
this.setState({username: e.target.value}); this.setState({username: e.target.value});
} }
updateFirstName(e) { updateFirstName(e) {
this.setState({firstName: e.target.value}); this.setState({firstName: e.target.value});
} }
updateLastName(e) { updateLastName(e) {
this.setState({lastName: e.target.value}); this.setState({lastName: e.target.value});
} }
updateNickname(e) { updateNickname(e) {
this.setState({nickname: e.target.value}); this.setState({nickname: e.target.value});
} }
updateEmail(e) { updateEmail(e) {
this.setState({email: e.target.value}); this.setState({email: e.target.value});
} }
updateConfirmEmail(e) { updateConfirmEmail(e) {
this.setState({confirmEmail: e.target.value}); this.setState({confirmEmail: e.target.value});
} }
updatePicture(e) { updatePicture(e) {
if (e.target.files && e.target.files[0]) { if (e.target.files && e.target.files[0]) {
this.setState({picture: e.target.files[0]}); this.setState({picture: e.target.files[0]});
@@ -270,6 +283,7 @@ class UserSettingsGeneralTab extends React.Component {
this.setState({picture: null}); this.setState({picture: null});
} }
} }
updateSection(section) { updateSection(section) {
$('.settings-modal .modal-body').scrollTop(0).perfectScrollbar('update'); $('.settings-modal .modal-body').scrollTop(0).perfectScrollbar('update');
const emailChangeInProgress = this.state.emailChangeInProgress; const emailChangeInProgress = this.state.emailChangeInProgress;
@@ -277,12 +291,14 @@ class UserSettingsGeneralTab extends React.Component {
this.submitActive = false; this.submitActive = false;
this.props.updateSection(section); this.props.updateSection(section);
} }
setupInitialState(props) { setupInitialState(props) {
const user = props.user; const user = props.user;
return {username: user.username, firstName: user.first_name, lastName: user.last_name, nickname: user.nickname, 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}; email: user.email, confirmEmail: '', picture: null, loadingPicture: false, emailChangeInProgress: false};
} }
createEmailSection() { createEmailSection() {
let emailSection; let emailSection;
@@ -526,6 +542,7 @@ class UserSettingsGeneralTab extends React.Component {
return emailSection; return emailSection;
} }
render() { render() {
const user = this.props.user; const user = this.props.user;
const {formatMessage} = this.props.intl; const {formatMessage} = this.props.intl;

Просмотреть файл

@@ -111,7 +111,7 @@ export default class ThemeSetting extends React.Component {
var user = UserStore.getCurrentUser(); var user = UserStore.getCurrentUser();
user.theme_props = this.state.theme; user.theme_props = this.state.theme;
Client.updateUser(user, Client.updateUser(user, Constants.UserUpdateEvents.THEME,
(data) => { (data) => {
AppDispatcher.handleServerAction({ AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_ME, type: ActionTypes.RECEIVED_ME,

Просмотреть файл

@@ -18,7 +18,7 @@
"keymirror": "0.1.1", "keymirror": "0.1.1",
"marked": "mattermost/marked#12d2be4cdf54d4ec95fead934e18840b6a2c1a7b", "marked": "mattermost/marked#12d2be4cdf54d4ec95fead934e18840b6a2c1a7b",
"match-at": "0.1.0", "match-at": "0.1.0",
"mattermost": "mattermost/mattermost-javascript#798c39c5d302d2d109e768a35575ebdbf2a8ee6a", "mattermost": "mattermost/mattermost-javascript#18527e6c4a9aea69aa7845a62d9618b357faa4e7",
"object-assign": "4.1.0", "object-assign": "4.1.0",
"perfect-scrollbar": "0.6.11", "perfect-scrollbar": "0.6.11",
"react": "15.0.2", "react": "15.0.2",

Просмотреть файл

@@ -167,6 +167,15 @@ export default {
EPHEMERAL_MESSAGE: 'ephemeral_message' EPHEMERAL_MESSAGE: 'ephemeral_message'
}, },
UserUpdateEvents: {
USERNAME: 'username',
FULLNAME: 'fullname',
NICKNAME: 'nickname',
EMAIL: 'email',
THEME: 'theme',
LANGUAGE: 'language'
},
ScrollTypes: { ScrollTypes: {
FREE: 1, FREE: 1,
BOTTOM: 2, BOTTOM: 2,