Browse Source

feat(gui-v2): testWebhook

pull/2838/head
Wing-Kam Wong 2 years ago
parent
commit
1cd4b2da8e
  1. 26
      packages/nc-gui-v2/components/webhook/Test.vue

26
packages/nc-gui-v2/components/webhook/Test.vue

@ -1,6 +1,8 @@
<script setup lang="ts">
import { onMounted } from '@vue/runtime-core'
import { useToast } from 'vue-toastification'
import { MetaInj } from '~/context'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
interface Props {
hook: Record<string, any>
@ -9,8 +11,11 @@ interface Props {
const { hook } = defineProps<Props>()
const { $state, $api, $e } = useNuxtApp()
const toast = useToast()
const meta = inject(MetaInj)
const isVisible = ref(false)
const sampleData = ref({
data: {},
user: {},
@ -31,6 +36,23 @@ async function loadSampleData() {
}
}
async function testWebhook() {
try {
await $api.dbTableWebhook.test(meta?.value.id as string, {
hook,
payload: sampleData.value,
})
toast.success('Webhook tested successfully')
} catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e))
}
}
defineExpose({
testWebhook,
})
onMounted(async () => {
await loadSampleData()
})
@ -39,7 +61,7 @@ onMounted(async () => {
<template>
<a-collapse v-model:activeKey="activeKey" ghost>
<a-collapse-panel key="1" header="Sample Payload">
<!-- TODO: need changes from Quick Import PR -->
<!-- TODO: set lang -->
<MonacoEditor v-model="sampleData" class="min-h-60 max-h-80" />
</a-collapse-panel>
</a-collapse>

Loading…
Cancel
Save