Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/data/featureflag-query.ts
2500 views
1
/**
2
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import { getPrimaryEmail } from "@gitpod/public-api-common/lib/user-utils";
8
import { useQuery } from "@tanstack/react-query";
9
import { getExperimentsClient } from "../experiments/client";
10
import { useCurrentUser } from "../user-context";
11
import { useCurrentOrg } from "./organizations/orgs-query";
12
13
const featureFlags = {
14
oidcServiceEnabled: false,
15
// Default to true to enable on gitpod dedicated until ff support is added for dedicated
16
orgGitAuthProviders: true,
17
userGitAuthProviders: false,
18
// Local SSH feature of VS Code Desktop Extension
19
gitpod_desktop_use_local_ssh_proxy: false,
20
enabledOrbitalDiscoveries: "",
21
// dummy specified dataops feature, default false
22
dataops: false,
23
enable_multi_org: false,
24
showBrowserExtensionPromotion: false,
25
enable_experimental_jbtb: false,
26
enabled_configuration_prebuild_full_clone: false,
27
enterprise_onboarding_enabled: false,
28
commit_annotation_setting_enabled: false,
29
};
30
31
type FeatureFlags = typeof featureFlags;
32
33
export const useFeatureFlag = <K extends keyof FeatureFlags>(featureFlag: K): FeatureFlags[K] | boolean => {
34
const user = useCurrentUser();
35
const org = useCurrentOrg().data;
36
37
const queryKey = ["featureFlag", featureFlag, user?.id || "", org?.id || ""];
38
39
const query = useQuery(queryKey, async () => {
40
const flagValue = await getExperimentsClient().getValueAsync(featureFlag, featureFlags[featureFlag], {
41
user: user && {
42
id: user.id,
43
email: getPrimaryEmail(user),
44
},
45
teamId: org?.id,
46
teamName: org?.name,
47
gitpodHost: window.location.host,
48
});
49
return flagValue;
50
});
51
52
return query.data !== undefined ? query.data : featureFlags[featureFlag];
53
};
54
55
export const useIsDataOps = () => {
56
return useFeatureFlag("dataops");
57
};
58
59