Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

1.3 KB
Raw Blame
import { useMemo } from 'react';

import {
	useInfraMonitoringCategory,
	useInfraMonitoringSelectedItemParams,
} from '../hooks';
import { getEntityConfig } from './entity.registry';
import { K8sBaseList } from './K8sBaseList';
import K8sBaseDetails from './K8sBaseDetails';

export interface K8sDynamicListProps {
	controlListPrefix?: React.ReactNode;
	leftFilters?: React.ReactNode;
}

export function K8sDynamicList({
	controlListPrefix,
	leftFilters,
}: K8sDynamicListProps): JSX.Element | null {
	const [selectedCategory] = useInfraMonitoringCategory();
	const [selectedItemParams] = useInfraMonitoringSelectedItemParams();

	const config = useMemo(
		() => getEntityConfig(selectedCategory),
		[selectedCategory],
	);

	// A row opened from the drawer's overview tab belongs to another category
	const drawerCategory = selectedItemParams.category ?? selectedCategory;
	const drawerConfig = useMemo(
		() => getEntityConfig(drawerCategory),
		[drawerCategory],
	);

	if (!config) {
		return null;
	}

	return (
		<>
			<K8sBaseList
				{...config.list}
				controlListPrefix={controlListPrefix}
				leftFilters={leftFilters}
			/>

			{/* No key: remounting would animate the drawer shut and open again
			    for what is really a change of contents */}
			{drawerConfig && <K8sBaseDetails {...drawerConfig.details} />}
		</>
	);
}

export default K8sDynamicList;