summaryrefslogtreecommitdiffstats
path: root/webapp/stores/integration_store.jsx
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-08-03 12:19:27 -0500
committerHarrison Healey <harrisonmhealey@gmail.com>2016-08-03 13:19:27 -0400
commit5bc3cea6fe4a909735753692d0c4cd960e8ab516 (patch)
tree85715d9fcbc146a9672d84c9a1ea1e96b6e71231 /webapp/stores/integration_store.jsx
parentea027c8de44d44b6ac4e66ab802e675d315b0be5 (diff)
downloadchat-5bc3cea6fe4a909735753692d0c4cd960e8ab516.tar.gz
chat-5bc3cea6fe4a909735753692d0c4cd960e8ab516.tar.bz2
chat-5bc3cea6fe4a909735753692d0c4cd960e8ab516.zip
PLT-3484 OAuth2 Service Provider (#3632)
* PLT-3484 OAuth2 Service Provider * PM text review for OAuth 2.0 Service Provider * PLT-3484 OAuth2 Service Provider UI tweaks (#3668) * Tweaks to help text * Pushing OAuth improvements (#3680) * Re-arrange System Console for OAuth 2.0 Provider
Diffstat (limited to 'webapp/stores/integration_store.jsx')
-rw-r--r--webapp/stores/integration_store.jsx43
1 files changed, 43 insertions, 0 deletions
diff --git a/webapp/stores/integration_store.jsx b/webapp/stores/integration_store.jsx
index 454e6290b..a23b9d206 100644
--- a/webapp/stores/integration_store.jsx
+++ b/webapp/stores/integration_store.jsx
@@ -20,6 +20,8 @@ class IntegrationStore extends EventEmitter {
this.outgoingWebhooks = new Map();
this.commands = new Map();
+
+ this.oauthApps = new Map();
}
addChangeListener(callback) {
@@ -149,6 +151,35 @@ class IntegrationStore extends EventEmitter {
this.setCommands(teamId, commands);
}
+ hasReceivedOAuthApps(userId) {
+ return this.oauthApps.has(userId);
+ }
+
+ getOAuthApps(userId) {
+ return this.oauthApps.get(userId) || [];
+ }
+
+ setOAuthApps(userId, oauthApps) {
+ this.oauthApps.set(userId, oauthApps);
+ }
+
+ addOAuthApp(oauthApp) {
+ const userId = oauthApp.creator_id;
+ const oauthApps = this.getOAuthApps(userId);
+
+ oauthApps.push(oauthApp);
+
+ this.setOAuthApps(userId, oauthApps);
+ }
+
+ removeOAuthApp(userId, id) {
+ let apps = this.getOAuthApps(userId);
+
+ apps = apps.filter((app) => app.id !== id);
+
+ this.setOAuthApps(userId, apps);
+ }
+
handleEventPayload(payload) {
const action = payload.action;
@@ -197,6 +228,18 @@ class IntegrationStore extends EventEmitter {
this.removeCommand(action.teamId, action.id);
this.emitChange();
break;
+ case ActionTypes.RECEIVED_OAUTHAPPS:
+ this.setOAuthApps(action.userId, action.oauthApps);
+ this.emitChange();
+ break;
+ case ActionTypes.RECEIVED_OAUTHAPP:
+ this.addOAuthApp(action.oauthApp);
+ this.emitChange();
+ break;
+ case ActionTypes.REMOVED_OAUTHAPP:
+ this.removeOAuthApp(action.userId, action.id);
+ this.emitChange();
+ break;
}
}
}