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/utils/async_client.jsx | 46 +++++++++++++++++++++++++++++++++++++++++++ webapp/utils/constants.jsx | 1 + 2 files changed, 47 insertions(+) (limited to 'webapp/utils') diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx index d47e45eb9..e1449e3c5 100644 --- a/webapp/utils/async_client.jsx +++ b/webapp/utils/async_client.jsx @@ -1324,6 +1324,29 @@ export function addIncomingHook(hook, success, error) { ); } +export function updateIncomingHook(hook, success, error) { + Client.updateIncomingHook( + hook, + (data) => { + AppDispatcher.handleServerAction({ + type: ActionTypes.UPDATED_INCOMING_WEBHOOK, + incomingWebhook: data + }); + + if (success) { + success(data); + } + }, + (err) => { + if (error) { + error(err); + } else { + dispatchError(err, 'updateIncomingHook'); + } + } + ); +} + export function addOutgoingHook(hook, success, error) { Client.addOutgoingHook( hook, @@ -1347,6 +1370,29 @@ export function addOutgoingHook(hook, success, error) { ); } +export function updateOutgoingHook(hook, success, error) { + Client.updateOutgoingHook( + hook, + (data) => { + AppDispatcher.handleServerAction({ + type: ActionTypes.UPDATED_OUTGOING_WEBHOOK, + outgoingWebhook: data + }); + + if (success) { + success(data); + } + }, + (err) => { + if (error) { + error(err); + } else { + dispatchError(err, 'updateOutgoingHook'); + } + } + ); +} + export function deleteIncomingHook(id) { Client.deleteIncomingHook( id, diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index 130e116a9..68b6f2cc0 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -105,6 +105,7 @@ export const ActionTypes = keyMirror({ RECEIVED_INCOMING_WEBHOOKS: null, RECEIVED_INCOMING_WEBHOOK: null, + UPDATED_INCOMING_WEBHOOK: null, REMOVED_INCOMING_WEBHOOK: null, RECEIVED_OUTGOING_WEBHOOKS: null, RECEIVED_OUTGOING_WEBHOOK: null, -- cgit v1.2.3-1-g7c22