tabs.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {useMemo} from 'react';
  2. import * as Layout from 'sentry/components/layouts/thirds';
  3. import {TabList} from 'sentry/components/tabs';
  4. import {t} from 'sentry/locale';
  5. import normalizeUrl from 'sentry/utils/url/normalizeUrl';
  6. import {useLocation} from 'sentry/utils/useLocation';
  7. import useOrganization from 'sentry/utils/useOrganization';
  8. import useAllMobileProj from 'sentry/views/replays/detail/useAllMobileProj';
  9. interface Props {
  10. selected: 'replays' | 'selectors';
  11. }
  12. export default function ReplayTabs({selected}: Props) {
  13. const organization = useOrganization();
  14. const location = useLocation();
  15. const {allMobileProj} = useAllMobileProj({});
  16. const tabs = useMemo(
  17. () => [
  18. {
  19. key: 'replays',
  20. label: t('Replays'),
  21. pathname: normalizeUrl(`/organizations/${organization.slug}/replays/`),
  22. query: {...location.query, sort: undefined},
  23. },
  24. {
  25. key: 'selectors',
  26. label: t('Selectors'),
  27. pathname: normalizeUrl(`/organizations/${organization.slug}/replays/selectors/`),
  28. query: {...location.query, sort: '-count_dead_clicks'},
  29. },
  30. ],
  31. [organization.slug, location.query]
  32. );
  33. return (
  34. <Layout.HeaderTabs 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. query: tab.query,
  43. }}
  44. disabled={tab.key === 'selectors' && allMobileProj}
  45. >
  46. {tab.label}
  47. </TabList.Item>
  48. ))}
  49. </TabList>
  50. </Layout.HeaderTabs>
  51. );
  52. }