refactor(config): add PRO_FEATURE constants for licensed features

This commit is contained in:
kolaente 2026-06-08 15:16:16 +02:00 committed by kolaente
parent 4a558fc57a
commit 565bf97294
2 changed files with 10 additions and 1 deletions

View File

@ -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]

View File

@ -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
}