Merge pull request #5682 from Budibase/bug/sev3/smtp-config-automation

Refetch the admin checklist on SMTP config save
This commit is contained in:
Michael Drury 2022-05-04 12:52:28 +01:00 committed by GitHub
commit 8c406e4049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 10 deletions

View File

@ -13,7 +13,7 @@
Table,
Checkbox,
} from "@budibase/bbui"
import { email } from "stores/portal"
import { email, admin } from "stores/portal"
import { API } from "api"
import { cloneDeep } from "lodash/fp"
import analytics, { Events } from "analytics"
@ -58,6 +58,7 @@
const savedConfig = await API.saveConfig(smtp)
smtpConfig._rev = savedConfig._rev
smtpConfig._id = savedConfig._id
await admin.getChecklist()
notifications.success(`Settings saved`)
analytics.captureEvent(Events.SMTP.SAVED)
} catch (error) {

View File

@ -24,14 +24,8 @@ export function createAdminStore() {
const admin = writable(DEFAULT_CONFIG)
async function init() {
const tenantId = get(auth).tenantId
const checklist = await API.getChecklist(tenantId)
const totalSteps = Object.keys(checklist).length
const completedSteps = Object.values(checklist).filter(
x => x?.checked
).length
await getChecklist()
await getEnvironment()
// enable system status checks in the cloud
if (get(admin).cloud) {
await getSystemStatus()
@ -40,8 +34,6 @@ export function createAdminStore() {
admin.update(store => {
store.loaded = true
store.checklist = checklist
store.onboardingProgress = (completedSteps / totalSteps) * 100
return store
})
}
@ -81,6 +73,20 @@ export function createAdminStore() {
})
}
async function getChecklist() {
const tenantId = get(auth).tenantId
const checklist = await API.getChecklist(tenantId)
const totalSteps = Object.keys(checklist).length
const completedSteps = Object.values(checklist).filter(
x => x?.checked
).length
admin.update(store => {
store.checklist = checklist
store.onboardingProgress = (completedSteps / totalSteps) * 100
return store
})
}
function unload() {
admin.update(store => {
store.loaded = false
@ -93,6 +99,7 @@ export function createAdminStore() {
init,
checkImportComplete,
unload,
getChecklist,
}
}