profileHeader.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import {Link} from 'react-router';
  2. import * as Layout from 'sentry/components/layouts/thirds';
  3. import {Breadcrumb} from 'sentry/components/profiling/breadcrumb';
  4. import {t} from 'sentry/locale';
  5. import {
  6. generateProfileDetailsRouteWithQuery,
  7. generateProfileFlamegraphRouteWithQuery,
  8. } from 'sentry/utils/profiling/routes';
  9. import {useLocation} from 'sentry/utils/useLocation';
  10. import useOrganization from 'sentry/utils/useOrganization';
  11. import {useParams} from 'sentry/utils/useParams';
  12. import {useProfileGroup} from 'sentry/views/profiling/profileGroupProvider';
  13. function ProfileHeader() {
  14. const params = useParams();
  15. const location = useLocation();
  16. const organization = useOrganization();
  17. const [profileGroup] = useProfileGroup();
  18. return (
  19. <Layout.Header style={{gridTemplateColumns: 'minmax(0, 1fr)'}}>
  20. <Layout.HeaderContent style={{marginBottom: 0}}>
  21. <Breadcrumb
  22. location={location}
  23. organization={organization}
  24. trails={[
  25. {type: 'landing'},
  26. {
  27. type: 'flamegraph',
  28. payload: {
  29. transaction:
  30. profileGroup.type === 'resolved' ? profileGroup.data.name : '',
  31. profileId: params.eventId ?? '',
  32. projectSlug: params.projectId ?? '',
  33. },
  34. },
  35. ]}
  36. />
  37. </Layout.HeaderContent>
  38. <Layout.HeaderNavTabs underlined>
  39. <li className={location.pathname.endsWith('details/') ? 'active' : undefined}>
  40. <Link
  41. to={generateProfileDetailsRouteWithQuery({
  42. orgSlug: organization.slug,
  43. projectSlug: params.projectId,
  44. profileId: params.eventId,
  45. location,
  46. })}
  47. >
  48. {t('Details')}
  49. </Link>
  50. </li>
  51. <li className={location.pathname.endsWith('flamegraph/') ? 'active' : undefined}>
  52. <Link
  53. to={generateProfileFlamegraphRouteWithQuery({
  54. orgSlug: organization.slug,
  55. projectSlug: params.projectId,
  56. profileId: params.eventId,
  57. location,
  58. })}
  59. >
  60. {t('Flamegraph')}
  61. </Link>
  62. </li>
  63. </Layout.HeaderNavTabs>
  64. </Layout.Header>
  65. );
  66. }
  67. export {ProfileHeader};