From 3f56a316c563f4d176bfb59ba479faeb2af60617 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 14 Jul 2021 11:23:24 +0100 Subject: [PATCH 1/3] Some quick fixes after a user had some confusion over how the email templating works, just adding some detail that should help explain. --- .../portal/manage/email/[template].svelte | 13 ++++++--- .../email/_components/TemplateLink.svelte | 13 --------- .../builder/portal/manage/email/index.svelte | 27 +++++++++++-------- .../src/api/controllers/admin/templates.js | 8 +++++- packages/worker/src/constants/index.js | 21 ++++++++++++--- 5 files changed, 50 insertions(+), 32 deletions(-) delete mode 100644 packages/builder/src/pages/builder/portal/manage/email/_components/TemplateLink.svelte diff --git a/packages/builder/src/pages/builder/portal/manage/email/[template].svelte b/packages/builder/src/pages/builder/portal/manage/email/[template].svelte index cd4c7c739d..41e682eb7c 100644 --- a/packages/builder/src/pages/builder/portal/manage/email/[template].svelte +++ b/packages/builder/src/pages/builder/portal/manage/email/[template].svelte @@ -16,6 +16,7 @@ import Editor from "components/integration/QueryEditor.svelte" import TemplateBindings from "./_components/TemplateBindings.svelte" + // this is the email purpose export let template let htmlEditor @@ -24,9 +25,11 @@ $: selectedTemplate = $email.templates?.find( ({ purpose }) => purpose === template ) + $: name = $email.definitions?.info[template]?.name + $: description = $email.definitions?.info[template]?.description $: baseTemplate = $email.templates?.find(({ purpose }) => purpose === "base") $: templateBindings = - $email.definitions?.bindings?.[selectedTemplate.purpose] || [] + $email.definitions?.bindings?.[selectedTemplate?.purpose] || [] $: previewContent = makePreviewContent(baseTemplate, selectedTemplate) async function saveTemplate() { @@ -81,13 +84,15 @@
- Email Template: {template} + Email Template: {name}
+ Description + {description} Change the email template here. Add dynamic content by using the bindings - menu on the right.Change the email template here. Add dynamic content by using the bindings + menu on the right. diff --git a/packages/builder/src/pages/builder/portal/manage/email/_components/TemplateLink.svelte b/packages/builder/src/pages/builder/portal/manage/email/_components/TemplateLink.svelte deleted file mode 100644 index 060f533bd2..0000000000 --- a/packages/builder/src/pages/builder/portal/manage/email/_components/TemplateLink.svelte +++ /dev/null @@ -1,13 +0,0 @@ - - - $goto(`./${value}`)}>{value} - - diff --git a/packages/builder/src/pages/builder/portal/manage/email/index.svelte b/packages/builder/src/pages/builder/portal/manage/email/index.svelte index 2c7b798d5e..250e4d9375 100644 --- a/packages/builder/src/pages/builder/portal/manage/email/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/email/index.svelte @@ -14,7 +14,6 @@ Checkbox, } from "@budibase/bbui" import { email } from "stores/portal" - import TemplateLink from "./_components/TemplateLink.svelte" import api from "builderStore/api" import { cloneDeep } from "lodash/fp" @@ -23,23 +22,30 @@ } const templateSchema = { - purpose: { - displayName: "Email", + name: { + displayName: "Name", editable: false, }, + category: { + displayName: "Category", + editable: false, + } } - const customRenderers = [ - { - column: "purpose", - component: TemplateLink, - }, - ] + $: emailInfo = getEmailInfo($email.definitions) let smtpConfig let loading let requireAuth = false + function getEmailInfo(definitions) { + if (!definitions) { + return [] + } + const entries = Object.entries(definitions.info) + return entries.map(([key, value]) => ({ purpose: key, ...value })) + } + async function saveSmtp() { // clone it so we can remove stuff if required const smtp = cloneDeep(smtpConfig) @@ -159,8 +165,7 @@ $goto(`./${detail.purpose}`)} diff --git a/packages/worker/src/api/controllers/admin/templates.js b/packages/worker/src/api/controllers/admin/templates.js index dde92ecca5..ab9c52cb5a 100644 --- a/packages/worker/src/api/controllers/admin/templates.js +++ b/packages/worker/src/api/controllers/admin/templates.js @@ -28,12 +28,18 @@ exports.save = async ctx => { exports.definitions = async ctx => { const bindings = {} - + const info = {} for (let template of TemplateMetadata.email) { bindings[template.purpose] = template.bindings + info[template.purpose] = { + name: template.name, + description: template.description, + category: template.category, + } } ctx.body = { + info, bindings: { ...bindings, common: Object.values(TemplateBindings), diff --git a/packages/worker/src/constants/index.js b/packages/worker/src/constants/index.js index b40446cc89..efb832ee1a 100644 --- a/packages/worker/src/constants/index.js +++ b/packages/worker/src/constants/index.js @@ -96,7 +96,9 @@ const TemplateBindings = { const TemplateMetadata = { [TemplateTypes.EMAIL]: [ { - name: "Base Format", + name: "Base format", + description: "This is the base template, all others are based on it. The {{ body }} will be replaced with another email template.", + category: "miscellaneous", purpose: EmailTemplatePurpose.BASE, bindings: [ { @@ -110,7 +112,9 @@ const TemplateMetadata = { ], }, { - name: "Password Recovery", + name: "Password recovery", + description: "When a user requests a password reset, this template will be used.", + category: "user management", purpose: EmailTemplatePurpose.PASSWORD_RECOVERY, bindings: [ { @@ -126,7 +130,16 @@ const TemplateMetadata = { ], }, { - name: "New User Invitation", + name: "User welcome", + description: "When a new user is added to the system, the welcome email will use this template.", + category: "user management", + purpose: EmailTemplatePurpose.WELCOME, + bindings: [], + }, + { + name: "User invitation", + description: "When using the email invitation system, this template will be used.", + category: "user management", purpose: EmailTemplatePurpose.INVITATION, bindings: [ { @@ -143,6 +156,8 @@ const TemplateMetadata = { }, { name: "Custom", + description: "A custom format, this is currently used for SMTP email actions in automations.", + category: "automations", purpose: EmailTemplatePurpose.CUSTOM, bindings: [ { From da5024633b2e40d64d495f8181d2e3be4d891e48 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 14 Jul 2021 13:18:27 +0100 Subject: [PATCH 2/3] Linting. --- .../builder/portal/manage/email/[template].svelte | 4 ++-- .../builder/portal/manage/email/index.svelte | 2 +- packages/worker/src/constants/index.js | 15 ++++++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/email/[template].svelte b/packages/builder/src/pages/builder/portal/manage/email/[template].svelte index 41e682eb7c..60ff3d6110 100644 --- a/packages/builder/src/pages/builder/portal/manage/email/[template].svelte +++ b/packages/builder/src/pages/builder/portal/manage/email/[template].svelte @@ -91,8 +91,8 @@ Description {description} Change the email template here. Add dynamic content by using the bindings - menu on the right.Change the email template here. Add dynamic content by using the bindings + menu on the right. diff --git a/packages/builder/src/pages/builder/portal/manage/email/index.svelte b/packages/builder/src/pages/builder/portal/manage/email/index.svelte index 250e4d9375..4a2b21b691 100644 --- a/packages/builder/src/pages/builder/portal/manage/email/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/email/index.svelte @@ -29,7 +29,7 @@ category: { displayName: "Category", editable: false, - } + }, } $: emailInfo = getEmailInfo($email.definitions) diff --git a/packages/worker/src/constants/index.js b/packages/worker/src/constants/index.js index efb832ee1a..f18b94c794 100644 --- a/packages/worker/src/constants/index.js +++ b/packages/worker/src/constants/index.js @@ -97,7 +97,8 @@ const TemplateMetadata = { [TemplateTypes.EMAIL]: [ { name: "Base format", - description: "This is the base template, all others are based on it. The {{ body }} will be replaced with another email template.", + description: + "This is the base template, all others are based on it. The {{ body }} will be replaced with another email template.", category: "miscellaneous", purpose: EmailTemplatePurpose.BASE, bindings: [ @@ -113,7 +114,8 @@ const TemplateMetadata = { }, { name: "Password recovery", - description: "When a user requests a password reset, this template will be used.", + description: + "When a user requests a password reset, this template will be used.", category: "user management", purpose: EmailTemplatePurpose.PASSWORD_RECOVERY, bindings: [ @@ -131,14 +133,16 @@ const TemplateMetadata = { }, { name: "User welcome", - description: "When a new user is added to the system, the welcome email will use this template.", + description: + "When a new user is added to the system, the welcome email will use this template.", category: "user management", purpose: EmailTemplatePurpose.WELCOME, bindings: [], }, { name: "User invitation", - description: "When using the email invitation system, this template will be used.", + description: + "When using the email invitation system, this template will be used.", category: "user management", purpose: EmailTemplatePurpose.INVITATION, bindings: [ @@ -156,7 +160,8 @@ const TemplateMetadata = { }, { name: "Custom", - description: "A custom format, this is currently used for SMTP email actions in automations.", + description: + "A custom format, this is currently used for SMTP email actions in automations.", category: "automations", purpose: EmailTemplatePurpose.CUSTOM, bindings: [ From 1fa0b3f204fd7d083702242633a08f695b4e13f3 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 14 Jul 2021 13:24:46 +0100 Subject: [PATCH 3/3] Rewording email template descriptions. --- packages/worker/src/constants/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/worker/src/constants/index.js b/packages/worker/src/constants/index.js index f18b94c794..aec864be97 100644 --- a/packages/worker/src/constants/index.js +++ b/packages/worker/src/constants/index.js @@ -115,7 +115,7 @@ const TemplateMetadata = { { name: "Password recovery", description: - "When a user requests a password reset, this template will be used.", + "When a user requests a password reset they will receive an email built with this template.", category: "user management", purpose: EmailTemplatePurpose.PASSWORD_RECOVERY, bindings: [ @@ -134,7 +134,7 @@ const TemplateMetadata = { { name: "User welcome", description: - "When a new user is added to the system, the welcome email will use this template.", + "When a new user is added they will be sent a welcome email using this template.", category: "user management", purpose: EmailTemplatePurpose.WELCOME, bindings: [], @@ -142,7 +142,7 @@ const TemplateMetadata = { { name: "User invitation", description: - "When using the email invitation system, this template will be used.", + "When inviting a user via the email on-boarding this template will be used.", category: "user management", purpose: EmailTemplatePurpose.INVITATION, bindings: [ @@ -161,7 +161,7 @@ const TemplateMetadata = { { name: "Custom", description: - "A custom format, this is currently used for SMTP email actions in automations.", + "A custom template, this is currently used for SMTP email actions in automations.", category: "automations", purpose: EmailTemplatePurpose.CUSTOM, bindings: [