Merge pull request #15170 from Budibase/ts-portal-admin-store
Convert portal admin store to typescript
This commit is contained in:
commit
a63b3a0c66
|
@ -49,7 +49,7 @@
|
|||
const disabled = () => {
|
||||
return {
|
||||
SEND_EMAIL_SMTP: {
|
||||
disabled: !$admin.checklist.smtp.checked,
|
||||
disabled: !$admin.checklist?.smtp?.checked,
|
||||
message: "Please configure SMTP",
|
||||
},
|
||||
COLLECT: {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
$: useAccountPortal = cloud && !$admin.disableAccountPortal
|
||||
|
||||
onMount(() => {
|
||||
if ($admin?.checklist?.adminUser.checked || useAccountPortal) {
|
||||
if ($admin?.checklist?.adminUser?.checked || useAccountPortal) {
|
||||
$redirect("../")
|
||||
} else {
|
||||
loaded = true
|
||||
|
|
|
@ -177,7 +177,7 @@
|
|||
<Button
|
||||
secondary
|
||||
on:click={deleteSmtp}
|
||||
disabled={!$admin.checklist.smtp.checked}
|
||||
disabled={!$admin.checklist?.smtp?.checked}
|
||||
>
|
||||
Reset
|
||||
</Button>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { it, expect, describe, beforeEach, vi } from "vitest"
|
||||
import { DEFAULT_CONFIG, createAdminStore } from "./admin"
|
||||
import { createAdminStore } from "./admin"
|
||||
|
||||
import { writable, get } from "svelte/store"
|
||||
import { API } from "api"
|
||||
|
@ -45,11 +45,6 @@ describe("admin store", () => {
|
|||
ctx.returnedStore = createAdminStore()
|
||||
})
|
||||
|
||||
it("inits the writable store with the default config", () => {
|
||||
expect(writable).toHaveBeenCalledTimes(1)
|
||||
expect(writable).toHaveBeenCalledWith(DEFAULT_CONFIG)
|
||||
})
|
||||
|
||||
it("returns the created store", ctx => {
|
||||
expect(ctx.returnedStore).toEqual({
|
||||
subscribe: expect.toBe(ctx.writableReturn.subscribe),
|
||||
|
|
|
@ -2,27 +2,28 @@ import { writable, get } from "svelte/store"
|
|||
import { API } from "api"
|
||||
import { auth } from "stores/portal"
|
||||
import { banner } from "@budibase/bbui"
|
||||
import {
|
||||
ConfigChecklistResponse,
|
||||
GetEnvironmentResponse,
|
||||
SystemStatusResponse,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const DEFAULT_CONFIG = {
|
||||
interface PortalAdminStore extends GetEnvironmentResponse {
|
||||
loaded: boolean
|
||||
checklist?: ConfigChecklistResponse
|
||||
status?: SystemStatusResponse
|
||||
}
|
||||
|
||||
export function createAdminStore() {
|
||||
const admin = writable<PortalAdminStore>({
|
||||
loaded: false,
|
||||
multiTenancy: false,
|
||||
cloud: false,
|
||||
isDev: false,
|
||||
disableAccountPortal: false,
|
||||
accountPortalUrl: "",
|
||||
importComplete: false,
|
||||
checklist: {
|
||||
apps: { checked: false },
|
||||
smtp: { checked: false },
|
||||
adminUser: { checked: false },
|
||||
sso: { checked: false },
|
||||
},
|
||||
maintenance: [],
|
||||
offlineMode: false,
|
||||
}
|
||||
|
||||
export function createAdminStore() {
|
||||
const admin = writable(DEFAULT_CONFIG)
|
||||
maintenance: [],
|
||||
})
|
||||
|
||||
async function init() {
|
||||
await getChecklist()
|
Loading…
Reference in New Issue