Move remaining client functions in components to actions (#5171)

Этот коммит содержится в:
Carlos Tadeu Panato Junior
2017-01-27 11:39:13 +01:00
коммит произвёл George Goldberg
родитель 49c677f6b4
Коммит d72547433a
32 изменённых файлов: 708 добавлений и 141 удалений

404
webapp/actions/admin_actions.jsx Обычный файл
Просмотреть файл

@@ -0,0 +1,404 @@
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import Client from 'client/web_client.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import {browserHistory} from 'react-router/es6';
export function revokeSession(altId, success, error) {
Client.revokeSession(altId,
() => {
AsyncClient.getSessions();
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function saveConfig(config, success, error) {
Client.saveConfig(
config,
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function reloadConfig(success, error) {
Client.reloadConfig(
() => {
AsyncClient.getConfig();
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function adminResetMfa(userId, success, error) {
Client.adminResetMfa(
userId,
() => {
AsyncClient.getUser(userId);
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function getClusterStatus(success, error) {
Client.getClusterStatus(
(data) => {
if (success) {
success(data);
}
},
(err) => {
AsyncClient.dispatchError(err, 'getClusterStatus');
if (error) {
error(err);
}
}
);
}
export function saveComplianceReports(job, success, error) {
Client.saveComplianceReports(
job,
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function testEmail(config, success, error) {
Client.testEmail(
config,
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function ldapTest(success, error) {
Client.ldapTest(
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function invalidateAllCaches(success, error) {
Client.invalidateAllCaches(
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function recycleDatabaseConnection(success, error) {
Client.recycleDatabaseConnection(
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function adminResetPassword(userId, password, success, error) {
Client.adminResetPassword(
userId,
password,
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function samlCertificateStatus(success, error) {
Client.samlCertificateStatus(
(data) => {
if (success) {
success(data);
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function ldapSyncNow(success, error) {
Client.ldapSyncNow(
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function getOAuthAppInfo(clientId, success, error) {
Client.getOAuthAppInfo(
clientId,
(data) => {
if (success) {
success(data);
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function allowOAuth2(params, success, error) {
const responseType = params.response_type;
const clientId = params.client_id;
const redirectUri = params.redirect_uri;
const state = params.state;
const scope = params.scope;
Client.allowOAuth2(responseType, clientId, redirectUri, state, scope,
(data) => {
if (success) {
success(data);
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function emailToLdap(loginId, password, token, ldapId, ldapPassword, success, error) {
Client.emailToLdap(
loginId,
password,
token,
ldapId,
ldapPassword,
(data) => {
if (success) {
success(data);
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function emailToOAuth(loginId, password, token, newType, success, error) {
Client.emailToOAuth(
loginId,
password,
token,
newType,
(data) => {
if (success) {
success(data);
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function oauthToEmail(email, password, success, error) {
Client.oauthToEmail(
email,
password,
(data) => {
if (data.follow_link) {
browserHistory.push(data.follow_link);
}
if (success) {
success(data);
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function regenerateOAuthAppSecret(oauthAppId, success, error) {
Client.regenerateOAuthAppSecret(
oauthAppId,
(data) => {
if (success) {
success(data);
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function uploadBrandImage(brandImage, success, error) {
Client.uploadBrandImage(
brandImage,
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function uploadLicenseFile(file, success, error) {
Client.uploadLicenseFile(
file,
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function removeLicenseFile(success, error) {
Client.removeLicenseFile(
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function uploadCertificateFile(certificateFile, success, error) {
Client.uploadCertificateFile(
certificateFile,
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function removeCertificateFile(certificateId, success, error) {
Client.removeCertificateFile(
certificateId,
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}

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

@@ -417,3 +417,30 @@ export function deletePost(channelId, post, success, error) {
}
);
}
export function performSearch(terms, isMentionSearch, success, error) {
Client.search(
terms,
isMentionSearch,
(data) => {
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_SEARCH,
results: data,
is_mention_search: isMentionSearch
});
loadProfilesForPosts(data.posts);
if (success) {
success(data);
}
},
(err) => {
AsyncClient.dispatchError(err, 'search');
if (error) {
error(err);
}
}
);
}

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

@@ -60,7 +60,10 @@ export function removeUserFromTeam(teamId, userId, success, error) {
userId,
() => {
TeamStore.removeMemberInTeam(teamId, userId);
UserStore.removeProfileFromTeam(teamId, userId);
UserStore.emitInTeamChange();
AsyncClient.getUser(userId);
AsyncClient.getTeamStats(teamId);
if (success) {
success();

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

@@ -4,10 +4,12 @@
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import PreferenceStore from 'stores/preference_store.jsx';
import BrowserStore from 'stores/browser_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import {getChannelMembersForUserIds} from 'actions/channel_actions.jsx';
import {loadStatusesForProfilesList, loadStatusesForProfilesMap} from 'actions/status_actions.jsx';
@@ -17,7 +19,6 @@ import * as AsyncClient from 'utils/async_client.jsx';
import Client from 'client/web_client.jsx';
import {ActionTypes, Preferences} from 'utils/constants.jsx';
import {browserHistory} from 'react-router/es6';
export function switchFromLdapToEmail(email, password, token, ldapPassword, onSuccess, onError) {
@@ -512,6 +513,25 @@ export function activateMfa(code, success, error) {
);
}
export function deactivateMfa(success, error) {
Client.updateMfa(
'',
false,
() => {
AsyncClient.getMe();
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function checkMfa(loginId, success, error) {
if (global.window.mm_config.EnableMultifactorAuthentication !== 'true') {
success(false);
@@ -616,3 +636,138 @@ export function resendVerification(email, success, error) {
}
);
}
export function loginById(userId, password, mfaToken, hash, success, error) {
Client.loginById(
userId,
password,
mfaToken,
hash,
() => {
if (hash > 0) {
BrowserStore.setGlobalItem(hash, JSON.stringify({usedBefore: true}));
}
GlobalActions.emitInitialLoad(
() => {
const query = this.props.location.query;
if (query.redirect_to) {
browserHistory.push(query.redirect_to);
} else {
GlobalActions.redirectUserToDefaultTeam();
}
}
);
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function createUserWithInvite(user, data, emailHash, inviteId, success, error) {
Client.createUserWithInvite(
user,
data,
emailHash,
inviteId,
(response) => {
if (success) {
success(response);
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function webLogin(loginId, password, token, success, error) {
Client.webLogin(
loginId,
password,
token,
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function webLoginByLdap(loginId, password, token, success, error) {
Client.webLoginByLdap(
loginId,
password,
token,
(data) => {
if (success) {
success(data);
}
},
(err) => {
if (error) {
error(err);
}
}
);
}
export function getAuthorizedApps(success, error) {
Client.getAuthorizedApps(
(authorizedApps) => {
if (success) {
success(authorizedApps);
}
},
(err) => {
if (error) {
error(err);
}
});
}
export function deauthorizeOAuthApp(appId, success, error) {
Client.deauthorizeOAuthApp(
appId,
() => {
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
});
}
export function uploadProfileImage(userPicture, success, error) {
Client.uploadProfileImage(
userPicture,
() => {
AsyncClient.getMe();
if (success) {
success();
}
},
(err) => {
if (error) {
error(err);
}
}
);
}

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

@@ -4,6 +4,8 @@
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import {WebrtcActionTypes} from 'utils/constants.jsx';
import Client from 'client/web_client.jsx';
export function initWebrtc(userId, isCalling) {
AppDispatcher.handleServerAction({
type: WebrtcActionTypes.INITIALIZE,
@@ -18,3 +20,17 @@ export function handle(message) {
message
});
}
export function webrtcToken(success, error) {
Client.webrtcToken(
(data) => {
if (success) {
success(data);
}
},
() => {
if (error) {
error();
}
});
}

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

@@ -5,7 +5,6 @@ import LoadingScreen from './loading_screen.jsx';
import UserStore from 'stores/user_store.jsx';
import Client from 'client/web_client.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import * as Utils from 'utils/utils.jsx';
@@ -14,6 +13,8 @@ import React from 'react';
import {Modal} from 'react-bootstrap';
import {FormattedMessage, FormattedTime, FormattedDate} from 'react-intl';
import {revokeSession} from 'actions/admin_actions.jsx';
export default class ActivityLogModal extends React.Component {
constructor(props) {
super(props);
@@ -46,10 +47,8 @@ export default class ActivityLogModal extends React.Component {
setTimeout(() => {
modalContent.removeClass('animation--highlight');
}, 1500);
Client.revokeSession(altId,
() => {
AsyncClient.getSessions();
},
revokeSession(altId,
null,
(err) => {
const state = this.getStateFromStores();
state.serverError = err;

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

@@ -4,11 +4,12 @@
import React from 'react';
import * as AsyncClient from 'utils/async_client.jsx';
import Client from 'client/web_client.jsx';
import FormError from 'components/form_error.jsx';
import SaveButton from 'components/admin_console/save_button.jsx';
import {saveConfig} from 'actions/admin_actions.jsx';
export default class AdminSettings extends React.Component {
static get propTypes() {
return {
@@ -53,7 +54,7 @@ export default class AdminSettings extends React.Component {
let config = JSON.parse(JSON.stringify(this.props.config));
config = this.getConfigFromState(config);
Client.saveConfig(
saveConfig(
config,
() => {
AsyncClient.getConfig((savedConfig) => {

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

@@ -6,12 +6,10 @@ import ConfirmModal from '../confirm_modal.jsx';
import UserStore from 'stores/user_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import Client from 'client/web_client.jsx';
import Constants from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import {updateUserRoles, updateActive} from 'actions/user_actions.jsx';
import {updateTeamMemberRoles} from 'actions/team_actions.jsx';
import {updateTeamMemberRoles, removeUserFromTeam, adminResetMfa} from 'actions/team_actions.jsx';
import {FormattedMessage} from 'react-intl';
@@ -75,14 +73,10 @@ export default class AdminTeamMembersDropdown extends React.Component {
}
handleRemoveFromTeam() {
Client.removeUserFromTeam(
removeUserFromTeam(
this.props.teamMember.team_id,
this.props.user.id,
() => {
AsyncClient.getTeamStats(this.props.teamMember.team_id);
UserStore.removeProfileFromTeam(this.props.teamMember.team_id, this.props.user.id);
UserStore.emitInTeamChange();
},
null,
(err) => {
this.setState({serverError: err.message});
}
@@ -150,10 +144,8 @@ export default class AdminTeamMembersDropdown extends React.Component {
handleResetMfa(e) {
e.preventDefault();
Client.adminResetMfa(this.props.user.id,
() => {
AsyncClient.getUser(this.props.user.id);
},
adminResetMfa(this.props.user.id,
null,
(err) => {
this.setState({serverError: err.message});
}

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

@@ -7,6 +7,7 @@ import ReactDOM from 'react-dom';
import Client from 'client/web_client.jsx';
import * as Utils from 'utils/utils.jsx';
import {uploadBrandImage} from 'actions/admin_actions.jsx';
import FormError from 'components/form_error.jsx';
import {FormattedHTMLMessage, FormattedMessage} from 'react-intl';
@@ -81,7 +82,7 @@ export default class BrandImageSetting extends React.Component {
error: ''
});
Client.uploadBrandImage(
uploadBrandImage(
this.state.brandImage,
() => {
$(ReactDOM.findDOMNode(this.refs.upload)).button('complete');

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

@@ -4,8 +4,8 @@
import React from 'react';
import ClusterTable from './cluster_table.jsx';
import LoadingScreen from '../loading_screen.jsx';
import Client from 'client/web_client.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import {getClusterStatus} from 'actions/admin_actions.jsx';
export default class ClusterTableContainer extends React.Component {
constructor(props) {
@@ -19,15 +19,13 @@ export default class ClusterTableContainer extends React.Component {
}
load() {
Client.getClusterStatus(
getClusterStatus(
(data) => {
this.setState({
clusterInfos: data
});
},
(err) => {
AsyncClient.dispatchError(err, 'getClusterStatus');
}
null
);
}

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

@@ -9,6 +9,7 @@ import UserStore from '../../stores/user_store.jsx';
import Client from 'client/web_client.jsx';
import * as AsyncClient from '../../utils/async_client.jsx';
import {saveComplianceReports} from 'actions/admin_actions.jsx';
import {FormattedMessage, FormattedDate, FormattedTime} from 'react-intl';
@@ -72,7 +73,7 @@ export default class ComplianceReports extends React.Component {
job.start_at = Date.parse(ReactDOM.findDOMNode(this.refs.from).value);
job.end_at = Date.parse(ReactDOM.findDOMNode(this.refs.to).value);
Client.saveComplianceReports(
saveComplianceReports(
job,
() => {
ReactDOM.findDOMNode(this.refs.emails).value = '';

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

@@ -3,11 +3,12 @@
import React from 'react';
import Client from 'client/web_client.jsx';
import * as Utils from 'utils/utils.jsx';
import {FormattedMessage} from 'react-intl';
import {testEmail} from 'actions/admin_actions.jsx';
export default class EmailConnectionTestButton extends React.Component {
static get propTypes() {
return {
@@ -41,7 +42,7 @@ export default class EmailConnectionTestButton extends React.Component {
const config = JSON.parse(JSON.stringify(this.props.config));
this.props.getConfigFromState(config);
Client.testEmail(
testEmail(
config,
() => {
this.setState({

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

@@ -3,11 +3,12 @@
import React from 'react';
import Client from 'client/web_client.jsx';
import * as Utils from 'utils/utils.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import {ldapTest} from 'actions/admin_actions.jsx';
export default class LdapTestButton extends React.Component {
static get propTypes() {
return {
@@ -38,7 +39,7 @@ export default class LdapTestButton extends React.Component {
});
const doRequest = () => { //eslint-disable-line func-style
Client.ldapTest(
ldapTest(
() => {
this.setState({
buisy: false,

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

@@ -4,7 +4,8 @@
import $ from 'jquery';
import ReactDOM from 'react-dom';
import * as Utils from 'utils/utils.jsx';
import Client from 'client/web_client.jsx';
import {uploadLicenseFile, removeLicenseFile} from 'actions/admin_actions.jsx';
import {injectIntl, intlShape, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'react-intl';
@@ -54,7 +55,8 @@ class LicenseSettings extends React.Component {
$('#upload-button').button('loading');
Client.uploadLicenseFile(file,
uploadLicenseFile(
file,
() => {
Utils.clearFileInput(element[0]);
$('#upload-button').button('reset');
@@ -74,7 +76,7 @@ class LicenseSettings extends React.Component {
$('#remove-button').button('loading');
Client.removeLicenseFile(
removeLicenseFile(
() => {
$('#remove-button').button('reset');
this.setState({fileSelected: false, fileName: null, serverError: null});

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

@@ -3,10 +3,10 @@
import React from 'react';
import Client from 'client/web_client.jsx';
import {FormattedMessage} from 'react-intl';
import {invalidateAllCaches} from 'actions/admin_actions.jsx';
export default class PurgeCachesButton extends React.Component {
constructor(props) {
super(props);
@@ -27,7 +27,7 @@ export default class PurgeCachesButton extends React.Component {
fail: null
});
Client.invalidateAllCaches(
invalidateAllCaches(
() => {
this.setState({
loading: false

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

@@ -3,11 +3,12 @@
import React from 'react';
import Client from 'client/web_client.jsx';
import * as Utils from 'utils/utils.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import {recycleDatabaseConnection} from 'actions/admin_actions.jsx';
export default class RecycleDbButton extends React.Component {
constructor(props) {
super(props);
@@ -28,7 +29,7 @@ export default class RecycleDbButton extends React.Component {
fail: null
});
Client.recycleDatabaseConnection(
recycleDatabaseConnection(
() => {
this.setState({
loading: false

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

@@ -3,13 +3,12 @@
import React from 'react';
import Client from 'client/web_client.jsx';
import * as Utils from 'utils/utils.jsx';
import {getConfig} from 'utils/async_client.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import {reloadConfig} from 'actions/admin_actions.jsx';
export default class ReloadConfigButton extends React.Component {
constructor(props) {
super(props);
@@ -30,9 +29,8 @@ export default class ReloadConfigButton extends React.Component {
fail: null
});
Client.reloadConfig(
reloadConfig(
() => {
getConfig();
this.setState({
loading: false
});

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

@@ -1,12 +1,13 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import Client from 'client/web_client.jsx';
import * as Utils from 'utils/utils.jsx';
import {Modal} from 'react-bootstrap';
import {injectIntl, intlShape, FormattedMessage} from 'react-intl';
import {adminResetPassword} from 'actions/admin_actions.jsx';
import React from 'react';
class ResetPasswordModal extends React.Component {
@@ -32,7 +33,7 @@ class ResetPasswordModal extends React.Component {
}
this.setState({serverError: null});
Client.adminResetPassword(
adminResetPassword(
this.props.user.id,
password,
() => {

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

@@ -12,9 +12,10 @@ import RemoveFileSetting from './remove_file_setting.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import SettingsGroup from './settings_group.jsx';
import Client from 'client/web_client.jsx';
import * as Utils from 'utils/utils.jsx';
import {samlCertificateStatus, uploadCertificateFile, removeCertificateFile} from 'actions/admin_actions.jsx';
export default class SamlSettings extends AdminSettings {
constructor(props) {
super(props);
@@ -73,7 +74,7 @@ export default class SamlSettings extends AdminSettings {
}
componentWillMount() {
Client.samlCertificateStatus(
samlCertificateStatus(
(data) => {
const files = {};
if (!data.IdpCertificateFile) {
@@ -93,7 +94,7 @@ export default class SamlSettings extends AdminSettings {
}
uploadCertificate(id, file, callback) {
Client.uploadCertificateFile(
uploadCertificateFile(
file,
() => {
const fileName = file.name;
@@ -112,7 +113,7 @@ export default class SamlSettings extends AdminSettings {
}
removeCertificate(id, callback) {
Client.removeCertificateFile(
removeCertificateFile(
this.state[id],
() => {
this.handleChange(id, '');

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

@@ -3,11 +3,12 @@
import React from 'react';
import Client from 'client/web_client.jsx';
import * as Utils from 'utils/utils.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import {ldapSyncNow} from 'actions/admin_actions.jsx';
export default class SyncNowButton extends React.Component {
static get propTypes() {
return {
@@ -33,7 +34,7 @@ export default class SyncNowButton extends React.Component {
fail: null
});
Client.ldapSyncNow(
ldapSyncNow(
() => {
this.setState({
buisy: false

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

@@ -1,7 +1,6 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import Client from 'client/web_client.jsx';
import FormError from 'components/form_error.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
@@ -9,6 +8,8 @@ import React from 'react';
import icon50 from 'images/icon50x50.png';
import {getOAuthAppInfo, allowOAuth2} from 'actions/admin_actions.jsx';
export default class Authorize extends React.Component {
static get propTypes() {
return {
@@ -27,7 +28,7 @@ export default class Authorize extends React.Component {
}
componentWillMount() {
Client.getOAuthAppInfo(
getOAuthAppInfo(
this.props.location.query.client_id,
(app) => {
this.setState({app});
@@ -46,7 +47,7 @@ export default class Authorize extends React.Component {
handleAllow() {
const params = this.props.location.query;
Client.allowOAuth2(params.response_type, params.client_id, params.redirect_uri, params.state, params.scope,
allowOAuth2(params,
(data) => {
if (data.redirect) {
window.location.href = data.redirect;

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

@@ -4,9 +4,9 @@
import LoginMfa from 'components/login/components/login_mfa.jsx';
import * as Utils from 'utils/utils.jsx';
import Client from 'client/web_client.jsx';
import {checkMfa} from 'actions/user_actions.jsx';
import {emailToLdap} from 'actions/admin_actions.jsx';
import React from 'react';
import {FormattedMessage} from 'react-intl';
@@ -79,7 +79,7 @@ export default class EmailToLDAP extends React.Component {
}
submit(loginId, password, token, ldapId, ldapPassword) {
Client.emailToLdap(
emailToLdap(
loginId,
password,
token,

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

@@ -4,10 +4,10 @@
import LoginMfa from 'components/login/components/login_mfa.jsx';
import * as Utils from 'utils/utils.jsx';
import Client from 'client/web_client.jsx';
import Constants from 'utils/constants.jsx';
import {checkMfa} from 'actions/user_actions.jsx';
import {emailToOAuth} from 'actions/admin_actions.jsx';
import React from 'react';
import ReactDOM from 'react-dom';
@@ -55,7 +55,7 @@ export default class EmailToOAuth extends React.Component {
}
submit(loginId, password, token) {
Client.emailToOAuth(
emailToOAuth(
loginId,
password,
token,

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

@@ -2,13 +2,13 @@
// See License.txt for license information.
import * as Utils from 'utils/utils.jsx';
import Client from 'client/web_client.jsx';
import Constants from 'utils/constants.jsx';
import React from 'react';
import ReactDOM from 'react-dom';
import {FormattedMessage} from 'react-intl';
import {browserHistory} from 'react-router/es6';
import {oauthToEmail} from 'actions/admin_actions.jsx';
export default class OAuthToEmail extends React.Component {
constructor(props) {
@@ -48,14 +48,10 @@ export default class OAuthToEmail extends React.Component {
state.error = null;
this.setState(state);
Client.oauthToEmail(
oauthToEmail(
this.props.email,
password,
(data) => {
if (data.follow_link) {
browserHistory.push(data.follow_link);
}
},
null,
(err) => {
this.setState({error: err.message});
}

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

@@ -5,10 +5,10 @@ import React from 'react';
import FormError from 'components/form_error.jsx';
import Client from 'client/web_client.jsx';
import * as Utils from 'utils/utils.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import {regenerateOAuthAppSecret} from 'actions/admin_actions.jsx';
const FAKE_SECRET = '***************';
@@ -49,7 +49,7 @@ export default class InstalledOAuthApp extends React.Component {
handleRegenerate(e) {
e.preventDefault();
Client.regenerateOAuthAppSecret(
regenerateOAuthAppSecret(
this.props.oauthApp.id,
(data) => {
this.props.oauthApp.client_secret = data.client_secret;

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

@@ -7,6 +7,7 @@ import FormError from 'components/form_error.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import {addUserToTeamFromInvite} from 'actions/team_actions.jsx';
import {checkMfa, webLogin} from 'actions/user_actions.jsx';
import BrowserStore from 'stores/browser_store.jsx';
import UserStore from 'stores/user_store.jsx';
@@ -119,29 +120,25 @@ export default class LoginController extends React.Component {
return;
}
if (global.window.mm_config.EnableMultifactorAuthentication === 'true') {
Client.checkMfa(
loginId,
(data) => {
if (data.mfa_required === 'true') {
this.setState({showMfa: true});
} else {
this.submit(loginId, password, '');
}
},
(err) => {
this.setState({serverError: err.message});
checkMfa(
loginId,
(data) => {
if (data && data.mfa_required === 'true') {
this.setState({showMfa: true});
} else {
this.submit(loginId, password, '');
}
);
} else {
this.submit(loginId, password, '');
}
},
(err) => {
this.setState({serverError: err.message});
}
);
}
submit(loginId, password, token) {
this.setState({serverError: null, loading: true});
Client.webLogin(
webLogin(
loginId,
password,
token,

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

@@ -2,8 +2,6 @@
// See License.txt for license information.
import $ from 'jquery';
import Client from 'client/web_client.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import SearchStore from 'stores/search_store.jsx';
import UserStore from 'stores/user_store.jsx';
@@ -14,7 +12,7 @@ import SearchSuggestionList from './suggestion/search_suggestion_list.jsx';
import SearchUserProvider from './suggestion/search_user_provider.jsx';
import * as Utils from 'utils/utils.jsx';
import Constants from 'utils/constants.jsx';
import {loadProfilesForPosts, getFlaggedPosts} from 'actions/post_actions.jsx';
import {getFlaggedPosts, performSearch} from 'actions/post_actions.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
@@ -118,26 +116,18 @@ export default class SearchBar extends React.Component {
if (terms.length) {
this.setState({isSearching: true});
Client.search(
performSearch(
terms,
isMentionSearch,
(data) => {
() => {
this.setState({isSearching: false});
if (Utils.isMobile() && this.search) {
this.search.value = '';
}
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_SEARCH,
results: data,
is_mention_search: isMentionSearch
});
loadProfilesForPosts(data.posts);
},
(err) => {
() => {
this.setState({isSearching: false});
AsyncClient.dispatchError(err, 'search');
}
);
}

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

@@ -6,11 +6,9 @@ import LoadingScreen from 'components/loading_screen.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import {track} from 'actions/analytics_actions.jsx';
import {getInviteInfo} from 'actions/team_actions.jsx';
import BrowserStore from 'stores/browser_store.jsx';
import {loginById, createUserWithInvite} from 'actions/user_actions.jsx';
import * as Utils from 'utils/utils.jsx';
import Client from 'client/web_client.jsx';
import Constants from 'utils/constants.jsx';
import React from 'react';
@@ -119,26 +117,12 @@ export default class SignupEmail extends React.Component {
handleSignupSuccess(user, data) {
track('signup', 'signup_user_02_complete');
Client.loginById(
loginById(
data.id,
user.password,
'',
() => {
if (this.state.hash > 0) {
BrowserStore.setGlobalItem(this.state.hash, JSON.stringify({usedBefore: true}));
}
GlobalActions.emitInitialLoad(
() => {
const query = this.props.location.query;
if (query.redirect_to) {
browserHistory.push(query.redirect_to);
} else {
GlobalActions.redirectUserToDefaultTeam();
}
}
);
},
this.state.hash,
null,
(err) => {
if (err.id === 'api.user.login.not_verified.app_error') {
browserHistory.push('/should_verify_email?email=' + encodeURIComponent(user.email) + '&teamname=' + encodeURIComponent(this.state.teamName));
@@ -242,7 +226,7 @@ export default class SignupEmail extends React.Component {
allow_marketing: true
};
Client.createUserWithInvite(user,
createUserWithInvite(user,
this.state.data,
this.state.hash,
this.state.inviteId,

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

@@ -6,9 +6,9 @@ import FormError from 'components/form_error.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import {track} from 'actions/analytics_actions.jsx';
import {addUserToTeamFromInvite} from 'actions/team_actions.jsx';
import {webLoginByLdap} from 'actions/user_actions.jsx';
import * as Utils from 'utils/utils.jsx';
import Client from 'client/web_client.jsx';
import React from 'react';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
@@ -56,7 +56,7 @@ export default class SignupLdap extends React.Component {
this.setState({ldapError: ''});
Client.webLoginByLdap(
webLoginByLdap(
this.state.ldapId,
this.state.ldapPassword,
null,

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

@@ -15,7 +15,7 @@ import * as AsyncClient from 'utils/async_client.jsx';
import * as Utils from 'utils/utils.jsx';
import {intlShape, injectIntl, defineMessages, FormattedMessage, FormattedHTMLMessage, FormattedDate} from 'react-intl';
import {updateUser} from 'actions/user_actions.jsx';
import {updateUser, uploadProfileImage} from 'actions/user_actions.jsx';
const holders = defineMessages({
usernameReserved: {
@@ -241,11 +241,11 @@ class UserSettingsGeneralTab extends React.Component {
this.setState({loadingPicture: true});
Client.uploadProfileImage(picture,
uploadProfileImage(
picture,
() => {
this.updateSection('');
this.submitActive = false;
AsyncClient.getMe();
},
(err) => {
var state = this.setupInitialState(this.props);

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

@@ -9,12 +9,11 @@ import ToggleModalButton from '../toggle_modal_button.jsx';
import PreferenceStore from 'stores/preference_store.jsx';
import Client from 'client/web_client.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import * as Utils from 'utils/utils.jsx';
import Constants from 'utils/constants.jsx';
import {updatePassword} from 'actions/user_actions.jsx';
import {updatePassword, getAuthorizedApps, deactivateMfa, deauthorizeOAuthApp} from 'actions/user_actions.jsx';
import $ from 'jquery';
import React from 'react';
@@ -29,7 +28,7 @@ export default class SecurityTab extends React.Component {
this.submitPassword = this.submitPassword.bind(this);
this.setupMfa = this.setupMfa.bind(this);
this.deactivateMfa = this.deactivateMfa.bind(this);
this.removeMfa = this.removeMfa.bind(this);
this.updateCurrentPassword = this.updateCurrentPassword.bind(this);
this.updateNewPassword = this.updateNewPassword.bind(this);
this.updateConfirmPassword = this.updateConfirmPassword.bind(this);
@@ -55,7 +54,7 @@ export default class SecurityTab extends React.Component {
componentDidMount() {
if (global.mm_config.EnableOAuthServiceProvider === 'true') {
Client.getAuthorizedApps(
getAuthorizedApps(
(authorizedApps) => {
this.setState({authorizedApps, serverError: null}); //eslint-disable-line react/no-did-mount-set-state
},
@@ -120,10 +119,8 @@ export default class SecurityTab extends React.Component {
browserHistory.push('/mfa/setup');
}
deactivateMfa() {
Client.updateMfa(
'',
false,
removeMfa() {
deactivateMfa(
() => {
if (global.window.mm_license.MFA === 'true' &&
global.window.mm_config.EnableMultifactorAuthentication === 'true' &&
@@ -133,7 +130,6 @@ export default class SecurityTab extends React.Component {
}
this.props.updateSection('');
AsyncClient.getMe();
this.setState(this.getDefaultState());
},
(err) => {
@@ -163,7 +159,7 @@ export default class SecurityTab extends React.Component {
deauthorizeApp(e) {
e.preventDefault();
const appId = e.currentTarget.getAttribute('data-app');
Client.deauthorizeOAuthApp(
deauthorizeOAuthApp(
appId,
() => {
const authorizedApps = this.state.authorizedApps.filter((app) => {
@@ -223,7 +219,7 @@ export default class SecurityTab extends React.Component {
<a
className='btn btn-primary'
href='#'
onClick={this.deactivateMfa}
onClick={this.removeMfa}
>
{mfaButtonText}
</a>

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

@@ -644,7 +644,7 @@ export default class WebrtcController extends React.Component {
}
onConnectCall() {
Client.webrtcToken(
WebrtcActions.webrtcToken(
(info) => {
const connectingMsg = (
<FormattedMessage