Skip to content

Commit ef8543a

Browse files
authored
fix: set cloud enabled when control plane is enabled (#3657)
* fix: set cloud enabled when control plane is enabled * chore: lint * enable ff query
1 parent b23b63c commit ef8543a

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

frontend/app/src/hooks/use-cloud.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import useControlPlane from '@/hooks/use-control-plane';
12
import { cloudApi } from '@/lib/api/api';
23
import {
34
APICloudMetadata,
@@ -66,11 +67,14 @@ type UseCloudReturn =
6667

6768
export default function useCloud(tenantId?: string): UseCloudReturn {
6869
const cloudMetaQuery = useQuery(getCloudMetadataQuery);
70+
const { isControlPlaneEnabled, controlPlaneMeta } = useControlPlane();
6971

7072
const featureFlagsQuery = useQuery({
7173
queryKey: ['feature-flags:list', tenantId],
7274
retry: false,
73-
enabled: cloudMetaQuery.data?.isCloudEnabled && !!tenantId,
75+
enabled:
76+
(isControlPlaneEnabled || cloudMetaQuery.data?.isCloudEnabled) &&
77+
!!tenantId,
7478
queryFn: async () => {
7579
try {
7680
// This shouldn't be possible because of the `enabled` above, and yet, Josh found it happening at runtime
@@ -86,6 +90,22 @@ export default function useCloud(tenantId?: string): UseCloudReturn {
8690
staleTime: 1000 * 60,
8791
});
8892

93+
if (isControlPlaneEnabled) {
94+
return {
95+
cloud: {
96+
canBill: true,
97+
canLinkGithub: true,
98+
metricsEnabled: true,
99+
requireBillingForManagedCompute: true,
100+
inactivityLogoutMs: controlPlaneMeta?.inactivityLogoutMs,
101+
},
102+
isCloudEnabled: true,
103+
isCloudLoaded: true,
104+
isCloudLoading: false,
105+
featureFlags: featureFlagsQuery.data?.data || null,
106+
};
107+
}
108+
89109
if (cloudMetaQuery.data && cloudMetaQuery.data.isCloudEnabled) {
90110
return {
91111
cloud: cloudMetaQuery.data,

0 commit comments

Comments
 (0)