profileHeader.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. generateProfileFlamechartRouteWithQuery,
  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. const transaction = profileGroup.type === 'resolved' ? profileGroup.data.name : '';
  19. const profileId = params.eventId ?? '';
  20. const projectSlug = params.projectId ?? '';
  21. return (
  22. <Layout.Header style={{gridTemplateColumns: 'minmax(0, 1fr)'}}>
  23. <Layout.HeaderContent style={{marginBottom: 0}}>
  24. <Breadcrumb
  25. location={location}
  26. organization={organization}
  27. trails={[
  28. {type: 'landing'},
  29. {
  30. type: 'profile summary',
  31. payload: {
  32. projectSlug,
  33. transaction,
  34. },
  35. },
  36. {
  37. type: 'flamechart',
  38. payload: {
  39. transaction,
  40. profileId,
  41. projectSlug,
  42. tab: location.pathname.endsWith('details/') ? 'details' : 'flamechart',
  43. },
  44. },
  45. ]}
  46. />
  47. </Layout.HeaderContent>
  48. <Layout.HeaderNavTabs underlined>
  49. <li className={location.pathname.endsWith('flamechart/') ? 'active' : undefined}>
  50. <Link
  51. to={generateProfileFlamechartRouteWithQuery({
  52. orgSlug: organization.slug,
  53. projectSlug,
  54. profileId,
  55. location,
  56. })}
  57. >
  58. {t('Flamechart')}
  59. </Link>
  60. </li>
  61. <li className={location.pathname.endsWith('details/') ? 'active' : undefined}>
  62. <Link
  63. to={generateProfileDetailsRouteWithQuery({
  64. orgSlug: organization.slug,
  65. projectSlug,
  66. profileId,
  67. location,
  68. })}
  69. >
  70. {t('Details')}
  71. </Link>
  72. </li>
  73. </Layout.HeaderNavTabs>
  74. </Layout.Header>
  75. );
  76. }
  77. export {ProfileHeader};