Adds a useServerCapabilities hook that fetches /api/v1/health once per session (staleTime: Infinity) and extracts the infrastructureEndpoints flag. buildAdminTreeNodes now accepts an opts parameter so ClickHouse and Database tabs are hidden when the server reports infra endpoints as disabled. LayoutShell wires the hook result into the admin tree memo. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
792 B
TypeScript
30 lines
792 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { config } from '../../config';
|
|
|
|
interface HealthResponse {
|
|
status: string;
|
|
components?: {
|
|
serverCapabilities?: {
|
|
details?: {
|
|
infrastructureEndpoints?: boolean;
|
|
};
|
|
};
|
|
};
|
|
}
|
|
|
|
export function useServerCapabilities() {
|
|
return useQuery<{ infrastructureEndpoints: boolean }>({
|
|
queryKey: ['server-capabilities'],
|
|
queryFn: async () => {
|
|
const res = await fetch(config.apiBaseUrl + '/health');
|
|
if (!res.ok) return { infrastructureEndpoints: true };
|
|
const data: HealthResponse = await res.json();
|
|
return {
|
|
infrastructureEndpoints:
|
|
data.components?.serverCapabilities?.details?.infrastructureEndpoints ?? true,
|
|
};
|
|
},
|
|
staleTime: Infinity,
|
|
});
|
|
}
|