mirror of
https://github.com/grafana/grafana.git
synced 2025-02-09 23:16:16 -06:00
Navigation: Add tab title to breadcrumbs (#89102)
* show active child in breadcrumb * use activeChild url * only add tab title if not first tab * handle scenes settings breadcrumbs * fix breadcrumbs on starred dashboard settings * display separate crumb
This commit is contained in:
parent
07685646a3
commit
95589ed091
@ -35,6 +35,14 @@ export function buildBreadcrumbs(sectionNav: NavModelItem, pageNav?: NavModelIte
|
||||
const shouldAddCrumb = !node.hideFromBreadcrumbs && !(shouldDedupe && isSamePathAsLastBreadcrumb);
|
||||
|
||||
if (shouldAddCrumb) {
|
||||
const activeChildIndex = node.children?.findIndex((child) => child.active) ?? -1;
|
||||
// Add tab to breadcrumbs if it's not the first active child
|
||||
if (activeChildIndex > 0) {
|
||||
const activeChild = node.children?.[activeChildIndex];
|
||||
if (activeChild) {
|
||||
crumbs.unshift({ text: activeChild.text, href: activeChild.url ?? '' });
|
||||
}
|
||||
}
|
||||
crumbs.unshift({ text: node.text, href: node.url ?? '' });
|
||||
}
|
||||
|
||||
|
@ -178,13 +178,11 @@ function AnnotationsSettingsEditView({
|
||||
onBackToList,
|
||||
onDelete,
|
||||
}: AnnotationsSettingsEditViewProps) {
|
||||
const parentTab = pageNav.children!.find((p) => p.active)!;
|
||||
parentTab.parentItem = pageNav;
|
||||
const { name, query } = annotationLayer.useState();
|
||||
|
||||
const editAnnotationPageNav = {
|
||||
text: name,
|
||||
parentItem: parentTab,
|
||||
parentItem: pageNav,
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -119,12 +119,9 @@ interface EditLinkViewProps {
|
||||
}
|
||||
|
||||
function EditLinkView({ pageNav, link, navModel, dashboard, onChange, onGoBack }: EditLinkViewProps) {
|
||||
const parentTab = pageNav.children!.find((p) => p.active)!;
|
||||
parentTab.parentItem = pageNav;
|
||||
|
||||
const editLinkPageNav = {
|
||||
text: 'Edit link',
|
||||
parentItem: parentTab,
|
||||
parentItem: pageNav,
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -261,13 +261,11 @@ function VariableEditorSettingsView({
|
||||
onDelete,
|
||||
onValidateVariableName,
|
||||
}: VariableEditorSettingsEditViewProps) {
|
||||
const parentTab = pageNav.children!.find((p) => p.active)!;
|
||||
parentTab.parentItem = pageNav;
|
||||
const { name } = variable.useState();
|
||||
|
||||
const editVariablePageNav = {
|
||||
text: name,
|
||||
parentItem: parentTab,
|
||||
parentItem: pageNav,
|
||||
};
|
||||
return (
|
||||
<Page navModel={navModel} pageNav={editVariablePageNav} layout={PageLayoutType.Standard}>
|
||||
|
@ -48,10 +48,7 @@ function getSubPageNav(
|
||||
if (editItem) {
|
||||
return {
|
||||
text: editItem.name,
|
||||
parentItem: parentItem && {
|
||||
...parentItem,
|
||||
url: node.url,
|
||||
},
|
||||
parentItem,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ function getSectionNav(
|
||||
subTitle: page.subTitle,
|
||||
}));
|
||||
|
||||
const pageNavWithSectionParent = applySectionAsParent(pageNav, sectionNav.node);
|
||||
const pageNavWithSectionParent = applySectionAsParent(pageNav, sectionNav.main);
|
||||
|
||||
main.parentItem = pageNavWithSectionParent;
|
||||
|
||||
|
@ -39,12 +39,7 @@ export function LinksSettings({ dashboard, sectionNav, editIndex }: SettingsPage
|
||||
pageNav = {
|
||||
text: title,
|
||||
subTitle: description,
|
||||
};
|
||||
|
||||
const parentUrl = sectionNav.node.url;
|
||||
pageNav.parentItem = sectionNav.node.parentItem && {
|
||||
...sectionNav.node.parentItem,
|
||||
url: parentUrl,
|
||||
parentItem: sectionNav.node.parentItem,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -108,12 +108,7 @@ class VariableEditorContainerUnconnected extends PureComponent<Props, State> {
|
||||
const { editIndex, variables, sectionNav } = this.props;
|
||||
const variableToEdit = editIndex != null ? variables[editIndex] : undefined;
|
||||
const node = sectionNav.node;
|
||||
const parentItem = node.parentItem
|
||||
? {
|
||||
...node.parentItem,
|
||||
url: node.url,
|
||||
}
|
||||
: undefined;
|
||||
const parentItem = node.parentItem;
|
||||
const subPageNav = variableToEdit ? { text: variableToEdit.name, parentItem } : parentItem;
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user