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 = () => {
|
const disabled = () => {
|
||||||
return {
|
return {
|
||||||
SEND_EMAIL_SMTP: {
|
SEND_EMAIL_SMTP: {
|
||||||
disabled: !$admin.checklist.smtp.checked,
|
disabled: !$admin.checklist?.smtp?.checked,
|
||||||
message: "Please configure SMTP",
|
message: "Please configure SMTP",
|
||||||
},
|
},
|
||||||
COLLECT: {
|
COLLECT: {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
$: useAccountPortal = cloud && !$admin.disableAccountPortal
|
$: useAccountPortal = cloud && !$admin.disableAccountPortal
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if ($admin?.checklist?.adminUser.checked || useAccountPortal) {
|
if ($admin?.checklist?.adminUser?.checked || useAccountPortal) {
|
||||||
$redirect("../")
|
$redirect("../")
|
||||||
} else {
|
} else {
|
||||||
loaded = true
|
loaded = true
|
||||||
|
|
|
@ -177,7 +177,7 @@
|
||||||
<Button
|
<Button
|
||||||
secondary
|
secondary
|
||||||
on:click={deleteSmtp}
|
on:click={deleteSmtp}
|
||||||
disabled={!$admin.checklist.smtp.checked}
|
disabled={!$admin.checklist?.smtp?.checked}
|
||||||
>
|
>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { it, expect, describe, beforeEach, vi } from "vitest"
|
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 { writable, get } from "svelte/store"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
|
@ -45,11 +45,6 @@ describe("admin store", () => {
|
||||||
ctx.returnedStore = createAdminStore()
|
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 => {
|
it("returns the created store", ctx => {
|
||||||
expect(ctx.returnedStore).toEqual({
|
expect(ctx.returnedStore).toEqual({
|
||||||
subscribe: expect.toBe(ctx.writableReturn.subscribe),
|
subscribe: expect.toBe(ctx.writableReturn.subscribe),
|
||||||
|
|
|
@ -2,27 +2,28 @@ import { writable, get } from "svelte/store"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { auth } from "stores/portal"
|
import { auth } from "stores/portal"
|
||||||
import { banner } from "@budibase/bbui"
|
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,
|
loaded: false,
|
||||||
multiTenancy: false,
|
multiTenancy: false,
|
||||||
cloud: false,
|
cloud: false,
|
||||||
isDev: false,
|
isDev: false,
|
||||||
disableAccountPortal: false,
|
disableAccountPortal: false,
|
||||||
accountPortalUrl: "",
|
|
||||||
importComplete: false,
|
|
||||||
checklist: {
|
|
||||||
apps: { checked: false },
|
|
||||||
smtp: { checked: false },
|
|
||||||
adminUser: { checked: false },
|
|
||||||
sso: { checked: false },
|
|
||||||
},
|
|
||||||
maintenance: [],
|
|
||||||
offlineMode: false,
|
offlineMode: false,
|
||||||
}
|
maintenance: [],
|
||||||
|
})
|
||||||
export function createAdminStore() {
|
|
||||||
const admin = writable(DEFAULT_CONFIG)
|
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
await getChecklist()
|
await getChecklist()
|
Loading…
Reference in New Issue