tabs.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {Fragment, useMemo} from 'react';
  2. import FeatureBadge from 'sentry/components/featureBadge';
  3. import {TabList, Tabs} from 'sentry/components/tabs';
  4. import {t} from 'sentry/locale';
  5. import {useLocation} from 'sentry/utils/useLocation';
  6. import useOrganization from 'sentry/utils/useOrganization';
  7. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  8. interface Props {
  9. selected: 'replays' | 'selectors';
  10. }
  11. export default function ReplayTabs({selected}: Props) {
  12. const organization = useOrganization();
  13. const location = useLocation();
  14. const tabs = useMemo(
  15. () => [
  16. {
  17. key: 'replays',
  18. label: t('Replays'),
  19. pathname: normalizeUrl(`/organizations/${organization.slug}/replays/`),
  20. query: {...location.query, sort: undefined},
  21. },
  22. {
  23. key: 'selectors',
  24. label: (
  25. <Fragment>
  26. {t('Selectors')} <FeatureBadge type="new" />
  27. </Fragment>
  28. ),
  29. pathname: normalizeUrl(`/organizations/${organization.slug}/replays/selectors/`),
  30. query: {...location.query, sort: '-count_dead_clicks'},
  31. },
  32. ],
  33. [organization.slug, location.query]
  34. );
  35. return (
  36. <Tabs value={selected}>
  37. <TabList hideBorder>
  38. {tabs.map(tab => (
  39. <TabList.Item
  40. key={tab.key}
  41. to={{
  42. ...location,
  43. pathname: tab.pathname,
  44. query: tab.query,
  45. }}
  46. >
  47. {tab.label}
  48. </TabList.Item>
  49. ))}
  50. </TabList>
  51. </Tabs>
  52. );
  53. }