Commit d8351c44 authored by Joram Wilander's avatar Joram Wilander Committed by Harrison Healey

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

parent 7c7b179f
......@@ -2,14 +2,15 @@
// See License.txt for license information.
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';
const dispatch = store.dispatch;
const getState = store.getState;
import {updateUserMfa, updateUserPassword} from 'mattermost-redux/actions/users';
import * as AdminActions from 'mattermost-redux/actions/admin';
import * as UserActions from 'mattermost-redux/actions/users';
export function saveConfig(config, success, error) {
AdminActions.updateConfig(config)(dispatch, getState).then(
......@@ -39,7 +40,7 @@ export function reloadConfig(success, error) {
}
export function adminResetMfa(userId, success, error) {
updateUserMfa(userId, false)(dispatch, getState).then(
UserActions.updateUserMfa(userId, false)(dispatch, getState).then(
(data) => {
if (data && success) {
success(data);
......@@ -117,7 +118,7 @@ export function recycleDatabaseConnection(success, error) {
}
export function adminResetPassword(userId, password, success, error) {
updateUserPassword(userId, '', password)(dispatch, getState).then(
UserActions.updateUserPassword(userId, '', password)(dispatch, getState).then(
(data) => {
if (data && success) {
success(data);
......@@ -193,60 +194,44 @@ export function allowOAuth2(params, success, error) {
}
export function emailToLdap(loginId, password, token, ldapId, ldapPassword, success, error) {
Client.emailToLdap(
loginId,
password,
token,
ldapId,
ldapPassword,
UserActions.switchEmailToLdap(loginId, password, ldapId, ldapPassword, token)(dispatch, getState).then(
(data) => {
if (success) {
if (data && success) {
success(data);
}
},
(err) => {
if (error) {
error(err);
} else if (data == null && error) {
const serverError = getState().requests.users.switchLogin.error;
error({id: serverError.server_error_id, ...serverError});
}
}
);
}
export function emailToOAuth(loginId, password, token, newType, success, error) {
Client.emailToOAuth(
loginId,
password,
token,
newType,
UserActions.switchEmailToOAuth(newType, loginId, password, token)(dispatch, getState).then(
(data) => {
if (success) {
if (data && success) {
success(data);
}
},
(err) => {
if (error) {
error(err);
} else if (data == null && error) {
const serverError = getState().requests.users.switchLogin.error;
error({id: serverError.server_error_id, ...serverError});
}
}
);
}
export function oauthToEmail(email, password, success, error) {
Client.oauthToEmail(
email,
password,
export function oauthToEmail(currentService, email, password, success, error) {
UserActions.switchOAuthToEmail(currentService, email, password)(dispatch, getState).then(
(data) => {
if (data.follow_link) {
browserHistory.push(data.follow_link);
}
if (success) {
success(data);
}
},
(err) => {
if (error) {
error(err);
if (data) {
if (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});
}
}
);
......
This diff is collapsed.
......@@ -12,7 +12,7 @@ import TeamStore from 'stores/team_store.jsx';
import Constants from 'utils/constants.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';
......@@ -170,7 +170,7 @@ export default class AddUsersToTeam extends React.Component {
onClick={() => onAdd(option)}
>
<ProfilePicture
src={`${Client.getUsersRoute()}/${option.id}/image?time=${option.last_picture_update}`}
src={Client4.getProfilePictureUrl(option.id, option.last_picture_update)}
width='32'
height='32'
/>
......
......@@ -9,7 +9,7 @@ import {FormattedMessage} from 'react-intl';
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';
......@@ -184,7 +184,7 @@ export default class ManageTeamsModal extends React.Component {
<div className='manage-teams__user'>
<img
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__name'>
......
......@@ -51,6 +51,7 @@ export default class OAuthToEmail extends React.Component {
this.setState(state);
oauthToEmail(
this.props.currentType,
this.props.email,
password,
null,
......
......@@ -12,7 +12,7 @@ import TeamStore from 'stores/team_store.jsx';
import Constants from 'utils/constants.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';
......@@ -227,7 +227,7 @@ export default class MoreDirectChannels extends React.Component {
onClick={() => onAdd(option)}
>
<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)}`}
width='32'
height='32'
......
......@@ -13,7 +13,7 @@ import ChannelInviteModal from 'components/channel_invite_modal';
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 Constants from 'utils/constants.jsx';
import {canManageMembers} from 'utils/channel_utils.jsx';
......@@ -132,7 +132,7 @@ export default class PopoverListMembers extends React.Component {
key={'popover-member-' + i}
>
<ProfilePicture
src={`${Client.getUsersRoute()}/${m.id}/image?time=${m.last_picture_update}`}
src={Client4.getProfilePictureUrl(m.id, m.last_picture_update)}
width='26'
height='26'
/>
......
import PropTypes from 'prop-types';
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import PreferenceStore from 'stores/preference_store.jsx';
import * as Utils from 'utils/utils.jsx';
......
......@@ -5,7 +5,7 @@ import {
getCurrentUser,
getStatusForUserId
} 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';
......@@ -13,7 +13,7 @@ function mapStateToProps(state) {
const currentUser = getCurrentUser(state);
const userId = currentUser.id;
const lastPicUpdate = currentUser.last_picture_update;
const profilePicture = Client.getProfilePictureUrl(userId, lastPicUpdate);
const profilePicture = Client4.getProfilePictureUrl(userId, lastPicUpdate);
const status = getStatusForUserId(state, currentUser.id);
return {
userId,
......
......@@ -4884,7 +4884,7 @@ math-expression-evaluator@^1.2.14:
mattermost-redux@mattermost/mattermost-redux#webapp-master:
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:
deep-equal "1.0.1"
harmony-reflect "1.5.1"
......@@ -6048,7 +6048,7 @@ react-bootstrap@0.31.0:
uncontrollable "^4.1.0"
warning "^3.0.0"
react-color@^2.11.7:
react-color@2.11.7:
version "2.11.7"
resolved "https://registry.yarnpkg.com/react-color/-/react-color-2.11.7.tgz#746465b75feda63c2567607dfbcb276fc954a5b7"
dependencies:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment