diff --git a/packages/nc-gui-v2/components/webhook/Editor.vue b/packages/nc-gui-v2/components/webhook/Editor.vue index c83fea2798..7551e1deb1 100644 --- a/packages/nc-gui-v2/components/webhook/Editor.vue +++ b/packages/nc-gui-v2/components/webhook/Editor.vue @@ -4,11 +4,6 @@ import { MetaInj } from '~/context' import { extractSdkResponseErrorMsg, fieldRequiredValidator } from '~/utils' import { inject, reactive, useApi, useNuxtApp } from '#imports' -interface Option { - label: string - value: string -} - const emit = defineEmits(['backToList', 'editOrAdd']) const { $e } = useNuxtApp() @@ -205,21 +200,27 @@ const validators = computed(() => { }) const { validate, validateInfos } = useForm(hook, validators) -function onNotTypeChange() { - hook.notification.payload = {} as any +function onNotTypeChange(reset = false) { + if (reset) { + hook.notification.payload = {} as Record + } if (hook.notification.type === 'Slack') { - slackChannels.value = (apps && apps?.Slack && apps.Slack.parsedInput) || [] + slackChannels.value = (apps.value && apps.value.Slack && apps.Slack.parsedInput) || [] } + if (hook.notification.type === 'Microsoft Teams') { - teamsChannels.value = (apps && apps['Microsoft Teams'] && apps['Microsoft Teams'].parsedInput) || [] + teamsChannels.value = (apps.value && apps.value['Microsoft Teams'] && apps.value['Microsoft Teams'].parsedInput) || [] } + if (hook.notification.type === 'Discord') { - discordChannels.value = (apps && apps.Discord && apps.Discord.parsedInput) || [] + discordChannels.value = (apps.value && apps.value.Discord && apps.value.Discord.parsedInput) || [] } + if (hook.notification.type === 'Mattermost') { - mattermostChannels.value = (apps && apps.Mattermost && apps.Mattermost.parsedInput) || [] + mattermostChannels.value = (apps.value && apps.value.Mattermost && apps.value.Mattermost.parsedInput) || [] } + if (hook.notification.type === 'URL') { hook.notification.payload.body = '{{ json data }}' hook.notification.payload.parameters = [{}] @@ -228,10 +229,6 @@ function onNotTypeChange() { } } -function filterOption(input: string, option: Option) { - return option.value.toUpperCase().includes(input.toUpperCase()) -} - function setHook(newHook: any) { Object.assign(hook, { ...newHook, @@ -301,6 +298,8 @@ async function loadPluginList() { if (hook.event && hook.operation) { hook.eventOperation = `${hook.event} ${hook.operation}` } + + onNotTypeChange() } catch (e: any) { message.error(await extractSdkResponseErrorMsg(e)) } @@ -383,8 +382,8 @@ watch( }, ) -onMounted(() => { - loadPluginList() +onMounted(async () => { + await loadPluginList() }) @@ -439,7 +438,7 @@ onMounted(() => { v-model:value="hook.notification.type" size="large" :placeholder="$t('general.notification')" - @change="onNotTypeChange" + @change="onNotTypeChange(true)" >
@@ -505,12 +504,12 @@ onMounted(() => { - @@ -519,12 +518,12 @@ onMounted(() => { - @@ -533,12 +532,12 @@ onMounted(() => { - @@ -547,12 +546,12 @@ onMounted(() => { -