mirror of
https://github.com/supabase/supabase.git
synced 2026-07-04 23:14:28 +08:00
* feat: enable/disable dashboard features * use the set directly * move enabled features to common * remove sneaky any --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
22 lines
772 B
TypeScript
22 lines
772 B
TypeScript
import { isFeatureEnabled, type Feature } from 'common'
|
|
import { useProfile } from 'lib/profile'
|
|
|
|
function useIsFeatureEnabled<T extends Feature[]>(
|
|
features: T
|
|
): ReturnType<typeof isFeatureEnabled<T>>
|
|
function useIsFeatureEnabled(features: Feature): ReturnType<typeof isFeatureEnabled>
|
|
function useIsFeatureEnabled<T extends Feature | Feature[]>(features: T) {
|
|
const { profile } = useProfile()
|
|
const disabledFeatures = profile?.disabled_features
|
|
|
|
// This code branch is to make the type checker happy, it's intentionally
|
|
// the same as the isFeatureEnabled function call below.
|
|
if (Array.isArray(features)) {
|
|
return isFeatureEnabled(features, disabledFeatures)
|
|
}
|
|
|
|
return isFeatureEnabled(features, disabledFeatures)
|
|
}
|
|
|
|
export { useIsFeatureEnabled }
|