From c0578d4cc2a5999fa56f9289455349cf8c3dd1f3 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Thu, 8 Jun 2023 14:25:35 +0100 Subject: [PATCH] Send meeting invite via automation email smtp (#10787) * Pass calendar props into sendSmtpEmail * Add calendar event to message * Add Checkbox and DatePicker automation field UI * Add URL prop * Add url to sendSmtpEmail unit test * Refactor * Code review comments * Make location optional * Add EmailInvite type --------- Co-authored-by: mike12345567 --- .../SetupPanel/AutomationBlockSetup.svelte | 412 ++++++++++-------- .../src/automations/steps/sendSmtpEmail.ts | 59 ++- .../automations/tests/sendSmtpEmail.spec.js | 71 --- .../automations/tests/sendSmtpEmail.spec.ts | 74 ++++ .../server/src/utilities/workerRequests.ts | 29 +- .../types/src/documents/app/automation.ts | 30 ++ packages/worker/package.json | 1 + .../src/api/controllers/global/email.ts | 2 + packages/worker/src/utilities/email.ts | 41 +- yarn.lock | 12 + 10 files changed, 437 insertions(+), 294 deletions(-) delete mode 100644 packages/server/src/automations/tests/sendSmtpEmail.spec.js create mode 100644 packages/server/src/automations/tests/sendSmtpEmail.spec.ts diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 6ab750c3d6..a8fa700b90 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -13,6 +13,8 @@ Modal, notifications, Icon, + Checkbox, + DatePicker, } from "@budibase/bbui" import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte" import { automationStore, selectedAutomation } from "builderStore" @@ -306,6 +308,11 @@ drawer.hide() } + function canShowField(key, value) { + const dependsOn = value.dependsOn + return !dependsOn || !!inputData[dependsOn] + } + onMount(async () => { try { await environment.loadVariables() @@ -317,210 +324,233 @@
{#each deprecatedSchemaProperties as [key, value]} -
- {#if key !== "fields"} - - {/if} - {#if value.type === "string" && value.enum} - onChange(e, key)} - value={inputData[key]} - options={Object.keys(table?.schema || {})} - /> - {:else if value.customType === "filters"} - Define filters - - - (tempFilters = e.detail)} - /> - - {:else if value.customType === "password"} - onChange(e, key)} - value={inputData[key]} - /> - {:else if value.customType === "email"} - {#if isTestModal} - onChange(e, key)} - {bindings} - fillWidth - updateOnChange={false} - /> - {:else} - onChange(e, key)} - {bindings} - allowJS={false} - updateOnChange={false} - drawerLeft="260px" - /> + {#if canShowField(key, value)} +
+ {#if key !== "fields" && value.type !== "boolean"} + {/if} - {:else if value.customType === "query"} - onChange(e, key)} - value={inputData[key]} - /> - {:else if value.customType === "cron"} - onChange(e, key)} value={inputData[key]} /> - {:else if value.customType === "queryParams"} - onChange(e, key)} - value={inputData[key]} - {bindings} - /> - {:else if value.customType === "table"} - onChange(e, key)} - /> - {:else if value.customType === "row"} - { - if (e.detail?.key) { - onChange(e, e.detail.key) - } else { - onChange(e, key) - } - }} - {bindings} - {isTestModal} - {isUpdateRow} - /> - {:else if value.customType === "webhookUrl"} - onChange(e, key)} - value={inputData[key]} - /> - {:else if value.customType === "fields"} - onChange(e, key)} - {bindings} - {isTestModal} - /> - {:else if value.customType === "triggerSchema"} - onChange(e, key)} value={inputData[key]} /> - {:else if value.customType === "code"} - - { - // need to pass without the value inside - onChange({ detail: e.detail }, key) - inputData[key] = e.detail - }} - completions={[ - jsAutocomplete([ - ...bindingsToCompletions(bindings, EditorModes.JS), - ]), - ]} - mode={EditorModes.JS} - height={500} - /> -
- -
-
Add available bindings by typing $
-
-
-
- {:else if value.customType === "loopOption"} - onChange(e, key)} + value={inputData[key]} + options={Object.keys(table?.schema || {})} + /> + {:else if value.customType === "filters"} + Define filters + + + (tempFilters = e.detail)} + /> + + {:else if value.customType === "password"} + onChange(e, key)} + value={inputData[key]} + /> + {:else if value.customType === "email"} + {#if isTestModal} + onChange(e, key)} + {bindings} + fillWidth + updateOnChange={false} + /> + {:else} onChange(e, key)} {bindings} + allowJS={false} updateOnChange={false} - placeholder={value.customType === "queryLimit" ? queryLimit : ""} drawerLeft="260px" /> -
+ {/if} + {:else if value.customType === "query"} + onChange(e, key)} + value={inputData[key]} + /> + {:else if value.customType === "cron"} + onChange(e, key)} + value={inputData[key]} + /> + {:else if value.customType === "queryParams"} + onChange(e, key)} + value={inputData[key]} + {bindings} + /> + {:else if value.customType === "table"} + onChange(e, key)} + /> + {:else if value.customType === "row"} + { + if (e.detail?.key) { + onChange(e, e.detail.key) + } else { + onChange(e, key) + } + }} + {bindings} + {isTestModal} + {isUpdateRow} + /> + {:else if value.customType === "webhookUrl"} + onChange(e, key)} + value={inputData[key]} + /> + {:else if value.customType === "fields"} + onChange(e, key)} + {bindings} + {isTestModal} + /> + {:else if value.customType === "triggerSchema"} + onChange(e, key)} + value={inputData[key]} + /> + {:else if value.customType === "code"} + + { + // need to pass without the value inside + onChange({ detail: e.detail }, key) + inputData[key] = e.detail + }} + completions={[ + jsAutocomplete([ + ...bindingsToCompletions(bindings, EditorModes.JS), + ]), + ]} + mode={EditorModes.JS} + height={500} + /> +
+ +
+
Add available bindings by typing $
+
+
+
+ {:else if value.customType === "loopOption"} +