tabBar.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 {useLocation} from 'sentry/utils/useLocation';
  6. interface Props {
  7. selected: string;
  8. }
  9. export default function TraceExplorerTabs({selected}: Props) {
  10. const location = useLocation();
  11. const tabs = useMemo(
  12. () => [
  13. {
  14. key: 'spans',
  15. label: t('Spans'),
  16. query: {...location.query, exploreTab: 'spans'},
  17. },
  18. {
  19. key: 'logs',
  20. label: t('Logs'),
  21. query: {...location.query, exploreTab: 'logs'},
  22. },
  23. ],
  24. [location.query]
  25. );
  26. return (
  27. <Layout.HeaderTabs value={selected}>
  28. <TabList hideBorder>
  29. {tabs.map(tab => (
  30. <TabList.Item
  31. key={tab.key}
  32. to={{
  33. ...location,
  34. query: tab.query,
  35. }}
  36. >
  37. {tab.label}
  38. </TabList.Item>
  39. ))}
  40. </TabList>
  41. </Layout.HeaderTabs>
  42. );
  43. }