Merge pull request #2556 from mslourens/checklist_item_navigation

add link to checklist items for direct navigation (and lint issues)
This commit is contained in:
Martin McKeaveney 2021-09-09 11:16:38 +01:00 committed by GitHub
commit 5e268dce18
6 changed files with 42 additions and 25 deletions

View File

@ -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"
</script>
<ActionMenu>
@ -28,9 +22,12 @@
</MenuItem>
{#each Object.keys($admin.checklist) as checklistItem, idx}
<MenuItem>
<div class="item">
<span>{idx + 1}. {MESSAGES[checklistItem]}</span>
<Checkbox value={!!$admin.checklist[checklistItem]} />
<div
class="item"
on:click={() => $goto($admin.checklist[checklistItem].link)}
>
<span>{idx + 1}. {$admin.checklist[checklistItem].label}</span>
<Checkbox value={$admin.checklist[checklistItem].checked} />
</div>
</MenuItem>
{/each}

View File

@ -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 (

View File

@ -6,7 +6,7 @@
let loaded = false
onMount(() => {
if ($admin?.checklist?.adminUser) {
if ($admin?.checklist?.adminUser.checked) {
$redirect("../")
} else {
loaded = true

View File

@ -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
)

View File

@ -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)

View File

@ -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()
})
})
})