diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-06-19 13:55:47 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-06-19 10:55:47 -0700 |
commit | ef9326bcbb461b4f3265f75a9f738e67e58b88d1 (patch) | |
tree | 1d2abc5304be4df51762985753ede12749f3bf43 /webapp/actions/oauth_actions.jsx | |
parent | 1594cf8af102d0ffe7c62fc68004049e918a530a (diff) | |
download | chat-ef9326bcbb461b4f3265f75a9f738e67e58b88d1.tar.gz chat-ef9326bcbb461b4f3265f75a9f738e67e58b88d1.tar.bz2 chat-ef9326bcbb461b4f3265f75a9f738e67e58b88d1.zip |
Move integrations over to redux and v4 (#6679)
Diffstat (limited to 'webapp/actions/oauth_actions.jsx')
-rw-r--r-- | webapp/actions/oauth_actions.jsx | 68 |
1 files changed, 26 insertions, 42 deletions
diff --git a/webapp/actions/oauth_actions.jsx b/webapp/actions/oauth_actions.jsx index d7e033604..03508efc1 100644 --- a/webapp/actions/oauth_actions.jsx +++ b/webapp/actions/oauth_actions.jsx @@ -1,60 +1,44 @@ // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import Client from 'client/web_client.jsx'; -import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; -import Constants from 'utils/constants.jsx'; +import store from 'stores/redux_store.jsx'; +const dispatch = store.dispatch; +const getState = store.getState; -const ActionTypes = Constants.ActionTypes; +import * as IntegrationActions from 'mattermost-redux/actions/integrations'; -export function listOAuthApps(userId, onSuccess, onError) { - Client.listOAuthApps( +export function listOAuthApps(complete) { + IntegrationActions.getOAuthApps(0, 10000)(dispatch, getState).then( (data) => { - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_OAUTHAPPS, - userId, - oauthApps: data - }); - - if (onSuccess) { - onSuccess(data); + if (complete) { + complete(data); } - }, - onError + } ); } -export function deleteOAuthApp(id, userId, onSuccess, onError) { - Client.deleteOAuthApp( - id, - () => { - AppDispatcher.handleServerAction({ - type: ActionTypes.REMOVED_OAUTHAPP, - userId, - id - }); - - if (onSuccess) { - onSuccess(); +export function deleteOAuthApp(id, success, error) { + IntegrationActions.deleteOAuthApp(id)(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.integrations.deleteOAuthApp.error; + error({id: serverError.server_error_id, ...serverError}); } - }, - onError + } ); } -export function registerOAuthApp(app, onSuccess, onError) { - Client.registerOAuthApp( - app, +export function registerOAuthApp(app, success, error) { + IntegrationActions.addOAuthApp(app)(dispatch, getState).then( (data) => { - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_OAUTHAPP, - oauthApp: data - }); - - if (onSuccess) { - onSuccess(data); + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.integrations.addOAuthApp.error; + error({id: serverError.server_error_id, ...serverError}); } - }, - onError + } ); } |