12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import type {ReactNode} from 'react';
- import ListLink from 'sentry/components/links/listLink';
- import ScrollableTabs from 'sentry/components/replays/scrollableTabs';
- import {t} from 'sentry/locale';
- import {trackAnalytics} from 'sentry/utils/analytics';
- import useActiveReplayTab, {TabKey} from 'sentry/utils/replays/hooks/useActiveReplayTab';
- import {useLocation} from 'sentry/utils/useLocation';
- import useOrganization from 'sentry/utils/useOrganization';
- function getReplayTabs({
- isVideoReplay,
- }: {
- isVideoReplay: boolean;
- }): Record<TabKey, ReactNode> {
- // For video replays, we hide the memory tab (not applicable for mobile)
- return {
- [TabKey.BREADCRUMBS]: t('Breadcrumbs'),
- [TabKey.CONSOLE]: t('Console'),
- [TabKey.NETWORK]: t('Network'),
- [TabKey.ERRORS]: t('Errors'),
- [TabKey.TRACE]: t('Trace'),
- [TabKey.MEMORY]: isVideoReplay ? null : t('Memory'),
- [TabKey.TAGS]: t('Tags'),
- };
- }
- type Props = {
- isVideoReplay: boolean;
- className?: string;
- };
- function FocusTabs({className, isVideoReplay}: Props) {
- const organization = useOrganization();
- const {pathname, query} = useLocation();
- const {getActiveTab, setActiveTab} = useActiveReplayTab({isVideoReplay});
- const activeTab = getActiveTab();
- return (
- <ScrollableTabs className={className} underlined>
- {Object.entries(getReplayTabs({isVideoReplay})).map(([tab, label]) =>
- label ? (
- <ListLink
- data-test-id={`replay-details-${tab}-btn`}
- key={tab}
- isActive={() => tab === activeTab}
- to={{pathname, query: {...query, t_main: tab}}}
- onClick={e => {
- e.preventDefault();
- setActiveTab(tab);
- trackAnalytics('replay.details-tab-changed', {
- tab,
- organization,
- mobile: isVideoReplay,
- });
- }}
- >
- {label}
- </ListLink>
- ) : null
- )}
- </ScrollableTabs>
- );
- }
- export default FocusTabs;
|