sideTabs.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import queryString from 'query-string';
  2. import ListLink from 'sentry/components/links/listLink';
  3. import ScrollableTabs from 'sentry/components/replays/scrollableTabs';
  4. import {t} from 'sentry/locale';
  5. import {useLocation} from 'sentry/utils/useLocation';
  6. import useUrlParams from 'sentry/utils/useUrlParams';
  7. const TABS = {
  8. crumbs: t('Breadcrumbs'),
  9. tags: t('Tags'),
  10. };
  11. type Props = {
  12. className?: string;
  13. };
  14. function SideTabs({className}: Props) {
  15. const {pathname, query} = useLocation();
  16. const {getParamValue, setParamValue} = useUrlParams('t_side', 'crumbs');
  17. const activeTab = getParamValue().toLowerCase();
  18. return (
  19. <ScrollableTabs className={className} underlined>
  20. {Object.entries(TABS).map(([tab, label]) => (
  21. <ListLink
  22. key={tab}
  23. isActive={() => tab === activeTab}
  24. to={`${pathname}?${queryString.stringify({...query, t_side: tab})}`}
  25. onClick={e => {
  26. e.preventDefault();
  27. setParamValue(tab);
  28. }}
  29. >
  30. {label}
  31. </ListLink>
  32. ))}
  33. </ScrollableTabs>
  34. );
  35. }
  36. export default SideTabs;