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 1b1675747c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 25 deletions

View File

@ -7,13 +7,7 @@
ProgressCircle, ProgressCircle,
} from "@budibase/bbui" } from "@budibase/bbui"
import { admin } from "stores/portal" import { admin } from "stores/portal"
import { goto } from "@roxi/routify"
const MESSAGES = {
apps: "Create your first app",
smtp: "Set up email",
adminUser: "Create your first user",
sso: "Set up single sign-on",
}
</script> </script>
<ActionMenu> <ActionMenu>
@ -28,9 +22,12 @@
</MenuItem> </MenuItem>
{#each Object.keys($admin.checklist) as checklistItem, idx} {#each Object.keys($admin.checklist) as checklistItem, idx}
<MenuItem> <MenuItem>
<div class="item"> <div
<span>{idx + 1}. {MESSAGES[checklistItem]}</span> class="item"
<Checkbox value={!!$admin.checklist[checklistItem]} /> on:click={() => $goto($admin.checklist[checklistItem].link)}
>
<span>{idx + 1}. {$admin.checklist[checklistItem].label}</span>
<Checkbox value={$admin.checklist[checklistItem].checked} />
</div> </div>
</MenuItem> </MenuItem>
{/each} {/each}

View File

@ -6,7 +6,7 @@
let loaded = false let loaded = false
$: multiTenancyEnabled = $admin.multiTenancy $: multiTenancyEnabled = $admin.multiTenancy
$: hasAdminUser = !!$admin?.checklist?.adminUser $: hasAdminUser = $admin?.checklist?.adminUser.checked
$: tenantSet = $auth.tenantSet $: tenantSet = $auth.tenantSet
onMount(async () => { onMount(async () => {
@ -26,7 +26,6 @@
$redirect("./admin") $redirect("./admin")
} }
} }
// Redirect to log in at any time if the user isn't authenticated // Redirect to log in at any time if the user isn't authenticated
$: { $: {
if ( if (

View File

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

View File

@ -8,7 +8,12 @@ export function createAdminStore() {
multiTenancy: false, multiTenancy: false,
sandbox: false, sandbox: false,
onboardingProgress: 0, 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) const admin = writable(DEFAULT_CONFIG)
@ -24,7 +29,7 @@ export function createAdminStore() {
const onboardingSteps = Object.keys(json) const onboardingSteps = Object.keys(json)
const stepsComplete = onboardingSteps.reduce( const stepsComplete = onboardingSteps.reduce(
(score, step) => score + Number(!!json[step]), (score, step) => (score + step.checked ? 1 : 0),
0 0
) )

View File

@ -248,10 +248,26 @@ exports.configChecklist = async function (ctx) {
const adminUser = users.rows.some(row => row.doc.admin) const adminUser = users.rows.some(row => row.doc.admin)
ctx.body = { ctx.body = {
apps: apps.length, apps: {
smtp: !!smtpConfig, checked: apps.length > 0,
adminUser, label: "Create your first app",
sso: !!googleConfig || !!oidcConfig, 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) { } catch (err) {
ctx.throw(err.status, err) ctx.throw(err.status, err)

View File

@ -4,7 +4,7 @@ const setup = require("./utilities")
jest.mock("nodemailer") jest.mock("nodemailer")
const nodemailer = require("nodemailer") const nodemailer = require("nodemailer")
nodemailer.createTransport.mockReturnValue({ nodemailer.createTransport.mockReturnValue({
verify: jest.fn() verify: jest.fn(),
}) })
describe("/api/global/configs/checklist", () => { describe("/api/global/configs/checklist", () => {
@ -28,8 +28,8 @@ describe("/api/global/configs/checklist", () => {
const checklist = res.body const checklist = res.body
expect(checklist.apps).toBe(0) expect(checklist.apps.checked).toBeFalsy()
expect(checklist.smtp).toBe(true) expect(checklist.smtp.checked).toBeTruthy()
expect(checklist.adminUser).toBe(true) expect(checklist.adminUser.checked).toBeTruthy()
}) })
}) })