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.6 KB
Raw Blame
import { Typography } from '@signozhq/ui/typography';

import { useBlockedNavigationStore } from './blockedNavigationStore';

import styles from './NavigationBlockedOverlay.module.scss';

/**
 * Surfaces every navigation the story swallowed. Rendered by `withProviders`,
 * so any story that tries to leave the page says so instead of silently
 * doing nothing.
 */
function NavigationBlockedOverlay(): JSX.Element | null {
	const blockedNavigations = useBlockedNavigationStore(
		(state) => state.blockedNavigations,
	);
	const clear = useBlockedNavigationStore((state) => state.clear);

	if (blockedNavigations.length === 0) {
		return null;
	}

	return (
		<aside
			className={styles.overlay}
			aria-live="polite"
			data-testid="navigation-blocked-overlay"
		>
			<div className={styles.header}>
				<Typography.Text as="span" size="small" weight="semibold" color="warning">
					Navigation blocked in Storybook
				</Typography.Text>
				<div className={styles.actions}>
					<button
						type="button"
						className={styles.button}
						onClick={clear}
						data-testid="navigation-blocked-clear"
					>
						<Typography.Text as="span" size="small" weight="medium">
							clear
						</Typography.Text>
					</button>
				</div>
			</div>
			<ul className={styles.list}>
				{blockedNavigations.map((navigation) => (
					<li key={navigation.id} className={styles.item}>
						<Typography.Text as="span" size="small" color="muted">
							{navigation.via}
						</Typography.Text>{' '}
						<Typography.Text as="span" size="small">
							→ {navigation.to}
						</Typography.Text>
					</li>
				))}
			</ul>
		</aside>
	);
}

export default NavigationBlockedOverlay;