From 565bf97294ee6525e6063d3763c75d477696a589 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 8 Jun 2026 15:16:16 +0200 Subject: [PATCH] refactor(config): add PRO_FEATURE constants for licensed features --- frontend/src/constants/proFeatures.ts | 8 ++++++++ frontend/src/stores/config.ts | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 frontend/src/constants/proFeatures.ts 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 }