summaryrefslogtreecommitdiffstats
path: root/webapp/stores/integration_store.jsx
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-04-05 09:29:01 -0400
committerChristopher Speller <crspeller@gmail.com>2016-04-05 09:29:01 -0400
commitb3edd32aee47a0b123870de58664600acc17087b (patch)
tree41840177672480ff428f279437a5a08a6eccaeb6 /webapp/stores/integration_store.jsx
parentc12d997f248c143b7746d07a3c2ce9b58a3ecd5e (diff)
downloadchat-b3edd32aee47a0b123870de58664600acc17087b.tar.gz
chat-b3edd32aee47a0b123870de58664600acc17087b.tar.bz2
chat-b3edd32aee47a0b123870de58664600acc17087b.zip
PLT-1750 Moved slash commands to backstage
* Added slash commands to InstalledIntegrations page * Reset installed integration type filter if there is no longer any integrations of the selected type * Added pages to backstage to add slash commands * Cleaned up internationalization for slash commands * Added ability to regen slash command tokens from backstage * Removed Integrations tab from UserSettings
Diffstat (limited to 'webapp/stores/integration_store.jsx')
-rw-r--r--webapp/stores/integration_store.jsx61
1 files changed, 59 insertions, 2 deletions
diff --git a/webapp/stores/integration_store.jsx b/webapp/stores/integration_store.jsx
index abd7e3558..d321edec2 100644
--- a/webapp/stores/integration_store.jsx
+++ b/webapp/stores/integration_store.jsx
@@ -20,6 +20,9 @@ class IntegrationStore extends EventEmitter {
this.outgoingWebhooks = [];
this.receivedOutgoingWebhooks = false;
+
+ this.commands = [];
+ this.receivedCommands = false;
}
addChangeListener(callback) {
@@ -61,7 +64,7 @@ class IntegrationStore extends EventEmitter {
}
hasReceivedOutgoingWebhooks() {
- return this.receivedIncomingWebhooks;
+ return this.receivedOutgoingWebhooks;
}
getOutgoingWebhooks() {
@@ -95,6 +98,41 @@ class IntegrationStore extends EventEmitter {
}
}
+ hasReceivedCommands() {
+ return this.receivedCommands;
+ }
+
+ getCommands() {
+ return this.commands;
+ }
+
+ setCommands(commands) {
+ this.commands = commands;
+ this.receivedCommands = true;
+ }
+
+ addCommand(command) {
+ this.commands.push(command);
+ }
+
+ updateCommand(command) {
+ for (let i = 0; i < this.commands.length; i++) {
+ if (this.commands[i].id === command.id) {
+ this.commands[i] = command;
+ break;
+ }
+ }
+ }
+
+ removeCommand(id) {
+ for (let i = 0; i < this.commands.length; i++) {
+ if (this.commands[i].id === id) {
+ this.commands.splice(i, 1);
+ break;
+ }
+ }
+ }
+
handleEventPayload(payload) {
const action = payload.action;
@@ -127,8 +165,27 @@ class IntegrationStore extends EventEmitter {
this.removeOutgoingWebhook(action.id);
this.emitChange();
break;
+ case ActionTypes.RECEIVED_COMMANDS:
+ this.setCommands(action.commands);
+ this.emitChange();
+ break;
+ case ActionTypes.RECEIVED_COMMAND:
+ this.addCommand(action.command);
+ this.emitChange();
+ break;
+ case ActionTypes.UPDATED_COMMAND:
+ this.updateCommand(action.command);
+ this.emitChange();
+ break;
+ case ActionTypes.REMOVED_COMMAND:
+ this.removeCommand(action.id);
+ this.emitChange();
+ break;
}
}
}
-export default new IntegrationStore();
+const instance = new IntegrationStore();
+export default instance;
+window.IntegrationStore = instance;
+