22541 expand breadcrumb route-state helpers for label and dns path reuse

This commit is contained in:
2026-04-09 09:26:19 +01:00
parent 1c06ef1639
commit 59d3ed287c
5 changed files with 120 additions and 30 deletions
+32
View File
@@ -60,3 +60,35 @@ export const resolveSearchResultsHref = ({
query
};
};
export const resolveSearchBreadcrumbLabel = ({
query = {},
getViewAllLabel = () => null,
advancedLabel = "",
addressLabel = "",
defaultLabel = ""
} = {}) => {
const routeState = normalizeRouteStateQuery(query);
const { viewAll, advanced, address, key } = routeState;
if (viewAll) {
return getViewAllLabel(key);
}
const keyedLabel = getViewAllLabel(key);
if (keyedLabel) return keyedLabel;
if (advanced) return advancedLabel;
if (address) return addressLabel;
return defaultLabel;
};
export const isDnsRoutePath = (pathname = "") => {
return (
pathname === "/dns" ||
pathname.startsWith("/dns/") ||
pathname === "/myportal/dns" ||
pathname.startsWith("/myportal/dns/")
);
};