From 19b753467d37209f2227567637e60138d05dd405 Mon Sep 17 00:00:00 2001 From: Poornima Date: Mon, 27 Feb 2017 00:18:20 +0530 Subject: Adding edit of incoming webhook (#5272) Adding edit of outgoing webhook Fixing spelling of error Fixing style Changing from PUT to POST for updates Fixing test failures due to merge --- webapp/stores/integration_store.jsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'webapp/stores') diff --git a/webapp/stores/integration_store.jsx b/webapp/stores/integration_store.jsx index 33680452b..34da3751a 100644 --- a/webapp/stores/integration_store.jsx +++ b/webapp/stores/integration_store.jsx @@ -57,6 +57,20 @@ class IntegrationStore extends EventEmitter { this.setIncomingWebhooks(teamId, incomingWebhooks); } + updateIncomingWebhook(incomingWebhook) { + const teamId = incomingWebhook.team_id; + const incomingWebhooks = this.getIncomingWebhooks(teamId); + + for (let i = 0; i < incomingWebhooks.length; i++) { + if (incomingWebhooks[i].id === incomingWebhook.id) { + incomingWebhooks[i] = incomingWebhook; + break; + } + } + + this.setIncomingWebhooks(teamId, incomingWebhooks); + } + removeIncomingWebhook(teamId, id) { let incomingWebhooks = this.getIncomingWebhooks(teamId); @@ -200,6 +214,10 @@ class IntegrationStore extends EventEmitter { this.addIncomingWebhook(action.incomingWebhook); this.emitChange(); break; + case ActionTypes.UPDATED_INCOMING_WEBHOOK: + this.updateIncomingWebhook(action.incomingWebhook); + this.emitChange(); + break; case ActionTypes.REMOVED_INCOMING_WEBHOOK: this.removeIncomingWebhook(action.teamId, action.id); this.emitChange(); -- cgit v1.2.3-1-g7c22