From 40743af734e438a97f946476552ccda2a5b0dbcf Mon Sep 17 00:00:00 2001 From: enahum Date: Fri, 27 May 2016 13:53:31 -0300 Subject: [PATCH 1/2] PLT-3030 Fix Blank Page (#3104) --- webapp/action_creators/global_actions.jsx | 14 ++++++++-- webapp/components/login/login.jsx | 1 + webapp/components/root.jsx | 33 ++++++++++++----------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/webapp/action_creators/global_actions.jsx b/webapp/action_creators/global_actions.jsx index 6bb0c1732b..f437e8a034 100644 --- a/webapp/action_creators/global_actions.jsx +++ b/webapp/action_creators/global_actions.jsx @@ -392,11 +392,15 @@ export function newLocalizationSelected(locale) { } else { Client.getTranslations( I18n.getLanguageInfo(locale).url, - (data) => { + (data, res) => { + let translations = data; + if (!data && res.text) { + translations = JSON.parse(res.text); + } AppDispatcher.handleServerAction({ type: ActionTypes.RECEIVED_LOCALE, locale, - translations: data + translations }); }, (err) => { @@ -409,6 +413,12 @@ export function newLocalizationSelected(locale) { export function loadBrowserLocale() { let locale = (navigator.languages && navigator.languages.length > 0 ? navigator.languages[0] : (navigator.language || navigator.userLanguage)).split('-')[0]; + + const user = UserStore.getCurrentUser(); + if (user) { + locale = user.locale || locale; + } + if (!I18n.getLanguages()[locale]) { locale = 'en'; } diff --git a/webapp/components/login/login.jsx b/webapp/components/login/login.jsx index 8ae3fdd4d4..e0969001ac 100644 --- a/webapp/components/login/login.jsx +++ b/webapp/components/login/login.jsx @@ -115,6 +115,7 @@ export default class Login extends React.Component { finishSignin() { GlobalActions.emitInitialLoad( () => { + GlobalActions.loadBrowserLocale(); browserHistory.push('/select_team'); } ); diff --git a/webapp/components/root.jsx b/webapp/components/root.jsx index 0adbc7f043..6a5af75c6a 100644 --- a/webapp/components/root.jsx +++ b/webapp/components/root.jsx @@ -26,6 +26,19 @@ export default class Root extends React.Component { this.localizationChanged = this.localizationChanged.bind(this); this.redirectIfNecessary = this.redirectIfNecessary.bind(this); + + // Ya.... + /*eslint-disable */ + if (window.mm_config.SegmentDeveloperKey != null && window.mm_config.SegmentDeveloperKey !== "") { + !function(){var analytics=global.window.analytics=global.window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","group","track","ready","alias","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t Date: Fri, 27 May 2016 09:56:26 -0700 Subject: [PATCH 2/2] PLT-3063 fix upgrade when user is a team admin (#3127) --- mattermost.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/mattermost.go b/mattermost.go index 6fe285d58a..6073f37f44 100644 --- a/mattermost.go +++ b/mattermost.go @@ -483,6 +483,7 @@ func convertTeamTo30(primaryTeamName string, team *TeamForUpgrade, uniqueEmails for _, user := range users { shouldUpdateUser := false + shouldUpdateRole := false previousRole := user.Roles previousEmail := user.Email previousUsername := user.Username @@ -495,7 +496,7 @@ func convertTeamTo30(primaryTeamName string, team *TeamForUpgrade, uniqueEmails if model.IsInRole(user.Roles, model.ROLE_TEAM_ADMIN) { member.Roles = model.ROLE_TEAM_ADMIN user.Roles = "" - shouldUpdateUser = true + shouldUpdateRole = true } exists := false @@ -609,6 +610,25 @@ func convertTeamTo30(primaryTeamName string, team *TeamForUpgrade, uniqueEmails } } + if shouldUpdateRole { + if _, err := store.GetMaster().Exec(` + UPDATE Users + SET + Roles = '' + WHERE + Id = :Id + `, + map[string]interface{}{ + "Id": user.Id, + }, + ); err != nil { + l4g.Error("Failed to update user role %v details=%v", user.Email, err) + flushLogAndExit(1) + } + + l4g.Info("modified user_id=%v, changed roles from=%v to=%v", user.Id, previousRole, user.Roles) + } + uniqueEmails[user.Email] = true uniqueUsernames[user.Username] = true