From 0da1dcee48ba3cef6dbe2478e0328727a64cc0f1 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 12 Dec 2024 14:48:06 +0000 Subject: [PATCH] Convert portal admin store to typescript --- packages/builder/src/api.ts | 6 ++--- packages/builder/src/index.d.ts | 8 ------- .../src/stores/portal/{admin.js => admin.ts} | 23 +++++++++++-------- 3 files changed, 16 insertions(+), 21 deletions(-) delete mode 100644 packages/builder/src/index.d.ts rename packages/builder/src/stores/portal/{admin.js => admin.ts} (86%) diff --git a/packages/builder/src/api.ts b/packages/builder/src/api.ts index 5d1a0beaeb..907354499f 100644 --- a/packages/builder/src/api.ts +++ b/packages/builder/src/api.ts @@ -8,7 +8,7 @@ import { get } from "svelte/store" import { auth, navigation } from "./stores/portal" export const API = createAPIClient({ - attachHeaders: (headers: Record) => { + attachHeaders: headers => { // Attach app ID header from store let appId = get(appStore).appId if (appId) { @@ -22,7 +22,7 @@ export const API = createAPIClient({ } }, - onError: (error: any) => { + onError: error => { const { url, message, status, method, handled } = error || {} // Log any errors that we haven't manually handled @@ -45,7 +45,7 @@ export const API = createAPIClient({ } } }, - onMigrationDetected: (appId: string) => { + onMigrationDetected: appId => { const updatingUrl = `/builder/app/updating/${appId}` if (window.location.pathname === updatingUrl) { diff --git a/packages/builder/src/index.d.ts b/packages/builder/src/index.d.ts deleted file mode 100644 index 1cbad4f12c..0000000000 --- a/packages/builder/src/index.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare module "api" { - const API: { - getPlugins: () => Promise - createPlugin: (plugin: object) => Promise - uploadPlugin: (plugin: FormData) => Promise - deletePlugin: (id: string) => Promise - } -} diff --git a/packages/builder/src/stores/portal/admin.js b/packages/builder/src/stores/portal/admin.ts similarity index 86% rename from packages/builder/src/stores/portal/admin.js rename to packages/builder/src/stores/portal/admin.ts index 54757fb314..9003be8953 100644 --- a/packages/builder/src/stores/portal/admin.js +++ b/packages/builder/src/stores/portal/admin.ts @@ -2,23 +2,26 @@ 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 const DEFAULT_CONFIG: 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, + maintenance: [], } export function createAdminStore() {