From bcf3e1ef1d7efa8b44142b09468a3aef48d4fd8e Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Thu, 12 May 2022 16:57:54 +0100 Subject: [PATCH] Allow SMTP config to be cleared --- .../builder/portal/manage/email/index.svelte | 27 ++++++++++++++++++- packages/frontend-core/src/api/configs.js | 4 +-- 2 files changed, 28 insertions(+), 3 deletions(-) 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 56242f0fe4..057620f6ad 100644 --- a/packages/builder/src/pages/builder/portal/manage/email/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/email/index.svelte @@ -68,6 +68,26 @@ } } + async function clearSmtp() { + // Delete the SMTP config + try { + await API.deleteConfig({ + id: smtpConfig._id, + rev: smtpConfig._rev, + }) + smtpConfig = { + config: {}, + } + await admin.getChecklist() + notifications.success(`Settings cleared`) + analytics.captureEvent(Events.SMTP.SAVED) + } catch (error) { + notifications.error( + `Failed to clear email settings, reason: ${error?.message || "Unknown"}` + ) + } + } + async function fetchSmtp() { loading = true try { @@ -156,8 +176,9 @@ {/if} -
+
+
@@ -186,4 +207,8 @@ grid-gap: var(--spacing-l); align-items: center; } + .spectrum-Settings-buttonGroup { + gap: var(--spectrum-global-dimension-static-size-200); + align-items: flex-end; + } diff --git a/packages/frontend-core/src/api/configs.js b/packages/frontend-core/src/api/configs.js index 3d38cf4728..8447e0d79d 100644 --- a/packages/frontend-core/src/api/configs.js +++ b/packages/frontend-core/src/api/configs.js @@ -21,13 +21,13 @@ export const buildConfigEndpoints = API => ({ }, /** - * Deletes a global config + * Deletes a global config * @param id the id of the config to delete * @param rev the revision of the config to delete */ deleteConfig: async ({ id, rev }) => { return await API.delete({ - url: `/api/global/configs/${id}/${rev}` + url: `/api/global/configs/${id}/${rev}`, }) },