diff --git a/packages/nc-gui/components/webhook/Editor.vue b/packages/nc-gui/components/webhook/Editor.vue index c4460eb914..c79cf2e85f 100644 --- a/packages/nc-gui/components/webhook/Editor.vue +++ b/packages/nc-gui/components/webhook/Editor.vue @@ -9,6 +9,7 @@ import { fieldRequiredValidator, iconMap, inject, + isEeUI, message, onMounted, parseProp, @@ -19,7 +20,6 @@ import { useI18n, useNuxtApp, watch, - isEeUI } from '#imports' import { extractNextDefaultName } from '~/helpers/parsers/parserHelpers' @@ -65,7 +65,7 @@ let hookRef = reactive< type: 'URL', payload: { method: 'POST', - body: '{{ json data }}', + body: '{{ json event }}', headers: [{}], parameters: [{}], path: '', @@ -76,9 +76,10 @@ let hookRef = reactive< version: 'v2', }) +const isBodyShownEasterEgg = ref(false) const isBodyShown = ref(hookRef.version === 'v1' || isEeUI) -const urlTabKey = ref(isBodyShown.value ? 'body' : 'params') +const urlTabKey = ref(isBodyShownEasterEgg.value && isBodyShown.value ? 'body' : 'params') const apps: Record = ref() @@ -302,7 +303,8 @@ function onNotificationTypeChange(reset = false) { } if (hookRef.notification.type === 'URL') { - hookRef.notification.payload.body = hookRef.notification.payload.body || '{{ json data }}' + const body = hookRef.notification.payload.body + hookRef.notification.payload.body = body ? (body === '{{ json data }}' ? '{{ json event }}' : body) : '{{ json event }}' hookRef.notification.payload.parameters = hookRef.notification.payload.parameters || [{}] hookRef.notification.payload.headers = hookRef.notification.payload.headers || [{}] hookRef.notification.payload.method = hookRef.notification.payload.method || 'POST' @@ -655,6 +657,7 @@ onMounted(async () => { size="large" class="nc-select-hook-url-method" dropdown-class-name="nc-dropdown-hook-notification-url-method" + @dblclick="isBodyShownEasterEgg = !isBodyShownEasterEgg" >
@@ -684,7 +687,7 @@ onMounted(async () => { - + { -
+
{{ $t('msg.webhookBodyMsg1') }} {{ $t('msg.webhookBodyMsg2') }} diff --git a/packages/nocodb/src/helpers/webhookHelpers.ts b/packages/nocodb/src/helpers/webhookHelpers.ts index 5b884486c1..3fb111cc62 100644 --- a/packages/nocodb/src/helpers/webhookHelpers.ts +++ b/packages/nocodb/src/helpers/webhookHelpers.ts @@ -30,6 +30,7 @@ export function parseBody(template: string, data: any): string { return Handlebars.compile(template, { noEscape: true })({ data, + event: data, }); }