From bb13476326b81191ba4aa854c25224638735272c Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Mon, 28 Mar 2016 16:17:17 -0400 Subject: Added delete buttons to InstalledIntegrations --- webapp/stores/integration_store.jsx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'webapp/stores') diff --git a/webapp/stores/integration_store.jsx b/webapp/stores/integration_store.jsx index b875c29e6..bf9f9ba85 100644 --- a/webapp/stores/integration_store.jsx +++ b/webapp/stores/integration_store.jsx @@ -51,6 +51,15 @@ class IntegrationStore extends EventEmitter { this.incomingWebhooks.push(incomingWebhook); } + removeIncomingWebhook(id) { + for (let i = 0; i < this.incomingWebhooks.length; i++) { + if (this.incomingWebhooks[i].id === id) { + this.incomingWebhooks.splice(i, 1); + break; + } + } + } + hasReceivedOutgoingWebhooks() { return this.receivedIncomingWebhooks; } @@ -68,6 +77,15 @@ class IntegrationStore extends EventEmitter { this.outgoingWebhooks.push(outgoingWebhook); } + removeOutgoingWebhook(id) { + for (let i = 0; i < this.outgoingWebhooks.length; i++) { + if (this.outgoingWebhooks[i].id === id) { + this.outgoingWebhooks.splice(i, 1); + break; + } + } + } + handleEventPayload(payload) { const action = payload.action; @@ -80,6 +98,10 @@ class IntegrationStore extends EventEmitter { this.addIncomingWebhook(action.incomingWebhook); this.emitChange(); break; + case ActionTypes.REMOVED_INCOMING_WEBHOOK: + this.removeIncomingWebhook(action.id); + this.emitChange(); + break; case ActionTypes.RECEIVED_OUTGOING_WEBHOOKS: this.setOutgoingWebhooks(action.outgoingWebhooks); this.emitChange(); @@ -88,6 +110,10 @@ class IntegrationStore extends EventEmitter { this.addOutgoingWebhook(action.outgoingWebhook); this.emitChange(); break; + case ActionTypes.REMOVED_OUTGOING_WEBHOOK: + this.removeOutgoingWebhook(action.id); + this.emitChange(); + break; } } } -- cgit v1.2.3-1-g7c22