()
| 38 | } |
| 39 | |
| 40 | function useAllowedIntegrationsFromEnv() { |
| 41 | return useQuery<AllowedIntegrationsResponse>({ |
| 42 | queryKey: allowedIntegrationsKeys.env(), |
| 43 | queryFn: async ({ signal }) => { |
| 44 | try { |
| 45 | return await requestJson(getAllowedIntegrationsContract, { signal }) |
| 46 | } catch (error) { |
| 47 | // Treat any auth/server failure as "no env allowlist configured" |
| 48 | // so the UI falls back to the permission-group-driven allowlist. |
| 49 | if (error instanceof ApiClientError) { |
| 50 | return { allowedIntegrations: null } |
| 51 | } |
| 52 | throw error |
| 53 | } |
| 54 | }, |
| 55 | staleTime: 5 * 60 * 1000, |
| 56 | }) |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Intersects two allowlists. If either is null (unrestricted), returns the other. |
no test coverage detected