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.7 KB
Raw Blame
import { useAppParams } from 'lib/router/useAppParams';
import {
	PublicDashboardSchema,
	useGetResolvedPublicDashboard,
} from 'hooks/dashboard/useGetResolvedPublicDashboard';
import { Frown, TriangleAlert } from '@signozhq/icons';

import PublicDashboardMessage from './PublicDashboardMessage';
import PublicDashboardView from './PublicDashboardView/PublicDashboardView';

import './PublicDashboard.styles.scss';

function PublicDashboardPage(): JSX.Element {
	// read the dashboard id from the url
	const { dashboardId } = useAppParams<'dashboardId'>();

	const {
		data: resolved,
		isLoading,
		isFetching,
		isError,
	} = useGetResolvedPublicDashboard(dashboardId ?? '');

	const isBusy = isLoading || isFetching;

	return (
		<div className="public-dashboard-page">
			{resolved?.schema === PublicDashboardSchema.V2 && dashboardId && (
				<PublicDashboardView publicDashboardId={dashboardId} data={resolved.data} />
			)}

			{resolved?.schema === PublicDashboardSchema.Legacy && (
				<PublicDashboardMessage
					testId="public-dashboard-legacy"
					icon={<TriangleAlert size={36} />}
					title="This dashboard isn't available in the new experience"
					description="It hasn't been migrated to the new dashboard experience yet, so it can't be shown here. Reach out to the owner of the dashboard — they can migrate it and re-share the link."
				/>
			)}

			{isError && !isBusy && (
				<PublicDashboardMessage
					testId="public-dashboard-unavailable"
					icon={<Frown size={36} />}
					title="The public dashboard you are looking for does not exist or has been unpublished."
					description="Please reach out to the owner of the dashboard to get access."
				/>
			)}
		</div>
	);
}

export default PublicDashboardPage;