diff --git a/packages/nc-gui-v2/components/webhook/Editor.vue b/packages/nc-gui-v2/components/webhook/Editor.vue index a728c40d8d..9c464210be 100644 --- a/packages/nc-gui-v2/components/webhook/Editor.vue +++ b/packages/nc-gui-v2/components/webhook/Editor.vue @@ -30,7 +30,7 @@ const meta = inject(MetaInj) const useForm = Form.useForm -const formState = reactive({ +const hook = reactive({ title: '', notification: { type: 'URL', @@ -39,7 +39,7 @@ const formState = reactive({ method: 'GET', }) -const apps = ref({}) +const apps: Record = ref() const slackChannels = ref() @@ -145,10 +145,7 @@ const formInput = ref({ ], }) -const notification = ref({ - method: 'POST', - body: '{{ json data }}', -}) +const notification = ref({}) const eventList = ref([ { @@ -195,10 +192,27 @@ const validators = computed(() => { 'method': [fieldRequiredValidator], } }) -const { resetFields, validate, validateInfos } = useForm(formState, validators) +const { resetFields, validate, validateInfos } = useForm(hook, validators) function onNotTypeChange() { - // TODO + notification.value = {} + + if (hook.notification.type === 'Slack') { + slackChannels.value = (apps && apps?.Slack && apps.Slack.parsedInput) || [] + } + if (hook.notification.type === 'Microsoft Teams') { + teamsChannels.value = (apps && apps['Microsoft Teams'] && apps['Microsoft Teams'].parsedInput) || [] + } + if (hook.notification.type === 'Discord') { + discordChannels.value = (apps && apps.Discord && apps.Discord.parsedInput) || [] + } + if (hook.notification.type === 'Mattermost') { + mattermostChannels.value = (apps && apps.Mattermost && apps.Mattermost.parsedInput) || [] + } + if (hook.notification.type === 'URL') { + notification.value = notification.value || {} + notification.value.body = '{{ json data }}' + } } function filterOption(input: string, option: Option) { @@ -245,19 +259,19 @@ onMounted(() => { - + - + - + {{ event.title }} @@ -267,7 +281,7 @@ onMounted(() => { { - + - + {{ method.title }} - + - + { - + { - + { - + { - - + + @@ -368,8 +382,8 @@ onMounted(() => { - On Condition - + On Condition + @@ -396,10 +410,10 @@ onMounted(() => {