Browse Source

fix(nc-gui): webhook editor type issues

pull/5307/head
Wing-Kam Wong 2 years ago
parent
commit
1a407e150b
  1. 22
      packages/nc-gui/components/webhook/Editor.vue

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

@ -18,9 +18,10 @@ import {
useNuxtApp, useNuxtApp,
watch, watch,
} from '#imports' } from '#imports'
import { HookType } from 'nocodb-sdk'
interface Props { interface Props {
hook?: Record<string, any> hook?: HookType
} }
const props = defineProps<Props>() const props = defineProps<Props>()
@ -39,11 +40,13 @@ const meta = inject(MetaInj, ref())
const useForm = Form.useForm const useForm = Form.useForm
const hook = reactive<Record<string, any>>({ const hook = reactive<
Omit<HookType, 'notification'> & { notification: Record<string, any>; eventOperation: string; condition: boolean }
>({
id: '', id: '',
title: '', title: '',
event: '', event: undefined,
operation: '', operation: undefined,
eventOperation: '', eventOperation: '',
notification: { notification: {
type: 'URL', type: 'URL',
@ -256,12 +259,13 @@ function onNotTypeChange(reset = false) {
} }
} }
function setHook(newHook: any) { function setHook(newHook: HookType) {
const notification = newHook.notification as Record<string, any>
Object.assign(hook, { Object.assign(hook, {
...newHook, ...newHook,
notification: { notification: {
...newHook.notification, ...notification,
payload: newHook.notification.payload, payload: notification.payload,
}, },
}) })
} }
@ -400,8 +404,8 @@ watch(
if (!hook.eventOperation) return if (!hook.eventOperation) return
const [event, operation] = hook.eventOperation.split(' ') const [event, operation] = hook.eventOperation.split(' ')
hook.event = event hook.event = event as HookType['event']
hook.operation = operation hook.operation = operation as HookType['operation']
}, },
) )

Loading…
Cancel
Save