diff --git a/frontend/src/constants/proFeatures.ts b/frontend/src/constants/proFeatures.ts new file mode 100644 index 000000000..4e2af18ec --- /dev/null +++ b/frontend/src/constants/proFeatures.ts @@ -0,0 +1,8 @@ +// Licensed "pro" features the server may advertise via /info's enabled_pro_features. +// Use these instead of bare strings when calling configStore.isProFeatureEnabled. +export const PRO_FEATURE = { + ADMIN_PANEL: 'admin_panel', + TIME_TRACKING: 'time_tracking', +} as const + +export type ProFeature = typeof PRO_FEATURE[keyof typeof PRO_FEATURE] diff --git a/frontend/src/stores/config.ts b/frontend/src/stores/config.ts index 73160acd5..3eea0595a 100644 --- a/frontend/src/stores/config.ts +++ b/frontend/src/stores/config.ts @@ -7,6 +7,7 @@ import {objectToCamelCase} from '@/helpers/case' import type {IProvider} from '@/types/IProvider' import type {MIGRATORS} from '@/views/migrate/migrators' +import type {ProFeature} from '@/constants/proFeatures' import {InvalidApiUrlProvidedError} from '@/helpers/checkAndSetApiUrl' export interface ConfigState { @@ -104,7 +105,7 @@ export const useConfigStore = defineStore('config', () => { Object.assign(state, config) } - function isProFeatureEnabled(name: string): boolean { + function isProFeatureEnabled(name: ProFeature): boolean { return state.enabledProFeatures?.includes(name) ?? false }