|
@@ -4,6 +4,7 @@ import styled from '@emotion/styled';
|
|
|
import space from 'app/styles/space';
|
|
|
import {IconChevron} from 'app/icons';
|
|
|
import Link from 'app/components/links/link';
|
|
|
+import GlobalSelectionLink from 'app/components/globalSelectionLink';
|
|
|
import overflowEllipsis from 'app/styles/overflowEllipsis';
|
|
|
import {Theme} from 'app/utils/theme';
|
|
|
|
|
@@ -18,6 +19,12 @@ export type Crumb = {
|
|
|
*/
|
|
|
to?: React.ComponentProps<typeof Link>['to'] | null;
|
|
|
|
|
|
+ /**
|
|
|
+ * It will keep the global selection values (projects, environments, time) in the
|
|
|
+ * querystring when navigating (GlobalSelectionLink)
|
|
|
+ */
|
|
|
+ preserveGlobalSelection?: boolean;
|
|
|
+
|
|
|
/**
|
|
|
* Component will try to come up with unique key, but you can provide your own
|
|
|
* (used when mapping over crumbs)
|
|
@@ -54,14 +61,16 @@ const Breadcrumbs = ({crumbs, linkLastItem = false}: Props) => {
|
|
|
|
|
|
return (
|
|
|
<BreadcrumbList>
|
|
|
- {crumbs.map(({label, to, key}, index) => {
|
|
|
+ {crumbs.map(({label, to, preserveGlobalSelection, key}, index) => {
|
|
|
const mapKey =
|
|
|
key ?? typeof to === 'string' ? `${label}${to}` : `${label}${index}`;
|
|
|
|
|
|
return (
|
|
|
<React.Fragment key={mapKey}>
|
|
|
{to ? (
|
|
|
- <BreadcrumbLink to={to}>{label}</BreadcrumbLink>
|
|
|
+ <BreadcrumbLink to={to} preserveGlobalSelection={preserveGlobalSelection}>
|
|
|
+ {label}
|
|
|
+ </BreadcrumbLink>
|
|
|
) : (
|
|
|
<BreadcrumbItem>{label}</BreadcrumbItem>
|
|
|
)}
|
|
@@ -92,7 +101,9 @@ const BreadcrumbList = styled('div')`
|
|
|
padding: ${space(1)} 0;
|
|
|
`;
|
|
|
|
|
|
-const BreadcrumbLink = styled(Link)`
|
|
|
+const BreadcrumbLink = styled(({preserveGlobalSelection, ...props}) =>
|
|
|
+ preserveGlobalSelection ? <GlobalSelectionLink {...props} /> : <Link {...props} />
|
|
|
+)`
|
|
|
${getBreadcrumbListItemStyles}
|
|
|
|
|
|
&:hover,
|