Convert portal feature flags store to TS

This commit is contained in:
Andrew Kingston 2025-01-02 16:11:15 +00:00
parent ffb47bf3ee
commit 799b6b15d7
No known key found for this signature in database
4 changed files with 23 additions and 20 deletions

View File

@ -4,14 +4,14 @@ import { admin } from "@/stores/portal"
import analytics from "@/analytics" import analytics from "@/analytics"
import { BudiStore } from "@/stores/BudiStore" import { BudiStore } from "@/stores/BudiStore"
import { import {
GetGlobalSelfResponse,
isSSOUser, isSSOUser,
SetInitInfoRequest, SetInitInfoRequest,
UpdateSelfRequest, UpdateSelfRequest,
User,
} from "@budibase/types" } from "@budibase/types"
interface PortalAuthStore { interface PortalAuthStore {
user?: User user?: GetGlobalSelfResponse
initInfo?: Record<string, any> initInfo?: Record<string, any>
accountPortalAccess: boolean accountPortalAccess: boolean
loaded: boolean loaded: boolean
@ -33,7 +33,7 @@ class AuthStore extends BudiStore<PortalAuthStore> {
}) })
} }
setUser(user?: User) { setUser(user?: GetGlobalSelfResponse) {
this.set({ this.set({
loaded: true, loaded: true,
user: user, user: user,

View File

@ -1,16 +0,0 @@
import { derived } from "svelte/store"
import { auth } from "@/stores/portal"
export const INITIAL_FEATUREFLAG_STATE = {
SQS: false,
DEFAULT_VALUES: false,
BUDIBASE_AI: false,
AI_CUSTOM_CONFIGS: false,
}
export const featureFlags = derived([auth], ([$auth]) => {
return {
...INITIAL_FEATUREFLAG_STATE,
...($auth?.user?.flags || {}),
}
})

View File

@ -0,0 +1,19 @@
import { derived, Readable } from "svelte/store"
import { auth } from "@/stores/portal"
export const INITIAL_FEATUREFLAG_STATE = {
SQS: false,
DEFAULT_VALUES: false,
BUDIBASE_AI: false,
AI_CUSTOM_CONFIGS: false,
}
export const featureFlags: Readable<Record<string, any>> = derived(
[auth],
([$auth]) => {
return {
...INITIAL_FEATUREFLAG_STATE,
...($auth?.user?.flags || {}),
}
}
)

View File

@ -8,5 +8,5 @@ export interface GenerateAPIKeyResponse extends DevInfo {}
export interface FetchAPIKeyResponse extends DevInfo {} export interface FetchAPIKeyResponse extends DevInfo {}
export interface GetGlobalSelfResponse extends User { export interface GetGlobalSelfResponse extends User {
flags?: Record<string, string> flags?: Record<string, any>
} }