detailsPageBreadcrumbs.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import {Fragment} from 'react';
  2. import Breadcrumbs from 'sentry/components/breadcrumbs';
  3. import BaseBadge from 'sentry/components/idBadge/baseBadge';
  4. import HeaderPlaceholder from 'sentry/components/replays/header/headerPlaceholder';
  5. import {t} from 'sentry/locale';
  6. import EventView from 'sentry/utils/discover/eventView';
  7. import {getShortEventId} from 'sentry/utils/events';
  8. import {useLocation} from 'sentry/utils/useLocation';
  9. import useProjects from 'sentry/utils/useProjects';
  10. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  11. import type {ReplayRecord} from 'sentry/views/replays/types';
  12. type Props = {
  13. orgSlug: string;
  14. replayRecord: ReplayRecord | undefined;
  15. };
  16. function DetailsPageBreadcrumbs({orgSlug, replayRecord}: Props) {
  17. const location = useLocation();
  18. const eventView = EventView.fromLocation(location);
  19. const {projects} = useProjects();
  20. const project = projects.find(p => p.id === replayRecord?.project_id);
  21. const labelTitle = replayRecord ? (
  22. <Fragment>{getShortEventId(replayRecord?.id)}</Fragment>
  23. ) : (
  24. <HeaderPlaceholder width="100%" height="16px" />
  25. );
  26. return (
  27. <Breadcrumbs
  28. crumbs={[
  29. {
  30. to: {
  31. pathname: normalizeUrl(`/organizations/${orgSlug}/replays/`),
  32. query: eventView.generateQueryStringObject(),
  33. },
  34. label: t('Session Replay'),
  35. },
  36. {
  37. label: (
  38. <Fragment>
  39. {<BaseBadge displayName={labelTitle} project={project} avatarSize={16} />}
  40. </Fragment>
  41. ),
  42. },
  43. ]}
  44. />
  45. );
  46. }
  47. export default DetailsPageBreadcrumbs;