tabs.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. },
  21. {
  22. key: 'selectors',
  23. label: (
  24. <Fragment>
  25. {t('Selectors')} <FeatureBadge type="new" />
  26. </Fragment>
  27. ),
  28. pathname: normalizeUrl(`/organizations/${organization.slug}/replays/selectors/`),
  29. },
  30. ],
  31. [organization.slug]
  32. );
  33. return (
  34. <Tabs value={selected}>
  35. <TabList hideBorder>
  36. {tabs.map(tab => (
  37. <TabList.Item
  38. key={tab.key}
  39. to={{
  40. ...location,
  41. pathname: tab.pathname,
  42. }}
  43. >
  44. {tab.label}
  45. </TabList.Item>
  46. ))}
  47. </TabList>
  48. </Tabs>
  49. );
  50. }