Skip to content

Commit

Permalink
feat: Send and wait operation - freeText and customForm response types (
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency authored Dec 16, 2024
1 parent 39462ab commit e98c7f1
Show file tree
Hide file tree
Showing 13 changed files with 475 additions and 58 deletions.
6 changes: 5 additions & 1 deletion packages/cli/templates/form-trigger.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,11 @@

<div class='card' id='submitted-form' style='display: none;'>
<div class='form-header'>
<h1 id='submitted-header'>Form Submitted</h1>
{{#if formSubmittedHeader}}
<h1 id='submitted-header'>{{formSubmittedHeader}}</h1>
{{else}}
<h1 id='submitted-header'>Form Submitted</h1>
{{/if}}
{{#if formSubmittedText}}
<p id='submitted-content'>
{{formSubmittedText}}
Expand Down
77 changes: 41 additions & 36 deletions packages/nodes-base/nodes/Form/Form.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
FormFieldsParameter,
IExecuteFunctions,
INodeExecutionData,
INodeProperties,
INodeTypeDescription,
IWebhookFunctions,
NodeTypeAndVersion,
Expand All @@ -22,49 +23,53 @@ import { formDescription, formFields, formTitle } from '../Form/common.descripti
import { prepareFormReturnItem, renderForm, resolveRawData } from '../Form/utils';
import { type CompletionPageConfig } from './interfaces';

export const formFieldsProperties: INodeProperties[] = [
{
displayName: 'Define Form',
name: 'defineForm',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Using Fields Below',
value: 'fields',
},
{
name: 'Using JSON',
value: 'json',
},
],
default: 'fields',
},
{
displayName: 'Form Fields',
name: 'jsonOutput',
type: 'json',
typeOptions: {
rows: 5,
},
default:
'[\n {\n "fieldLabel":"Name",\n "placeholder":"enter you name",\n "requiredField":true\n },\n {\n "fieldLabel":"Age",\n "fieldType":"number",\n "placeholder":"enter your age"\n },\n {\n "fieldLabel":"Email",\n "fieldType":"email",\n "requiredField":true\n }\n]',
validateType: 'form-fields',
ignoreValidationDuringExecution: true,
hint: '<a href="hhttps://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.form/" target="_blank">See docs</a> for field syntax',
displayOptions: {
show: {
defineForm: ['json'],
},
},
},
{ ...formFields, displayOptions: { show: { defineForm: ['fields'] } } },
];

const pageProperties = updateDisplayOptions(
{
show: {
operation: ['page'],
},
},
[
{
displayName: 'Define Form',
name: 'defineForm',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Using Fields Below',
value: 'fields',
},
{
name: 'Using JSON',
value: 'json',
},
],
default: 'fields',
},
{
displayName: 'Form Fields',
name: 'jsonOutput',
type: 'json',
typeOptions: {
rows: 5,
},
default:
'[\n {\n "fieldLabel":"Name",\n "placeholder":"enter you name",\n "requiredField":true\n },\n {\n "fieldLabel":"Age",\n "fieldType":"number",\n "placeholder":"enter your age"\n },\n {\n "fieldLabel":"Email",\n "fieldType":"email",\n "requiredField":true\n }\n]',
validateType: 'form-fields',
ignoreValidationDuringExecution: true,
hint: '<a href="hhttps://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.form/" target="_blank">See docs</a> for field syntax',
displayOptions: {
show: {
defineForm: ['json'],
},
},
},
{ ...formFields, displayOptions: { show: { defineForm: ['fields'] } } },
...formFieldsProperties,
{
displayName: 'Options',
name: 'options',
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Form/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type FormTriggerData = {
validForm: boolean;
formTitle: string;
formDescription?: string;
formSubmittedHeader?: string;
formSubmittedText?: string;
redirectUrl?: string;
n8nWebsiteLink: string;
Expand Down
3 changes: 3 additions & 0 deletions packages/nodes-base/nodes/Form/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { getResolvables } from '../../utils/utilities';
export function prepareFormData({
formTitle,
formDescription,
formSubmittedHeader,
formSubmittedText,
redirectUrl,
formFields,
Expand All @@ -49,6 +50,7 @@ export function prepareFormData({
useResponseData?: boolean;
appendAttribution?: boolean;
buttonLabel?: string;
formSubmittedHeader?: string;
}) {
const validForm = formFields.length > 0;
const utm_campaign = instanceId ? `&utm_campaign=${instanceId}` : '';
Expand All @@ -63,6 +65,7 @@ export function prepareFormData({
validForm,
formTitle,
formDescription,
formSubmittedHeader,
formSubmittedText,
n8nWebsiteLink,
formFields: [],
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Google/Gmail/Gmail.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
}
]
},
"alias": ["email"]
"alias": ["email", "human", "form", "wait"]
}
9 changes: 9 additions & 0 deletions packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ const versionDescription: INodeTypeDescription = {
restartWebhook: true,
isFullPath: true,
},
{
name: 'default',
httpMethod: 'POST',
responseMode: 'onReceived',
responseData: '',
path: '={{ $nodeId }}',
restartWebhook: true,
isFullPath: true,
},
],
properties: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export const messageOperations: INodeProperties[] = [
action: 'Send a message',
},
{
name: 'Send and Wait for Approval',
name: 'Send and Wait for Response',
value: SEND_AND_WAIT_OPERATION,
action: 'Send a message and wait for approval',
action: 'Send message and wait for response',
},
],
default: 'send',
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Slack/Slack.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Communication"],
"alias": ["human", "form", "wait"],
"resources": {
"credentialDocumentation": [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/nodes-base/nodes/Slack/V2/MessageDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export const messageOperations: INodeProperties[] = [
action: 'Send a message',
},
{
name: 'Send and Wait for Approval',
name: 'Send and Wait for Response',
value: SEND_AND_WAIT_OPERATION,
action: 'Send a message and wait for approval',
action: 'Send message and wait for response',
},
{
name: 'Update',
Expand Down
9 changes: 9 additions & 0 deletions packages/nodes-base/nodes/Slack/V2/SlackV2.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ export class SlackV2 implements INodeType {
restartWebhook: true,
isFullPath: true,
},
{
name: 'default',
httpMethod: 'POST',
responseMode: 'onReceived',
responseData: '',
path: '={{ $nodeId }}',
restartWebhook: true,
isFullPath: true,
},
],
properties: [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/utils/sendAndWait/email-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function createEmailBody(message: string, buttons: string, instanceId?: s
<tr>
<td
style="text-align: center; padding-top: 8px; font-family: Arial, sans-serif; font-size: 14px; color: #7e8186;">
<p>${message}</p>
<p style="white-space: pre-line;">${message}</p>
</td>
</tr>
<tr>
Expand Down
Loading

0 comments on commit e98c7f1

Please sign in to comment.