tabs.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. const hasDeadClickFeature = organization.features.includes(
  34. 'session-replay-rage-dead-selectors'
  35. );
  36. return hasDeadClickFeature ? (
  37. <Tabs value={selected}>
  38. <TabList hideBorder>
  39. {tabs.map(tab => (
  40. <TabList.Item
  41. key={tab.key}
  42. to={{
  43. ...location,
  44. pathname: tab.pathname,
  45. }}
  46. >
  47. {tab.label}
  48. </TabList.Item>
  49. ))}
  50. </TabList>
  51. </Tabs>
  52. ) : null;
  53. }