1
0
Fork 0
mirror of synced 2024-07-15 11:15:59 +12:00

Merge pull request #5857 from Budibase/bug/sev2/unable-to-clear-smtp-config

Allow SMTP config to be cleared
This commit is contained in:
melohagan 2022-05-16 20:00:59 +01:00 committed by GitHub
commit b7c34304eb
2 changed files with 43 additions and 1 deletions

View file

@ -68,6 +68,26 @@
}
}
async function deleteSmtp() {
// 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,15 @@
</div>
{/if}
</Layout>
<div>
<div class="spectrum-ButtonGroup spectrum-Settings-buttonGroup">
<Button cta on:click={saveSmtp}>Save</Button>
<Button
secondary
on:click={deleteSmtp}
disabled={!$admin.checklist.smtp.checked}
>
Reset
</Button>
</div>
<Divider />
<Layout gap="XS" noPadding>
@ -186,4 +213,8 @@
grid-gap: var(--spacing-l);
align-items: center;
}
.spectrum-Settings-buttonGroup {
gap: var(--spectrum-global-dimension-static-size-200);
align-items: flex-end;
}
</style>

View file

@ -20,6 +20,17 @@ export const buildConfigEndpoints = API => ({
})
},
/**
* 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}`,
})
},
/**
* Gets the config for a certain tenant.
* @param tenantId the tenant ID to get the config for