1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-02-07 14:19:18 +00:00
bramw_baserow/web-frontend/modules/core/plugins/featureFlags.js
2024-12-10 14:27:16 +00:00

37 lines
1 KiB
JavaScript

const FF_ENABLE_ALL = '*'
export const FF_DASHBOARDS = 'dashboards'
export const FF_AB_SSO = 'ab_sso'
/**
* A comma separated list of feature flags used to enable in-progress or not ready
* features for developers. See docs/development/feature-flags.md for more info
* @param env: The environment that should be used to get the flags from
* @returns {string[]}
*/
function getFeatureFlags(env = process.env) {
return (env.FEATURE_FLAGS || '')
.split(',')
.map((flag) => flag.trim().toLowerCase())
}
/**
* Checks if a feature is enabled
* @param featureFlags: The list of feature flags
* @param flag: The flag that is being checked for
* @returns {boolean|*}
*/
function featureFlagIsEnabled(featureFlags, flag) {
if (featureFlags.includes(FF_ENABLE_ALL)) {
return true
} else {
return featureFlags.includes(flag.toLowerCase())
}
}
export default function ({ app }, inject) {
const FEATURE_FLAGS = getFeatureFlags(app.$config)
inject('featureFlagIsEnabled', (flag) =>
featureFlagIsEnabled(FEATURE_FLAGS, flag)
)
}