22541 expand breadcrumb route-state helpers for label and dns path reuse
This commit is contained in:
@@ -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/")
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user