mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* Replace icons in dashboard and settings * Replace icons in alerting * Update batch of icons * Implement icons accross various files * Style updates * Search: Fix recent and starred icons * Update styling and details * Replace new icon created by unicons * Fix e2e test, styling * Minor styling updates Co-authored-by: Clarity-89 <homes89@ukr.net>
54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
import { NavModel, NavModelItem, NavIndex } from '@grafana/data';
|
|
|
|
function getNotFoundModel(): NavModel {
|
|
const node: NavModelItem = {
|
|
id: 'not-found',
|
|
text: 'Page not found',
|
|
icon: 'exclamation-triangle',
|
|
subTitle: '404 Error',
|
|
url: 'not-found',
|
|
};
|
|
|
|
return {
|
|
node: node,
|
|
main: node,
|
|
};
|
|
}
|
|
|
|
export function getNavModel(navIndex: NavIndex, id: string, fallback?: NavModel, onlyChild = false): NavModel {
|
|
if (navIndex[id]) {
|
|
const node = navIndex[id];
|
|
|
|
let main: NavModelItem;
|
|
if (!onlyChild && node.parentItem) {
|
|
main = { ...node.parentItem };
|
|
|
|
main.children =
|
|
main.children &&
|
|
main.children.map(item => {
|
|
return {
|
|
...item,
|
|
active: item.url === node.url,
|
|
};
|
|
});
|
|
} else {
|
|
main = node;
|
|
}
|
|
|
|
return {
|
|
node: node,
|
|
main: main,
|
|
};
|
|
}
|
|
|
|
if (fallback) {
|
|
return fallback;
|
|
}
|
|
|
|
return getNotFoundModel();
|
|
}
|
|
|
|
export const getTitleFromNavModel = (navModel: NavModel) => {
|
|
return `${navModel.main.text}${navModel.node.text ? ': ' + navModel.node.text : ''}`;
|
|
};
|