builderBreadCrumbs.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import {PlainRoute} from 'react-router';
  2. import styled from '@emotion/styled';
  3. import type {Location} from 'history';
  4. import Breadcrumbs, {Crumb, CrumbDropdown} from 'sentry/components/breadcrumbs';
  5. import {t} from 'sentry/locale';
  6. import space from 'sentry/styles/space';
  7. import {Organization} from 'sentry/types';
  8. interface Props {
  9. location: Location;
  10. organization: Organization;
  11. projectSlug: string;
  12. routes: PlainRoute[];
  13. title: string;
  14. alertName?: string;
  15. alertType?: string;
  16. canChangeProject?: boolean;
  17. }
  18. function BuilderBreadCrumbs({title, alertName, projectSlug, organization}: Props) {
  19. const crumbs: (Crumb | CrumbDropdown)[] = [
  20. {
  21. to: `/organizations/${organization.slug}/alerts/rules/`,
  22. label: t('Alerts'),
  23. preservePageFilters: true,
  24. },
  25. {
  26. label: title,
  27. ...(alertName
  28. ? {
  29. to: `/organizations/${organization.slug}/alerts/${projectSlug}/wizard`,
  30. preservePageFilters: true,
  31. }
  32. : {}),
  33. },
  34. ];
  35. if (alertName) {
  36. crumbs.push({label: alertName});
  37. }
  38. return <StyledBreadcrumbs crumbs={crumbs} />;
  39. }
  40. const StyledBreadcrumbs = styled(Breadcrumbs)`
  41. margin-bottom: ${space(1)};
  42. `;
  43. export default BuilderBreadCrumbs;