2022-01-03 15:00:03 +00:00
|
|
|
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
|
|
|
|
|
|
|
export enum Feature {
|
|
|
|
DeclarativeUserProfile = "DECLARATIVE_USER_PROFILE",
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function useIsFeatureEnabled() {
|
|
|
|
const { profileInfo } = useServerInfo();
|
2023-04-11 11:28:24 +00:00
|
|
|
|
|
|
|
const experimentalFeatures = profileInfo?.experimentalFeatures ?? [];
|
|
|
|
const previewFeatures = profileInfo?.previewFeatures ?? [];
|
2022-01-03 15:00:03 +00:00
|
|
|
const disabledFilters = profileInfo?.disabledFeatures ?? [];
|
2023-04-11 11:28:24 +00:00
|
|
|
const allFeatures = [...experimentalFeatures, ...previewFeatures];
|
|
|
|
const enabledFeatures = allFeatures.filter(
|
|
|
|
(feature) => !disabledFilters.includes(feature)
|
|
|
|
);
|
2022-01-03 15:00:03 +00:00
|
|
|
|
|
|
|
return function isFeatureEnabled(feature: Feature) {
|
2023-04-11 11:28:24 +00:00
|
|
|
return enabledFeatures.includes(feature);
|
2022-01-03 15:00:03 +00:00
|
|
|
};
|
|
|
|
}
|