mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08:00
feat(n8n Form Trigger Node): Option to remove attribution (#9162)
This commit is contained in:
parent
85780eade5
commit
699fd70c24
|
@ -78,6 +78,7 @@ describe('n8n Form Trigger', () => {
|
||||||
|
|
||||||
//add optional submitted message
|
//add optional submitted message
|
||||||
cy.get('.param-options').click();
|
cy.get('.param-options').click();
|
||||||
|
getVisibleSelect().find('span').contains('Form Response').click();
|
||||||
cy.contains('span', 'Text to Show')
|
cy.contains('span', 'Text to Show')
|
||||||
.should('exist')
|
.should('exist')
|
||||||
.parent()
|
.parent()
|
||||||
|
|
|
@ -354,6 +354,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{#if appendAttribution}}
|
||||||
<div class='n8n-link'>
|
<div class='n8n-link'>
|
||||||
<a href={{n8nWebsiteLink}} target='_blank'>
|
<a href={{n8nWebsiteLink}} target='_blank'>
|
||||||
Form automated with
|
Form automated with
|
||||||
|
@ -385,6 +386,8 @@
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#if redirectUrl}}
|
{{#if redirectUrl}}
|
||||||
<a id='redirectUrl' href='{{redirectUrl}}' style='display: none;'></a>
|
<a id='redirectUrl' href='{{redirectUrl}}' style='display: none;'></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -30,4 +30,5 @@ export type FormTriggerData = {
|
||||||
n8nWebsiteLink: string;
|
n8nWebsiteLink: string;
|
||||||
formFields: FormTriggerInput[];
|
formFields: FormTriggerInput[];
|
||||||
useResponseData?: boolean;
|
useResponseData?: boolean;
|
||||||
|
appendAttribution?: boolean;
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,6 +10,7 @@ export const prepareFormData = (
|
||||||
testRun: boolean,
|
testRun: boolean,
|
||||||
instanceId?: string,
|
instanceId?: string,
|
||||||
useResponseData?: boolean,
|
useResponseData?: boolean,
|
||||||
|
appendAttribution = true,
|
||||||
) => {
|
) => {
|
||||||
const validForm = formFields.length > 0;
|
const validForm = formFields.length > 0;
|
||||||
const utm_campaign = instanceId ? `&utm_campaign=${instanceId}` : '';
|
const utm_campaign = instanceId ? `&utm_campaign=${instanceId}` : '';
|
||||||
|
@ -28,6 +29,7 @@ export const prepareFormData = (
|
||||||
n8nWebsiteLink,
|
n8nWebsiteLink,
|
||||||
formFields: [],
|
formFields: [],
|
||||||
useResponseData,
|
useResponseData,
|
||||||
|
appendAttribution,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (redirectUrl) {
|
if (redirectUrl) {
|
||||||
|
@ -90,6 +92,7 @@ export async function formWebhook(context: IWebhookFunctions) {
|
||||||
|
|
||||||
let formSubmittedText;
|
let formSubmittedText;
|
||||||
let redirectUrl;
|
let redirectUrl;
|
||||||
|
let appendAttribution = true;
|
||||||
|
|
||||||
if (options.respondWithOptions) {
|
if (options.respondWithOptions) {
|
||||||
const values = (options.respondWithOptions as IDataObject).values as IDataObject;
|
const values = (options.respondWithOptions as IDataObject).values as IDataObject;
|
||||||
|
@ -103,6 +106,10 @@ export async function formWebhook(context: IWebhookFunctions) {
|
||||||
formSubmittedText = options.formSubmittedText as string;
|
formSubmittedText = options.formSubmittedText as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.appendAttribution === false) {
|
||||||
|
appendAttribution = false;
|
||||||
|
}
|
||||||
|
|
||||||
const useResponseData = responseMode === 'responseNode';
|
const useResponseData = responseMode === 'responseNode';
|
||||||
|
|
||||||
const data = prepareFormData(
|
const data = prepareFormData(
|
||||||
|
@ -114,6 +121,7 @@ export async function formWebhook(context: IWebhookFunctions) {
|
||||||
mode === 'test',
|
mode === 'test',
|
||||||
instanceId,
|
instanceId,
|
||||||
useResponseData,
|
useResponseData,
|
||||||
|
appendAttribution,
|
||||||
);
|
);
|
||||||
|
|
||||||
const res = context.getResponseObject();
|
const res = context.getResponseObject();
|
||||||
|
|
|
@ -81,7 +81,18 @@ const descriptionV2: INodeTypeDescription = {
|
||||||
responseMode: ['responseNode'],
|
responseMode: ['responseNode'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [respondWithOptions],
|
options: [
|
||||||
|
{
|
||||||
|
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased
|
||||||
|
displayName: 'Append n8n Attribution',
|
||||||
|
name: 'appendAttribution',
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
description:
|
||||||
|
'Whether to include the link “Form automated with n8n” at the bottom of the form',
|
||||||
|
},
|
||||||
|
respondWithOptions,
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue