sideTabs.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import NavTabs from 'sentry/components/navTabs';
  2. import {t} from 'sentry/locale';
  3. import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent';
  4. import useOrganization from 'sentry/utils/useOrganization';
  5. import useUrlParams from 'sentry/utils/useUrlParams';
  6. const TABS = {
  7. crumbs: t('Breadcrumbs'),
  8. tags: t('Tags'),
  9. };
  10. type Props = {
  11. className?: string;
  12. };
  13. function SideTabs({className}: Props) {
  14. const organization = useOrganization();
  15. const {getParamValue, setParamValue} = useUrlParams('t_side', 'crumbs');
  16. const active = getParamValue();
  17. const createTabChangeHandler = (tab: string) => () => {
  18. trackAdvancedAnalyticsEvent('replay.details-tab-changed', {
  19. tab,
  20. organization,
  21. });
  22. setParamValue(tab);
  23. };
  24. return (
  25. <NavTabs underlined className={className}>
  26. {Object.entries(TABS).map(([tab, label]) => {
  27. return (
  28. <li key={tab} className={active === tab ? 'active' : ''}>
  29. <a onClick={createTabChangeHandler(tab)}>{label}</a>
  30. </li>
  31. );
  32. })}
  33. </NavTabs>
  34. );
  35. }
  36. export default SideTabs;