tabs.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import FeatureBadge from 'sentry/components/featureBadge';
  2. import {TabList, Tabs} from 'sentry/components/tabs';
  3. import {useLocation} from 'sentry/utils/useLocation';
  4. import useOrganization from 'sentry/utils/useOrganization';
  5. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  6. interface Props {
  7. selected: 'replays' | 'selectors';
  8. }
  9. const SELECTOR_IDX_ROUTE = 'selectors/';
  10. const REPLAY_IDX_ROUTE = '';
  11. const TABS = [
  12. {key: 'replays', label: 'Replays', badge: null, to: REPLAY_IDX_ROUTE},
  13. {
  14. key: 'selectors',
  15. label: 'Selectors',
  16. badge: <FeatureBadge type="new" />,
  17. to: SELECTOR_IDX_ROUTE,
  18. },
  19. ];
  20. export default function ReplayTabs({selected}: Props) {
  21. const organization = useOrganization();
  22. const hasDeadClickFeature = organization.features.includes(
  23. 'session-replay-rage-dead-selectors'
  24. );
  25. const location = useLocation();
  26. return hasDeadClickFeature ? (
  27. <Tabs value={selected}>
  28. <TabList hideBorder>
  29. {TABS.map(tab => (
  30. <TabList.Item
  31. key={tab.key}
  32. to={{
  33. ...location,
  34. query: location.query,
  35. pathname: normalizeUrl(
  36. `/organizations/${organization.slug}/replays/${tab.to}`
  37. ),
  38. }}
  39. >
  40. {tab.label}
  41. {tab.badge}
  42. </TabList.Item>
  43. ))}
  44. </TabList>
  45. </Tabs>
  46. ) : null;
  47. }