Browse Source

Merge pull request #5530 from nocodb/feat/webhook-body-edit

feat: webhook body edit
pull/5581/head
Raju Udava 2 years ago committed by GitHub
parent
commit
14881f2b00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      packages/nc-gui/components/webhook/Editor.vue
  2. 3
      packages/nocodb-nest/src/helpers/webhookHelpers.ts
  3. 1
      packages/nocodb-nest/src/schema/swagger.json
  4. 3
      packages/nocodb-nest/src/services/hooks.service.ts
  5. 6
      tests/playwright/setup/index.ts

8
packages/nc-gui/components/webhook/Editor.vue

@ -66,7 +66,9 @@ const hook = reactive<
version: 'v2',
})
const urlTabKey = ref('params')
const isBodyShown = ref(hook.version === 'v1' || (hook.version === 'v2' && appInfo.ee))
const urlTabKey = ref(isBodyShown.value ? 'body' : 'params')
const apps: Record<string, any> = ref()
@ -596,7 +598,7 @@ onMounted(async () => {
<a-col :span="24">
<a-tabs v-model:activeKey="urlTabKey" type="card" closeable="false" class="shadow-sm">
<a-tab-pane v-if="hook.version === 'v1'" key="body" tab="Body">
<a-tab-pane v-if="isBodyShown" key="body" tab="Body">
<LazyMonacoEditor
v-model="hook.notification.payload.body"
disable-deep-compare
@ -716,7 +718,7 @@ onMounted(async () => {
<a-row>
<a-col :span="24">
<div v-if="!(hook.version === 'v2' && hook.notification.type === 'URL')" class="text-gray-600">
<div v-if="isBodyShown" class="text-gray-600">
<div class="flex items-center">
<em>Use context variable <strong>data</strong> to refer the record under consideration</em>

3
packages/nocodb-nest/src/helpers/webhookHelpers.ts

@ -1,6 +1,7 @@
import Handlebars from 'handlebars';
import { v4 as uuidv4 } from 'uuid';
import { Filter, HookLog } from '../models';
import Noco from '../Noco';
import NcPluginMgrv2 from './NcPluginMgrv2';
import type { Column, FormView, Hook, Model, View } from '../models';
import type { HookLogType } from 'nocodb-sdk';
@ -135,7 +136,7 @@ export async function validateCondition(filters: Filter[], data: any) {
}
export function constructWebHookData(hook, model, view, prevData, newData) {
if (hook.version === 'v2') {
if (hook.version === 'v2' && !Noco.isEE()) {
// extend in the future - currently only support records
const scope = 'records';

1
packages/nocodb-nest/src/schema/swagger.json

@ -17087,7 +17087,6 @@
"description": "The license key",
"example": "1234567890",
"maxLength": 255,
"minLength": 10,
"type": "string"
}
},

3
packages/nocodb-nest/src/services/hooks.service.ts

@ -8,6 +8,7 @@ import {
} from '../helpers/populateSamplePayload';
import { invokeWebhook } from '../helpers/webhookHelpers';
import { Hook, HookLog, Model } from '../models';
import Noco from '../Noco';
import type { HookReqType, HookTestReqType, HookType } from 'nocodb-sdk';
@Injectable()
@ -107,7 +108,7 @@ export class HooksService {
}) {
const model = await Model.getByIdOrName({ id: param.tableId });
if (param.version === 'v1') {
if (param.version === 'v1' || (param.version === 'v2' && Noco.isEE())) {
return await populateSamplePayload(model, false, param.operation);
}
return await populateSamplePayloadV2(model, false, param.operation);

6
tests/playwright/setup/index.ts

@ -48,6 +48,12 @@ const setup = async ({ page, isEmptyProject }: { page: Page; isEmptyProject?: bo
}
const token = response.data.token;
try {
await axios.post(`http://localhost:8080/api/v1/license`, { key: '' }, { headers: { 'xc-auth': token } });
} catch (e) {
console.error(`Error resetting project: ${process.env.TEST_PARALLEL_INDEX}`, e);
}
await page.addInitScript(
async ({ token }) => {
try {

Loading…
Cancel
Save