From f9e30cde6df4218ca032700745ad81a08c78571d Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Mon, 26 Sep 2022 13:42:49 +0200 Subject: [PATCH] fix(nc-gui): webhooks drawer --- packages/nc-gui/components/webhook/Drawer.vue | 13 ++--- packages/nc-gui/components/webhook/Editor.vue | 58 ++++++++++++------- 2 files changed, 44 insertions(+), 27 deletions(-) diff --git a/packages/nc-gui/components/webhook/Drawer.vue b/packages/nc-gui/components/webhook/Drawer.vue index d63b474c03..35eb278c6b 100644 --- a/packages/nc-gui/components/webhook/Drawer.vue +++ b/packages/nc-gui/components/webhook/Drawer.vue @@ -1,4 +1,6 @@ @@ -34,7 +33,7 @@ async function editHook(hook: Record) { > - + diff --git a/packages/nc-gui/components/webhook/Editor.vue b/packages/nc-gui/components/webhook/Editor.vue index 5ac405705f..61e302cba9 100644 --- a/packages/nc-gui/components/webhook/Editor.vue +++ b/packages/nc-gui/components/webhook/Editor.vue @@ -4,18 +4,27 @@ import type { AuditType } from 'nocodb-sdk' import { Form, MetaInj, + computed, extractSdkResponseErrorMsg, fieldRequiredValidator, inject, message, onMounted, reactive, + ref, useApi, useI18n, useNuxtApp, + watch, } from '#imports' -const emit = defineEmits(['backToList', 'editOrAdd']) +interface Props { + hook?: Record +} + +const props = defineProps() + +const emit = defineEmits(['backToList']) const { t } = useI18n() @@ -155,16 +164,13 @@ const formInput = ref({ ], }) -const eventList = ref([ - // {text: ["Before", "Insert"], value: ['before', 'insert']}, +const eventList = [ { text: ['After', 'Insert'], value: ['after', 'insert'] }, - // {text: ["Before", "Update"], value: ['before', 'update']}, { text: ['After', 'Update'], value: ['after', 'update'] }, - // {text: ["Before", "Delete"], value: ['before', 'delete']}, { text: ['After', 'Delete'], value: ['after', 'delete'] }, -]) +] -const notificationList = ref([ +const notificationList = [ { type: 'URL' }, { type: 'Email' }, { type: 'Slack' }, @@ -173,16 +179,16 @@ const notificationList = ref([ { type: 'Mattermost' }, { type: 'Twilio' }, { type: 'Whatsapp Twilio' }, -]) +] -const methodList = ref([ +const methodList = [ { title: 'GET' }, { title: 'POST' }, { title: 'DELETE' }, { title: 'PUT' }, { title: 'HEAD' }, { title: 'PATCH' }, -]) +] const validators = computed(() => { return { @@ -386,11 +392,6 @@ async function testWebhook() { await webhookTestRef.value.testWebhook() } -defineExpose({ - onEventChange, - setHook, -}) - watch( () => hook.eventOperation, () => { @@ -402,9 +403,18 @@ watch( }, ) -onMounted(async () => { - await loadPluginList() -}) +watch( + () => props.hook, + () => { + if (props.hook) { + setHook(props.hook) + onEventChange() + } + }, + { immediate: true }, +) + +onMounted(loadPluginList)