2022-01-03 15:00:03 +00:00
|
|
|
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
|
|
|
|
|
|
|
export enum Feature {
|
2023-04-18 16:50:46 +00:00
|
|
|
AdminFineGrainedAuthz = "ADMIN_FINE_GRAINED_AUTHZ",
|
|
|
|
ClientPolicies = "CLIENT_POLICIES",
|
2022-01-03 15:00:03 +00:00
|
|
|
DeclarativeUserProfile = "DECLARATIVE_USER_PROFILE",
|
2023-04-18 16:50:46 +00:00
|
|
|
Kerberos = "KERBEROS",
|
2023-05-02 09:46:57 +00:00
|
|
|
DynamicScopes = "DYNAMIC_SCOPES",
|
2023-07-24 14:44:24 +00:00
|
|
|
DPoP = "DPOP",
|
2023-10-24 08:09:26 +00:00
|
|
|
DeviceFlow = "DEVICE_FLOW",
|
2023-10-20 12:02:07 +00:00
|
|
|
TransientUsers = "TRANSIENT_USERS",
|
2022-01-03 15:00:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default function useIsFeatureEnabled() {
|
2023-09-12 14:03:13 +00:00
|
|
|
const { features } = useServerInfo();
|
2022-01-03 15:00:03 +00:00
|
|
|
|
|
|
|
return function isFeatureEnabled(feature: Feature) {
|
2023-09-12 14:03:13 +00:00
|
|
|
if (!features) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return features
|
|
|
|
.filter((f) => f.enabled)
|
|
|
|
.map((f) => f.name)
|
|
|
|
.includes(feature);
|
2022-01-03 15:00:03 +00:00
|
|
|
};
|
|
|
|
}
|