useModuleBreadcrumbs.tsx 837 B

12345678910111213141516171819202122232425
  1. import type {Crumb} from 'sentry/components/breadcrumbs';
  2. import {useModuleURL} from 'sentry/views/insights/common/utils/useModuleURL';
  3. import {INSIGHTS_TITLE, MODULE_TITLES} from 'sentry/views/insights/settings';
  4. import type {ModuleName} from 'sentry/views/insights/types';
  5. type ModuleNameStrings = `${ModuleName}`;
  6. type RoutableModuleNames = Exclude<ModuleNameStrings, '' | 'other'>;
  7. export function useModuleBreadcrumbs(moduleName: RoutableModuleNames): Crumb[] {
  8. const moduleTitle = MODULE_TITLES[moduleName];
  9. const moduleTo = useModuleURL(moduleName);
  10. return [
  11. {
  12. label: INSIGHTS_TITLE,
  13. to: undefined, // There is no page at `/insights/` so there is nothing to link to
  14. preservePageFilters: true,
  15. },
  16. {
  17. label: moduleTitle,
  18. to: moduleTo,
  19. preservePageFilters: true,
  20. },
  21. ];
  22. }