summaryrefslogtreecommitdiffstats
path: root/webapp/actions
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2017-01-27 11:39:13 +0100
committerGeorge Goldberg <george@gberg.me>2017-01-27 10:39:13 +0000
commitd72547433af3ec5829ce0de4f4e1cfd440be7142 (patch)
tree6bd7664e9058468842c7b7bb7c7a76abf1b7c5e3 /webapp/actions
parent49c677f6b46409289210abc0e0bda63735be3e9f (diff)
downloadchat-d72547433af3ec5829ce0de4f4e1cfd440be7142.tar.gz
chat-d72547433af3ec5829ce0de4f4e1cfd440be7142.tar.bz2
chat-d72547433af3ec5829ce0de4f4e1cfd440be7142.zip
Move remaining client functions in components to actions (#5171)
Diffstat (limited to 'webapp/actions')
-rw-r--r--webapp/actions/admin_actions.jsx404
-rw-r--r--webapp/actions/post_actions.jsx27
-rw-r--r--webapp/actions/team_actions.jsx3
-rw-r--r--webapp/actions/user_actions.jsx157
-rw-r--r--webapp/actions/webrtc_actions.jsx16
5 files changed, 606 insertions, 1 deletions
diff --git a/webapp/actions/admin_actions.jsx b/webapp/actions/admin_actions.jsx
new file mode 100644
index 000000000..73b73c130
--- /dev/null
+++ b/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);
+ }
+ }
+ );
+}
diff --git a/webapp/actions/post_actions.jsx b/webapp/actions/post_actions.jsx
index 3f660b94d..61f193b66 100644
--- a/webapp/actions/post_actions.jsx
+++ b/webapp/actions/post_actions.jsx
@@ -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);
+ }
+ }
+ );
+}
diff --git a/webapp/actions/team_actions.jsx b/webapp/actions/team_actions.jsx
index 941ea880d..e23fe1e5d 100644
--- a/webapp/actions/team_actions.jsx
+++ b/webapp/actions/team_actions.jsx
@@ -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();
diff --git a/webapp/actions/user_actions.jsx b/webapp/actions/user_actions.jsx
index 09148c3f2..73a84a7c6 100644
--- a/webapp/actions/user_actions.jsx
+++ b/webapp/actions/user_actions.jsx
@@ -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);
+ }
+ }
+ );
+}
diff --git a/webapp/actions/webrtc_actions.jsx b/webapp/actions/webrtc_actions.jsx
index 444eee241..b096e1c33 100644
--- a/webapp/actions/webrtc_actions.jsx
+++ b/webapp/actions/webrtc_actions.jsx
@@ -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();
+ }
+ });
+}