From 015fba1455b37f52185c35d526c0c1001b28c367 Mon Sep 17 00:00:00 2001 From: mdshamoon Date: Thu, 24 Jun 2021 12:02:36 +0530 Subject: [PATCH 1/3] added function in webhook node --- .../routers/webhook/WebhookRouterForm.tsx | 25 ++++++++++++++----- .../flow/routers/webhook/helpers.ts | 12 +++++---- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/components/flow/routers/webhook/WebhookRouterForm.tsx b/src/components/flow/routers/webhook/WebhookRouterForm.tsx index 0c55ec37b..6796ddd9e 100644 --- a/src/components/flow/routers/webhook/WebhookRouterForm.tsx +++ b/src/components/flow/routers/webhook/WebhookRouterForm.tsx @@ -208,10 +208,15 @@ export default class WebhookRouterForm extends React.Component< private handleSave(): void { // validate our url in case they haven't interacted - const valid = this.handleUpdate( - { url: this.state.url.value, resultName: this.state.resultName.value }, - true - ); + let valid = false; + if (this.state.method.value.name === 'FUNCTION') { + valid = this.handleUpdate({ resultName: this.state.resultName.value }, true); + } else { + valid = this.handleUpdate( + { url: this.state.url.value, resultName: this.state.resultName.value }, + true + ); + } if (valid) { this.props.updateRouter(stateToNode(this.props.nodeSettings, this.state)); @@ -325,9 +330,17 @@ export default class WebhookRouterForm extends React.Component<
{ + method === 'FUNCTION' + ? this.setState({ url: { value: url } }) + : this.handleUrlUpdate(url, name); + }} autocomplete={true} />
diff --git a/src/components/flow/routers/webhook/helpers.ts b/src/components/flow/routers/webhook/helpers.ts index f8f99d9e5..42b69cd33 100644 --- a/src/components/flow/routers/webhook/helpers.ts +++ b/src/components/flow/routers/webhook/helpers.ts @@ -15,7 +15,8 @@ export enum Methods { PUT = 'PUT', DELETE = 'DELETE', HEAD = 'HEAD', - PATCH = 'PATCH' + PATCH = 'PATCH', + FUNCTION = 'FUNCTION' } export interface MethodOption { @@ -35,10 +36,11 @@ export const GET_METHOD: MethodOption = { export const METHOD_OPTIONS: MethodOption[] = [ GET_METHOD, { value: Methods.POST, name: Methods.POST }, - { value: Methods.PUT, name: Methods.PUT }, - { value: Methods.DELETE, name: Methods.DELETE }, - { value: Methods.HEAD, name: Methods.HEAD }, - { value: Methods.PATCH, name: Methods.PATCH } + // { value: Methods.PUT, name: Methods.PUT }, + // { value: Methods.DELETE, name: Methods.DELETE }, // These methods are not needed currently + // { value: Methods.HEAD, name: Methods.HEAD }, + { value: Methods.PATCH, name: Methods.PATCH }, + { value: Methods.FUNCTION, name: Methods.FUNCTION } ]; export const getOriginalAction = (settings: NodeEditorSettings): CallWebhook => { From 1ac5625588d46531fa7d27368723604f0a2a20c9 Mon Sep 17 00:00:00 2001 From: mdshamoon Date: Thu, 24 Jun 2021 12:10:37 +0530 Subject: [PATCH 2/3] updated package --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6533f2113..b93d90baa 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@glific/flow-editor", "license": "AGPL-3.0", "repository": "git://github.com/glific/floweditor.git", - "version": "1.13.9-2", + "version": "1.13.9-3", "description": "'Standalone flow editing tool designed for use within the RapidPro suite of messaging tools but can be adopted for use outside of that ecosystem.'", "browser": "umd/flow-editor.min.js", "unpkg": "umd/flow-editor.min.js", From c4946f92e78896cb768222ce3bb238b108f04e15 Mon Sep 17 00:00:00 2001 From: mdshamoon Date: Thu, 24 Jun 2021 12:11:50 +0530 Subject: [PATCH 3/3] updated package --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b93d90baa..70588ce37 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "license": "AGPL-3.0", "repository": "git://github.com/glific/floweditor.git", "version": "1.13.9-3", - "description": "'Standalone flow editing tool designed for use within the RapidPro suite of messaging tools but can be adopted for use outside of that ecosystem.'", + "description": "'Standalone flow editing tool designed for use within the Glific suite of messaging tools'", "browser": "umd/flow-editor.min.js", "unpkg": "umd/flow-editor.min.js", "homepage": "https://glific.org",