Move user actions over to use redux and v4 (#6649)

Этот коммит содержится в:
Joram Wilander
2017-06-15 10:34:20 -04:00
коммит произвёл Harrison Healey
родитель 0c04c5334f
Коммит c0a0065472
11 изменённых файлов: 174 добавлений и 221 удалений

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

@@ -12,7 +12,7 @@ type SwitchRequest struct {
CurrentService string `json:"current_service"` CurrentService string `json:"current_service"`
NewService string `json:"new_service"` NewService string `json:"new_service"`
Email string `json:"email"` Email string `json:"email"`
Password string `json:"current_password"` Password string `json:"password"`
NewPassword string `json:"new_password"` NewPassword string `json:"new_password"`
MfaCode string `json:"mfa_code"` MfaCode string `json:"mfa_code"`
LdapId string `json:"ldap_id"` LdapId string `json:"ldap_id"`

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

@@ -2,14 +2,15 @@
// See License.txt for license information. // See License.txt for license information.
import Client from 'client/web_client.jsx'; import Client from 'client/web_client.jsx';
import {browserHistory} from 'react-router/es6';
import {clientLogout} from 'actions/global_actions.jsx';
import store from 'stores/redux_store.jsx'; import store from 'stores/redux_store.jsx';
const dispatch = store.dispatch; const dispatch = store.dispatch;
const getState = store.getState; const getState = store.getState;
import {updateUserMfa, updateUserPassword} from 'mattermost-redux/actions/users';
import * as AdminActions from 'mattermost-redux/actions/admin'; import * as AdminActions from 'mattermost-redux/actions/admin';
import * as UserActions from 'mattermost-redux/actions/users';
export function saveConfig(config, success, error) { export function saveConfig(config, success, error) {
AdminActions.updateConfig(config)(dispatch, getState).then( AdminActions.updateConfig(config)(dispatch, getState).then(
@@ -39,7 +40,7 @@ export function reloadConfig(success, error) {
} }
export function adminResetMfa(userId, success, error) { export function adminResetMfa(userId, success, error) {
updateUserMfa(userId, false)(dispatch, getState).then( UserActions.updateUserMfa(userId, false)(dispatch, getState).then(
(data) => { (data) => {
if (data && success) { if (data && success) {
success(data); success(data);
@@ -117,7 +118,7 @@ export function recycleDatabaseConnection(success, error) {
} }
export function adminResetPassword(userId, password, success, error) { export function adminResetPassword(userId, password, success, error) {
updateUserPassword(userId, '', password)(dispatch, getState).then( UserActions.updateUserPassword(userId, '', password)(dispatch, getState).then(
(data) => { (data) => {
if (data && success) { if (data && success) {
success(data); success(data);
@@ -193,60 +194,44 @@ export function allowOAuth2(params, success, error) {
} }
export function emailToLdap(loginId, password, token, ldapId, ldapPassword, success, error) { export function emailToLdap(loginId, password, token, ldapId, ldapPassword, success, error) {
Client.emailToLdap( UserActions.switchEmailToLdap(loginId, password, ldapId, ldapPassword, token)(dispatch, getState).then(
loginId,
password,
token,
ldapId,
ldapPassword,
(data) => { (data) => {
if (success) { if (data && success) {
success(data); success(data);
} } else if (data == null && error) {
}, const serverError = getState().requests.users.switchLogin.error;
(err) => { error({id: serverError.server_error_id, ...serverError});
if (error) {
error(err);
} }
} }
); );
} }
export function emailToOAuth(loginId, password, token, newType, success, error) { export function emailToOAuth(loginId, password, token, newType, success, error) {
Client.emailToOAuth( UserActions.switchEmailToOAuth(newType, loginId, password, token)(dispatch, getState).then(
loginId,
password,
token,
newType,
(data) => { (data) => {
if (success) { if (data && success) {
success(data); success(data);
} } else if (data == null && error) {
}, const serverError = getState().requests.users.switchLogin.error;
(err) => { error({id: serverError.server_error_id, ...serverError});
if (error) {
error(err);
} }
} }
); );
} }
export function oauthToEmail(email, password, success, error) { export function oauthToEmail(currentService, email, password, success, error) {
Client.oauthToEmail( UserActions.switchOAuthToEmail(currentService, email, password)(dispatch, getState).then(
email,
password,
(data) => { (data) => {
if (data) {
if (data.follow_link) { if (data.follow_link) {
browserHistory.push(data.follow_link); clientLogout(data.follow_link);
} }
if (success) { if (success) {
success(data); success(data);
} }
}, } else if (data == null && error) {
(err) => { const serverError = getState().requests.users.switchLogin.error;
if (error) { error({id: serverError.server_error_id, ...serverError});
error(err);
} }
} }
); );

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

@@ -1,20 +1,17 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import PreferenceStore from 'stores/preference_store.jsx'; import PreferenceStore from 'stores/preference_store.jsx';
import TeamStore from 'stores/team_store.jsx'; import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx'; import UserStore from 'stores/user_store.jsx';
import ChannelStore from 'stores/channel_store.jsx'; import ChannelStore from 'stores/channel_store.jsx';
import {getChannelMembersForUserIds} from 'actions/channel_actions.jsx'; import {getChannelMembersForUserIds} from 'actions/channel_actions.jsx';
import {loadCurrentLocale} from 'actions/global_actions.jsx'; import {loadCurrentLocale, clientLogout} from 'actions/global_actions.jsx';
import {loadStatusesForProfilesList, loadStatusesForProfilesMap} from 'actions/status_actions.jsx'; import {loadStatusesForProfilesList, loadStatusesForProfilesMap} from 'actions/status_actions.jsx';
import {getDirectChannelName, getUserIdFromChannelName} from 'utils/utils.jsx'; import {getDirectChannelName, getUserIdFromChannelName} from 'utils/utils.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import Client from 'client/web_client.jsx'; import Client from 'client/web_client.jsx';
import {Constants, ActionTypes, Preferences} from 'utils/constants.jsx'; import {Constants, ActionTypes, Preferences} from 'utils/constants.jsx';
@@ -28,34 +25,17 @@ const getState = store.getState;
import * as Selectors from 'mattermost-redux/selectors/entities/users'; import * as Selectors from 'mattermost-redux/selectors/entities/users';
import {getBool} from 'mattermost-redux/selectors/entities/preferences'; import {getBool} from 'mattermost-redux/selectors/entities/preferences';
import { import * as UserActions from 'mattermost-redux/actions/users';
getProfiles,
getProfilesInChannel,
getProfilesInTeam,
getProfilesWithoutTeam,
getProfilesByIds,
getMe,
searchProfiles,
autocompleteUsers as autocompleteRedux,
updateMe,
updateUserMfa,
checkMfa as checkMfaRedux,
updateUserPassword,
createUser,
login,
loadMe as loadMeRedux,
updateUserRoles as updateUserRolesRedux,
getStatus,
setStatus
} from 'mattermost-redux/actions/users';
import {getClientConfig, getLicenseConfig} from 'mattermost-redux/actions/general'; import {getClientConfig, getLicenseConfig} from 'mattermost-redux/actions/general';
import {getTeamMembersByIds, getMyTeamMembers} from 'mattermost-redux/actions/teams'; import {getTeamMembersByIds, getMyTeamMembers, getMyTeamUnreads} from 'mattermost-redux/actions/teams';
import {getChannelAndMyMember} from 'mattermost-redux/actions/channels'; import {getChannelAndMyMember} from 'mattermost-redux/actions/channels';
import {savePreferences, deletePreferences} from 'mattermost-redux/actions/preferences';
import {Preferences as PreferencesRedux} from 'mattermost-redux/constants'; import {Preferences as PreferencesRedux} from 'mattermost-redux/constants';
export function loadMe(callback) { export function loadMe(callback) {
loadMeRedux()(dispatch, getState).then( UserActions.loadMe()(dispatch, getState).then(
() => { () => {
loadCurrentLocale(); loadCurrentLocale();
@@ -102,27 +82,26 @@ export function loadMeAndConfig(callback) {
}); });
} }
export function switchFromLdapToEmail(email, password, token, ldapPassword, onSuccess, onError) { export function switchFromLdapToEmail(email, password, token, ldapPassword, success, error) {
Client.ldapToEmail( UserActions.switchLdapToEmail(ldapPassword, email, password, token)(dispatch, getState).then(
email,
password,
token,
ldapPassword,
(data) => { (data) => {
if (data) {
if (data.follow_link) { if (data.follow_link) {
window.location.href = data.follow_link; clientLogout(data.follow_link);
}
if (success) {
success(data);
}
} else if (data == null && error) {
const serverError = getState().requests.users.switchLogin.error;
error({id: serverError.server_error_id, ...serverError});
} }
if (onSuccess) {
onSuccess(data);
} }
},
onError
); );
} }
export function loadProfilesAndTeamMembers(page, perPage, teamId = TeamStore.getCurrentId(), success) { export function loadProfilesAndTeamMembers(page, perPage, teamId = TeamStore.getCurrentId(), success) {
getProfilesInTeam(teamId, page, perPage)(dispatch, getState).then( UserActions.getProfilesInTeam(teamId, page, perPage)(dispatch, getState).then(
(data) => { (data) => {
loadTeamMembersForProfilesList(data, teamId, success); loadTeamMembersForProfilesList(data, teamId, success);
loadStatusesForProfilesList(data); loadStatusesForProfilesList(data);
@@ -131,7 +110,7 @@ export function loadProfilesAndTeamMembers(page, perPage, teamId = TeamStore.get
} }
export function loadProfilesAndTeamMembersAndChannelMembers(page, perPage, teamId = TeamStore.getCurrentId(), channelId = ChannelStore.getCurrentId(), success, error) { export function loadProfilesAndTeamMembersAndChannelMembers(page, perPage, teamId = TeamStore.getCurrentId(), channelId = ChannelStore.getCurrentId(), success, error) {
getProfilesInChannel(channelId, page, perPage)(dispatch, getState).then( UserActions.getProfilesInChannel(channelId, page, perPage)(dispatch, getState).then(
(data) => { (data) => {
loadTeamMembersForProfilesList( loadTeamMembersForProfilesList(
data, data,
@@ -167,7 +146,7 @@ export function loadTeamMembersForProfilesList(profiles, teamId = TeamStore.getC
} }
export function loadProfilesWithoutTeam(page, perPage, success) { export function loadProfilesWithoutTeam(page, perPage, success) {
getProfilesWithoutTeam(page, perPage)(dispatch, getState).then( UserActions.getProfilesWithoutTeam(page, perPage)(dispatch, getState).then(
(data) => { (data) => {
loadStatusesForProfilesMap(data); loadStatusesForProfilesMap(data);
@@ -272,7 +251,8 @@ export function loadNewDMIfNeeded(channelId) {
const pref = PreferenceStore.getBool(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, false); const pref = PreferenceStore.getBool(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, false);
if (pref === false) { if (pref === false) {
PreferenceStore.setPreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true'); PreferenceStore.setPreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true');
AsyncClient.savePreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true'); const currentUserId = UserStore.getCurrentId();
savePreferences(currentUserId, [{user_id: currentUserId, category: Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, name: userId, value: 'true'}])(dispatch, getState);
loadProfilesForDM(); loadProfilesForDM();
} }
} }
@@ -296,7 +276,8 @@ export function loadNewGMIfNeeded(channelId) {
const pref = PreferenceStore.getBool(Preferences.CATEGORY_GROUP_CHANNEL_SHOW, channelId, false); const pref = PreferenceStore.getBool(Preferences.CATEGORY_GROUP_CHANNEL_SHOW, channelId, false);
if (pref === false) { if (pref === false) {
PreferenceStore.setPreference(Preferences.CATEGORY_GROUP_CHANNEL_SHOW, channelId, 'true'); PreferenceStore.setPreference(Preferences.CATEGORY_GROUP_CHANNEL_SHOW, channelId, 'true');
AsyncClient.savePreference(Preferences.CATEGORY_GROUP_CHANNEL_SHOW, channelId, 'true'); const currentUserId = UserStore.getCurrentId();
savePreferences(currentUserId, [{user_id: currentUserId, category: Preferences.CATEGORY_GROUP_CHANNEL_SHOW, name: channelId, value: 'true'}])(dispatch, getState);
loadProfilesForGM(); loadProfilesForGM();
} }
} }
@@ -348,7 +329,7 @@ export function loadProfilesForGM() {
}); });
} }
getProfilesInChannel(channel.id, 0, Constants.MAX_USERS_IN_GM)(dispatch, getState).then( UserActions.getProfilesInChannel(channel.id, 0, Constants.MAX_USERS_IN_GM)(dispatch, getState).then(
(data) => { (data) => {
populateChannelWithProfiles(channel.id, data); populateChannelWithProfiles(channel.id, data);
} }
@@ -356,7 +337,8 @@ export function loadProfilesForGM() {
} }
if (newPreferences.length > 0) { if (newPreferences.length > 0) {
AsyncClient.savePreferences(newPreferences); const currentUserId = UserStore.getCurrentId();
savePreferences(currentUserId, newPreferences)(dispatch, getState);
} }
} }
@@ -396,11 +378,12 @@ export function loadProfilesForDM() {
} }
if (newPreferences.length > 0) { if (newPreferences.length > 0) {
AsyncClient.savePreferences(newPreferences); const currentUserId = UserStore.getCurrentId();
savePreferences(currentUserId, newPreferences)(dispatch, getState);
} }
if (profilesToLoad.length > 0) { if (profilesToLoad.length > 0) {
getProfilesByIds(profilesToLoad)(dispatch, getState).then( UserActions.getProfilesByIds(profilesToLoad)(dispatch, getState).then(
() => { () => {
populateDMChannelsWithProfiles(profileIds); populateDMChannelsWithProfiles(profileIds);
}, },
@@ -411,15 +394,20 @@ export function loadProfilesForDM() {
} }
export function saveTheme(teamId, theme, onSuccess, onError) { export function saveTheme(teamId, theme, onSuccess, onError) {
AsyncClient.savePreference( const currentUserId = UserStore.getCurrentId();
Preferences.CATEGORY_THEME, savePreferences(currentUserId, [{
teamId, user_id: currentUserId,
JSON.stringify(theme), category: Preferences.CATEGORY_THEME,
() => { name: teamId,
value: JSON.stringify(theme)
}])(dispatch, getState).then(
(data) => {
if (data && onSuccess) {
onThemeSaved(teamId, theme, onSuccess); onThemeSaved(teamId, theme, onSuccess);
}, } else if (data == null && onError) {
(err) => { const serverError = getState().requests.users.savePreferences.error;
onError(err); onError({id: serverError.server_error_id, ...serverError});
}
} }
); );
} }
@@ -449,20 +437,15 @@ function onThemeSaved(teamId, theme, onSuccess) {
if (toDelete.length > 0) { if (toDelete.length > 0) {
// we're saving a new global theme so delete any team-specific ones // we're saving a new global theme so delete any team-specific ones
AsyncClient.deletePreferences(toDelete); const currentUserId = UserStore.getCurrentId();
deletePreferences(currentUserId, toDelete)(dispatch, getState);
// delete them locally before we hear from the server so that the UI flow is smoother
AppDispatcher.handleServerAction({
type: ActionTypes.DELETED_PREFERENCES,
preferences: toDelete
});
} }
onSuccess(); onSuccess();
} }
export function searchUsers(term, teamId = TeamStore.getCurrentId(), options = {}, success) { export function searchUsers(term, teamId = TeamStore.getCurrentId(), options = {}, success) {
searchProfiles(term, {team_id: teamId, ...options})(dispatch, getState).then( UserActions.searchProfiles(term, {team_id: teamId, ...options})(dispatch, getState).then(
(data) => { (data) => {
loadStatusesForProfilesList(data); loadStatusesForProfilesList(data);
@@ -474,7 +457,7 @@ export function searchUsers(term, teamId = TeamStore.getCurrentId(), options = {
} }
export function searchUsersNotInTeam(term, teamId = TeamStore.getCurrentId(), options = {}, success) { export function searchUsersNotInTeam(term, teamId = TeamStore.getCurrentId(), options = {}, success) {
searchProfiles(term, {not_in_team_id: teamId, ...options})(dispatch, getState).then( UserActions.searchProfiles(term, {not_in_team_id: teamId, ...options})(dispatch, getState).then(
(data) => { (data) => {
loadStatusesForProfilesList(data); loadStatusesForProfilesList(data);
@@ -488,7 +471,7 @@ export function searchUsersNotInTeam(term, teamId = TeamStore.getCurrentId(), op
export function autocompleteUsersInChannel(username, channelId, success) { export function autocompleteUsersInChannel(username, channelId, success) {
const channel = ChannelStore.get(channelId); const channel = ChannelStore.get(channelId);
const teamId = channel ? channel.team_id : TeamStore.getCurrentId(); const teamId = channel ? channel.team_id : TeamStore.getCurrentId();
autocompleteRedux(username, teamId, channelId)(dispatch, getState).then( UserActions.autocompleteRedux(username, teamId, channelId)(dispatch, getState).then(
(data) => { (data) => {
if (success) { if (success) {
success(data); success(data);
@@ -498,7 +481,7 @@ export function autocompleteUsersInChannel(username, channelId, success) {
} }
export function autocompleteUsersInTeam(username, success) { export function autocompleteUsersInTeam(username, success) {
autocompleteRedux(username, TeamStore.getCurrentId())(dispatch, getState).then( UserActions.autocompleteRedux(username, TeamStore.getCurrentId())(dispatch, getState).then(
(data) => { (data) => {
if (success) { if (success) {
success(data); success(data);
@@ -508,7 +491,7 @@ export function autocompleteUsersInTeam(username, success) {
} }
export function autocompleteUsers(username, success) { export function autocompleteUsers(username, success) {
autocompleteRedux(username)(dispatch, getState).then( UserActions.autocompleteRedux(username)(dispatch, getState).then(
(data) => { (data) => {
if (success) { if (success) {
success(data); success(data);
@@ -518,7 +501,7 @@ export function autocompleteUsers(username, success) {
} }
export function updateUser(user, type, success, error) { export function updateUser(user, type, success, error) {
updateMe(user)(dispatch, getState).then( UserActions.updateMe(user)(dispatch, getState).then(
(data) => { (data) => {
if (data && success) { if (data && success) {
success(data); success(data);
@@ -531,24 +514,20 @@ export function updateUser(user, type, success, error) {
} }
export function generateMfaSecret(success, error) { export function generateMfaSecret(success, error) {
Client.generateMfaSecret( UserActions.generateMfaSecret()(dispatch, getState).then(
(data) => { (data) => {
if (success) { if (data && success) {
success(data); success(data);
} } else if (data == null && error) {
}, const serverError = getState().requests.users.generateMfaSecret.error;
(err) => { error({id: serverError.server_error_id, ...serverError});
AsyncClient.dispatchError(err, 'generateMfaSecret');
if (error) {
error(err);
} }
} }
); );
} }
export function updateUserNotifyProps(props, success, error) { export function updateUserNotifyProps(props, success, error) {
updateMe({notify_props: props})(dispatch, getState).then( UserActions.updateMe({notify_props: props})(dispatch, getState).then(
(data) => { (data) => {
if (data && success) { if (data && success) {
success(data); success(data);
@@ -561,7 +540,7 @@ export function updateUserNotifyProps(props, success, error) {
} }
export function updateUserRoles(userId, newRoles, success, error) { export function updateUserRoles(userId, newRoles, success, error) {
updateUserRolesRedux(userId, newRoles)(dispatch, getState).then( UserActions.updateUserRolesRedux(userId, newRoles)(dispatch, getState).then(
(data) => { (data) => {
if (data && success) { if (data && success) {
success(data); success(data);
@@ -574,7 +553,7 @@ export function updateUserRoles(userId, newRoles, success, error) {
} }
export function activateMfa(code, success, error) { export function activateMfa(code, success, error) {
updateUserMfa(UserStore.getCurrentId(), true, code)(dispatch, getState).then( UserActions.updateUserMfa(UserStore.getCurrentId(), true, code)(dispatch, getState).then(
(data) => { (data) => {
if (data && success) { if (data && success) {
success(data); success(data);
@@ -587,7 +566,7 @@ export function activateMfa(code, success, error) {
} }
export function deactivateMfa(success, error) { export function deactivateMfa(success, error) {
updateUserMfa(UserStore.getCurrentId(), false)(dispatch, getState).then( UserActions.updateUserMfa(UserStore.getCurrentId(), false)(dispatch, getState).then(
(data) => { (data) => {
if (data && success) { if (data && success) {
success(data); success(data);
@@ -605,7 +584,7 @@ export function checkMfa(loginId, success, error) {
return; return;
} }
checkMfaRedux(loginId)(dispatch, getState).then( UserActions.checkMfaRedux(loginId)(dispatch, getState).then(
(data) => { (data) => {
if (data != null && success) { if (data != null && success) {
success(data); success(data);
@@ -618,20 +597,20 @@ export function checkMfa(loginId, success, error) {
} }
export function updateActive(userId, active, success, error) { export function updateActive(userId, active, success, error) {
Client.updateActive(userId, active, UserActions.updateUserActive(userId, active)(dispatch, getState).then(
(data) => { (data) => {
UserStore.saveProfile(data); if (data && success) {
if (success) {
success(data); success(data);
} else if (data == null && error) {
const serverError = getState().requests.users.updateUser.error;
error({id: serverError.server_error_id, ...serverError});
}
} }
},
error
); );
} }
export function updatePassword(userId, currentPassword, newPassword, success, error) { export function updatePassword(userId, currentPassword, newPassword, success, error) {
updateUserPassword(userId, currentPassword, newPassword)(dispatch, getState).then( UserActions.updateUserPassword(userId, currentPassword, newPassword)(dispatch, getState).then(
(data) => { (data) => {
if (data && success) { if (data && success) {
success(data); success(data);
@@ -644,76 +623,68 @@ export function updatePassword(userId, currentPassword, newPassword, success, er
} }
export function verifyEmail(token, success, error) { export function verifyEmail(token, success, error) {
Client.verifyEmail( UserActions.verifyUserEmail(token)(dispatch, getState).then(
token,
(data) => { (data) => {
if (success) { if (data && success) {
success(data); success(data);
} } else if (data == null && error) {
}, const serverError = getState().requests.users.verifyEmail.error;
(err) => { error({id: serverError.server_error_id, ...serverError});
if (error) {
error(err);
} }
} }
); );
} }
export function resetPassword(token, password, success, error) { export function resetPassword(token, password, success, error) {
Client.resetPassword( UserActions.resetUserPassword(token, password)(dispatch, getState).then(
token, (data) => {
password, if (data) {
() => {
browserHistory.push('/login?extra=' + ActionTypes.PASSWORD_CHANGE); browserHistory.push('/login?extra=' + ActionTypes.PASSWORD_CHANGE);
if (success) { if (success) {
success(); success(data);
} }
}, } else if (data == null && error) {
(err) => { const serverError = getState().requests.users.passwordReset.error;
if (error) { error({id: serverError.server_error_id, ...serverError});
error(err);
} }
} }
); );
} }
export function resendVerification(email, success, error) { export function resendVerification(email, success, error) {
Client.resendVerification( UserActions.sendVerificationEmail(email)(dispatch, getState).then(
email, (data) => {
() => { if (data && success) {
if (success) { success(data);
success(); } else if (data == null && error) {
} const serverError = getState().requests.users.verifyEmail.error;
}, error({id: serverError.server_error_id, ...serverError});
(err) => {
if (error) {
error(err);
} }
} }
); );
} }
export function loginById(userId, password, mfaToken, success, error) { export function loginById(userId, password, mfaToken, success, error) {
Client.loginById( UserActions.loginById(userId, password, mfaToken)(dispatch, getState).then(
userId, (ok) => {
password, if (ok && success) {
mfaToken, success();
() => { } else if (!ok && error) {
const serverError = getState().requests.users.login.error;
if (serverError.server_error_id === 'api.context.mfa_required.app_error') {
if (success) { if (success) {
success(); success();
} }
}, return;
(err) => { }
if (error) { error({id: serverError.server_error_id, ...serverError});
error(err);
} }
} }
); );
} }
export function createUserWithInvite(user, data, emailHash, inviteId, success, error) { export function createUserWithInvite(user, data, emailHash, inviteId, success, error) {
createUser(user, data, emailHash, inviteId)(dispatch, getState).then( UserActions.createUser(user, data, emailHash, inviteId)(dispatch, getState).then(
(resp) => { (resp) => {
if (resp && success) { if (resp && success) {
success(resp); success(resp);
@@ -726,7 +697,7 @@ export function createUserWithInvite(user, data, emailHash, inviteId, success, e
} }
export function webLogin(loginId, password, token, success, error) { export function webLogin(loginId, password, token, success, error) {
login(loginId, password, token)(dispatch, getState).then( UserActions.login(loginId, password, token)(dispatch, getState).then(
(ok) => { (ok) => {
if (ok && success) { if (ok && success) {
success(); success();
@@ -745,18 +716,19 @@ export function webLogin(loginId, password, token, success, error) {
} }
export function webLoginByLdap(loginId, password, token, success, error) { export function webLoginByLdap(loginId, password, token, success, error) {
Client.webLoginByLdap( UserActions.login(loginId, password, token, true)(dispatch, getState).then(
loginId, (ok) => {
password, if (ok && success) {
token, success();
(data) => { } else if (!ok && error) {
const serverError = getState().requests.users.login.error;
if (serverError.server_error_id === 'api.context.mfa_required.app_error') {
if (success) { if (success) {
success(data); success();
} }
}, return;
(err) => { }
if (error) { error({id: serverError.server_error_id, ...serverError});
error(err);
} }
} }
); );
@@ -792,24 +764,20 @@ export function deauthorizeOAuthApp(appId, success, error) {
} }
export function uploadProfileImage(userPicture, success, error) { export function uploadProfileImage(userPicture, success, error) {
Client.uploadProfileImage( UserActions.uploadProfileImage(Selectors.getCurrentUserId(getState()), userPicture)(dispatch, getState).then(
userPicture, (data) => {
() => { if (data && success) {
getMe()(dispatch, getState); success(data);
if (success) { } else if (data == null && error) {
success(); const serverError = getState().requests.users.updateUser.error;
} error({id: serverError.server_error_id, ...serverError});
},
(err) => {
if (error) {
error(err);
} }
} }
); );
} }
export function loadProfiles(page, perPage, success) { export function loadProfiles(page, perPage, success) {
getProfiles(page, perPage)(dispatch, getState).then( UserActions.getProfiles(page, perPage)(dispatch, getState).then(
(data) => { (data) => {
if (success) { if (success) {
success(data); success(data);
@@ -825,13 +793,13 @@ export function getMissingProfiles(ids) {
return; return;
} }
getProfilesByIds(missingIds)(dispatch, getState); UserActions.getProfilesByIds(missingIds)(dispatch, getState);
} }
export function loadMyTeamMembers() { export function loadMyTeamMembers() {
getMyTeamMembers()(dispatch, getState).then( getMyTeamMembers()(dispatch, getState).then(
() => { () => {
AsyncClient.getMyTeamsUnread(); getMyTeamUnreads()(dispatch, getState);
} }
); );
} }
@@ -839,7 +807,7 @@ export function loadMyTeamMembers() {
export function autoResetStatus() { export function autoResetStatus() {
return async (doDispatch, doGetState) => { return async (doDispatch, doGetState) => {
const {currentUserId} = getState().entities.users; const {currentUserId} = getState().entities.users;
const userStatus = await getStatus(currentUserId)(doDispatch, doGetState); const userStatus = await UserActions.getStatus(currentUserId)(doDispatch, doGetState);
if (!userStatus.manual) { if (!userStatus.manual) {
return userStatus; return userStatus;
@@ -848,7 +816,7 @@ export function autoResetStatus() {
const autoReset = getBool(getState(), PreferencesRedux.CATEGORY_AUTO_RESET_MANUAL_STATUS, currentUserId, false); const autoReset = getBool(getState(), PreferencesRedux.CATEGORY_AUTO_RESET_MANUAL_STATUS, currentUserId, false);
if (autoReset) { if (autoReset) {
setStatus({user_id: currentUserId, status: 'online'})(doDispatch, doGetState); UserActions.setStatus({user_id: currentUserId, status: 'online'})(doDispatch, doGetState);
return userStatus; return userStatus;
} }

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

@@ -12,7 +12,7 @@ import TeamStore from 'stores/team_store.jsx';
import Constants from 'utils/constants.jsx'; import Constants from 'utils/constants.jsx';
import {displayUsernameForUser} from 'utils/utils.jsx'; import {displayUsernameForUser} from 'utils/utils.jsx';
import Client from 'client/web_client.jsx'; import {Client4} from 'mattermost-redux/client';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
@@ -170,7 +170,7 @@ export default class AddUsersToTeam extends React.Component {
onClick={() => onAdd(option)} onClick={() => onAdd(option)}
> >
<ProfilePicture <ProfilePicture
src={`${Client.getUsersRoute()}/${option.id}/image?time=${option.last_picture_update}`} src={Client4.getProfilePictureUrl(option.id, option.last_picture_update)}
width='32' width='32'
height='32' height='32'
/> />

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

@@ -9,7 +9,7 @@ import {FormattedMessage} from 'react-intl';
import * as TeamActions from 'actions/team_actions.jsx'; import * as TeamActions from 'actions/team_actions.jsx';
import Client from 'client/web_client.jsx'; import {Client4} from 'mattermost-redux/client';
import LoadingScreen from 'components/loading_screen.jsx'; import LoadingScreen from 'components/loading_screen.jsx';
@@ -184,7 +184,7 @@ export default class ManageTeamsModal extends React.Component {
<div className='manage-teams__user'> <div className='manage-teams__user'>
<img <img
className='manage-teams__profile-picture' className='manage-teams__profile-picture'
src={Client.getProfilePictureUrl(user.id, user.last_picture_update)} src={Client4.getProfilePictureUrl(user.id, user.last_picture_update)}
/> />
<div className='manage-teams__info'> <div className='manage-teams__info'>
<div className='manage-teams__name'> <div className='manage-teams__name'>

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

@@ -51,6 +51,7 @@ export default class OAuthToEmail extends React.Component {
this.setState(state); this.setState(state);
oauthToEmail( oauthToEmail(
this.props.currentType,
this.props.email, this.props.email,
password, password,
null, null,

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

@@ -12,7 +12,7 @@ import TeamStore from 'stores/team_store.jsx';
import Constants from 'utils/constants.jsx'; import Constants from 'utils/constants.jsx';
import {displayUsernameForUser} from 'utils/utils.jsx'; import {displayUsernameForUser} from 'utils/utils.jsx';
import Client from 'client/web_client.jsx'; import {Client4} from 'mattermost-redux/client';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
@@ -227,7 +227,7 @@ export default class MoreDirectChannels extends React.Component {
onClick={() => onAdd(option)} onClick={() => onAdd(option)}
> >
<ProfilePicture <ProfilePicture
src={`${Client.getUsersRoute()}/${option.id}/image?time=${option.last_picture_update}`} src={Client4.getProfilePictureUrl(option.id, option.last_picture_update)}
status={`${UserStore.getStatus(option.id)}`} status={`${UserStore.getStatus(option.id)}`}
width='32' width='32'
height='32' height='32'

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

@@ -13,7 +13,7 @@ import ChannelInviteModal from 'components/channel_invite_modal';
import {openDirectChannelToUser} from 'actions/channel_actions.jsx'; import {openDirectChannelToUser} from 'actions/channel_actions.jsx';
import Client from 'client/web_client.jsx'; import {Client4} from 'mattermost-redux/client';
import * as Utils from 'utils/utils.jsx'; import * as Utils from 'utils/utils.jsx';
import Constants from 'utils/constants.jsx'; import Constants from 'utils/constants.jsx';
import {canManageMembers} from 'utils/channel_utils.jsx'; import {canManageMembers} from 'utils/channel_utils.jsx';
@@ -132,7 +132,7 @@ export default class PopoverListMembers extends React.Component {
key={'popover-member-' + i} key={'popover-member-' + i}
> >
<ProfilePicture <ProfilePicture
src={`${Client.getUsersRoute()}/${m.id}/image?time=${m.last_picture_update}`} src={Client4.getProfilePictureUrl(m.id, m.last_picture_update)}
width='26' width='26'
height='26' height='26'
/> />

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

@@ -1,9 +1,8 @@
import PropTypes from 'prop-types';
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import PreferenceStore from 'stores/preference_store.jsx'; import PreferenceStore from 'stores/preference_store.jsx';
import * as Utils from 'utils/utils.jsx'; import * as Utils from 'utils/utils.jsx';

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

@@ -5,7 +5,7 @@ import {
getCurrentUser, getCurrentUser,
getStatusForUserId getStatusForUserId
} from 'mattermost-redux/selectors/entities/users'; } from 'mattermost-redux/selectors/entities/users';
import {Client} from 'mattermost-redux/client'; import {Client4} from 'mattermost-redux/client';
import StatusDropdown from 'components/status_dropdown/status_dropdown.jsx'; import StatusDropdown from 'components/status_dropdown/status_dropdown.jsx';
@@ -13,7 +13,7 @@ function mapStateToProps(state) {
const currentUser = getCurrentUser(state); const currentUser = getCurrentUser(state);
const userId = currentUser.id; const userId = currentUser.id;
const lastPicUpdate = currentUser.last_picture_update; const lastPicUpdate = currentUser.last_picture_update;
const profilePicture = Client.getProfilePictureUrl(userId, lastPicUpdate); const profilePicture = Client4.getProfilePictureUrl(userId, lastPicUpdate);
const status = getStatusForUserId(state, currentUser.id); const status = getStatusForUserId(state, currentUser.id);
return { return {
userId, userId,

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

@@ -4884,7 +4884,7 @@ math-expression-evaluator@^1.2.14:
mattermost-redux@mattermost/mattermost-redux#webapp-master: mattermost-redux@mattermost/mattermost-redux#webapp-master:
version "0.0.1" version "0.0.1"
resolved "https://codeload.github.com/mattermost/mattermost-redux/tar.gz/dc9c164de3153a4c33922a8a3f996490e8949e02" resolved "https://codeload.github.com/mattermost/mattermost-redux/tar.gz/1ba6245017789943d286443b95fd75d651437df7"
dependencies: dependencies:
deep-equal "1.0.1" deep-equal "1.0.1"
harmony-reflect "1.5.1" harmony-reflect "1.5.1"
@@ -6048,7 +6048,7 @@ react-bootstrap@0.31.0:
uncontrollable "^4.1.0" uncontrollable "^4.1.0"
warning "^3.0.0" warning "^3.0.0"
react-color@^2.11.7: react-color@2.11.7:
version "2.11.7" version "2.11.7"
resolved "https://registry.yarnpkg.com/react-color/-/react-color-2.11.7.tgz#746465b75feda63c2567607dfbcb276fc954a5b7" resolved "https://registry.yarnpkg.com/react-color/-/react-color-2.11.7.tgz#746465b75feda63c2567607dfbcb276fc954a5b7"
dependencies: dependencies: