mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-24 04:59:13 +00:00
feat(Webhook Node): Setting to enable multiple outputs/methods (#9086)
Co-authored-by: Giulio Andreini <andreini@netseven.it>
This commit is contained in:
@@ -28,9 +28,7 @@
|
||||
>
|
||||
<div v-if="isWebhookMethodVisible(webhook)" class="webhook-wrapper">
|
||||
<div class="http-field">
|
||||
<div class="http-method">
|
||||
{{ workflowHelpers.getWebhookExpressionValue(webhook, 'httpMethod') }}<br />
|
||||
</div>
|
||||
<div class="http-method">{{ getWebhookHttpMethod(webhook) }}<br /></div>
|
||||
</div>
|
||||
<div class="url-field">
|
||||
<div class="webhook-url left-ellipsis clickable" @click="copyWebhookUrl(webhook)">
|
||||
@@ -195,12 +193,27 @@ export default defineComponent({
|
||||
return '';
|
||||
},
|
||||
isWebhookMethodVisible(webhook: IWebhookDescription): boolean {
|
||||
try {
|
||||
const method = this.workflowHelpers.getWebhookExpressionValue(webhook, 'httpMethod', false);
|
||||
if (Array.isArray(method) && method.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
} catch (error) {}
|
||||
|
||||
if (typeof webhook.ndvHideMethod === 'string') {
|
||||
return !this.workflowHelpers.getWebhookExpressionValue(webhook, 'ndvHideMethod');
|
||||
}
|
||||
|
||||
return !webhook.ndvHideMethod;
|
||||
},
|
||||
|
||||
getWebhookHttpMethod(webhook: IWebhookDescription): string {
|
||||
const method = this.workflowHelpers.getWebhookExpressionValue(webhook, 'httpMethod', false);
|
||||
if (Array.isArray(method)) {
|
||||
return method[0];
|
||||
}
|
||||
return method;
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -225,10 +225,17 @@ export default defineComponent({
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return this.workflowHelpers.getWebhookExpressionValue(
|
||||
const httpMethod = this.workflowHelpers.getWebhookExpressionValue(
|
||||
this.nodeType.webhooks[0],
|
||||
'httpMethod',
|
||||
false,
|
||||
);
|
||||
|
||||
if (Array.isArray(httpMethod)) {
|
||||
return httpMethod.join(', ');
|
||||
}
|
||||
|
||||
return httpMethod;
|
||||
},
|
||||
webhookTestUrl(): string | undefined {
|
||||
if (!this.node || !this.nodeType?.webhooks?.length) {
|
||||
|
||||
@@ -738,12 +738,21 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute
|
||||
return nodeData;
|
||||
}
|
||||
|
||||
function getWebhookExpressionValue(webhookData: IWebhookDescription, key: string): string {
|
||||
function getWebhookExpressionValue(
|
||||
webhookData: IWebhookDescription,
|
||||
key: string,
|
||||
stringify = true,
|
||||
): string {
|
||||
if (webhookData[key] === undefined) {
|
||||
return 'empty';
|
||||
}
|
||||
try {
|
||||
return resolveExpression(webhookData[key] as string) as string;
|
||||
return resolveExpression(
|
||||
webhookData[key] as string,
|
||||
undefined,
|
||||
undefined,
|
||||
stringify,
|
||||
) as string;
|
||||
} catch (e) {
|
||||
return i18n.baseText('nodeWebhooks.invalidExpression');
|
||||
}
|
||||
@@ -785,6 +794,7 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute
|
||||
c?: number;
|
||||
additionalKeys?: IWorkflowDataProxyAdditionalKeys;
|
||||
} = {},
|
||||
stringifyObject = true,
|
||||
) {
|
||||
const parameters = {
|
||||
__xxxxxxx__: expression,
|
||||
@@ -796,7 +806,7 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute
|
||||
}
|
||||
|
||||
const obj = returnData.__xxxxxxx__;
|
||||
if (typeof obj === 'object') {
|
||||
if (typeof obj === 'object' && stringifyObject) {
|
||||
const proxy = obj as { isProxy: boolean; toJSON?: () => unknown } | null;
|
||||
if (proxy?.isProxy && proxy.toJSON) return JSON.stringify(proxy.toJSON());
|
||||
const workflow = getCurrentWorkflow();
|
||||
|
||||
Reference in New Issue
Block a user