tabs.tsx 1.2 KB

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