builderBreadCrumbs.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import styled from '@emotion/styled';
  2. import type {Location} from 'history';
  3. import Breadcrumbs, {Crumb, CrumbDropdown} from 'sentry/components/breadcrumbs';
  4. import {t} from 'sentry/locale';
  5. import space from 'sentry/styles/space';
  6. import {Organization} from 'sentry/types';
  7. import type {RouteWithName} from 'sentry/views/settings/components/settingsBreadcrumb/types';
  8. interface Props {
  9. location: Location;
  10. organization: Organization;
  11. projectSlug: string;
  12. routes: RouteWithName[];
  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. font-size: 18px;
  42. margin-bottom: ${space(3)};
  43. `;
  44. export default BuilderBreadCrumbs;