diff --git a/packages/builder/src/components/common/ConfigChecklist.svelte b/packages/builder/src/components/common/ConfigChecklist.svelte index 83e6a41063..7914a78b65 100644 --- a/packages/builder/src/components/common/ConfigChecklist.svelte +++ b/packages/builder/src/components/common/ConfigChecklist.svelte @@ -7,13 +7,7 @@ ProgressCircle, } from "@budibase/bbui" import { admin } from "stores/portal" - - const MESSAGES = { - apps: "Create your first app", - smtp: "Set up email", - adminUser: "Create your first user", - sso: "Set up single sign-on", - } + import { goto } from "@roxi/routify" @@ -28,9 +22,12 @@ {#each Object.keys($admin.checklist) as checklistItem, idx} -
- {idx + 1}. {MESSAGES[checklistItem]} - +
$goto($admin.checklist[checklistItem].link)} + > + {idx + 1}. {$admin.checklist[checklistItem].label} +
{/each} diff --git a/packages/builder/src/pages/builder/_layout.svelte b/packages/builder/src/pages/builder/_layout.svelte index b1f6d7e733..0dbabb31d2 100644 --- a/packages/builder/src/pages/builder/_layout.svelte +++ b/packages/builder/src/pages/builder/_layout.svelte @@ -6,7 +6,7 @@ let loaded = false $: multiTenancyEnabled = $admin.multiTenancy - $: hasAdminUser = !!$admin?.checklist?.adminUser + $: hasAdminUser = $admin?.checklist?.adminUser.checked $: tenantSet = $auth.tenantSet onMount(async () => { @@ -26,7 +26,6 @@ $redirect("./admin") } } - // Redirect to log in at any time if the user isn't authenticated $: { if ( diff --git a/packages/builder/src/pages/builder/admin/_layout.svelte b/packages/builder/src/pages/builder/admin/_layout.svelte index 70823b9a34..602b6a6de3 100644 --- a/packages/builder/src/pages/builder/admin/_layout.svelte +++ b/packages/builder/src/pages/builder/admin/_layout.svelte @@ -6,7 +6,7 @@ let loaded = false onMount(() => { - if ($admin?.checklist?.adminUser) { + if ($admin?.checklist?.adminUser.checked) { $redirect("../") } else { loaded = true diff --git a/packages/builder/src/stores/portal/admin.js b/packages/builder/src/stores/portal/admin.js index 25688ac70c..24b8c31aab 100644 --- a/packages/builder/src/stores/portal/admin.js +++ b/packages/builder/src/stores/portal/admin.js @@ -8,7 +8,12 @@ export function createAdminStore() { multiTenancy: false, sandbox: false, onboardingProgress: 0, - checklist: { apps: 0, smtp: false, adminUser: false, sso: false }, + checklist: { + apps: { checked: false }, + smtp: { checked: false }, + adminUser: { checked: false }, + sso: { checked: false }, + }, } const admin = writable(DEFAULT_CONFIG) @@ -24,7 +29,7 @@ export function createAdminStore() { const onboardingSteps = Object.keys(json) const stepsComplete = onboardingSteps.reduce( - (score, step) => score + Number(!!json[step]), + (score, step) => (score + step.checked ? 1 : 0), 0 ) diff --git a/packages/worker/src/api/controllers/global/configs.js b/packages/worker/src/api/controllers/global/configs.js index 1208fda485..aa83fd695f 100644 --- a/packages/worker/src/api/controllers/global/configs.js +++ b/packages/worker/src/api/controllers/global/configs.js @@ -248,10 +248,26 @@ exports.configChecklist = async function (ctx) { const adminUser = users.rows.some(row => row.doc.admin) ctx.body = { - apps: apps.length, - smtp: !!smtpConfig, - adminUser, - sso: !!googleConfig || !!oidcConfig, + apps: { + checked: apps.length > 0, + label: "Create your first app", + link: "/builder/portal/apps", + }, + smtp: { + checked: !!smtpConfig, + label: "Set up email", + link: "/builder/portal/manage/email", + }, + adminUser: { + checked: adminUser, + label: "Create your first user", + link: "/builder/portal/manage/users", + }, + sso: { + checked: !!googleConfig || !!oidcConfig, + label: "Set up single sign-on", + link: "/builder/portal/manage/auth", + }, } } catch (err) { ctx.throw(err.status, err) diff --git a/packages/worker/src/api/routes/tests/configs.spec.js b/packages/worker/src/api/routes/tests/configs.spec.js index 10feb77b37..73c2903ced 100644 --- a/packages/worker/src/api/routes/tests/configs.spec.js +++ b/packages/worker/src/api/routes/tests/configs.spec.js @@ -4,7 +4,7 @@ const setup = require("./utilities") jest.mock("nodemailer") const nodemailer = require("nodemailer") nodemailer.createTransport.mockReturnValue({ - verify: jest.fn() + verify: jest.fn(), }) describe("/api/global/configs/checklist", () => { @@ -25,11 +25,11 @@ describe("/api/global/configs/checklist", () => { .set(config.defaultHeaders()) .expect("Content-Type", /json/) .expect(200) - + const checklist = res.body - expect(checklist.apps).toBe(0) - expect(checklist.smtp).toBe(true) - expect(checklist.adminUser).toBe(true) + expect(checklist.apps.checked).toBeFalsy() + expect(checklist.smtp.checked).toBeTruthy() + expect(checklist.adminUser.checked).toBeTruthy() }) -}) \ No newline at end of file +})