mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
1db9fff056
* First batch of strictNullChecks * Remove undefined * Check an alternative solution * Fix strict nullChecks * Low hanging strictNullChecks * Fixing strict nulls issues and more * Minor change * fixed unit test * Fix feedback * Update public/vendor/ansicolor/ansicolor.ts Co-Authored-By: Dominik Prokop <dominik.prokop@grafana.com> * Update public/vendor/ansicolor/ansicolor.ts Co-Authored-By: Dominik Prokop <dominik.prokop@grafana.com> * Update public/vendor/ansicolor/ansicolor.ts Co-Authored-By: Dominik Prokop <dominik.prokop@grafana.com> * Fix build errors
56 lines
1.0 KiB
TypeScript
56 lines
1.0 KiB
TypeScript
import { NavModel, NavModelItem } from '@grafana/data';
|
|
|
|
export const backendSrv = {
|
|
get: jest.fn(),
|
|
getDashboard: jest.fn(),
|
|
getDashboardByUid: jest.fn(),
|
|
getFolderByUid: jest.fn(),
|
|
post: jest.fn(),
|
|
};
|
|
|
|
export function createNavTree(...args: any[]) {
|
|
const root: any[] = [];
|
|
let node = root;
|
|
for (const arg of args) {
|
|
const child: any = { id: arg, url: `/url/${arg}`, text: `${arg}-Text`, children: [] };
|
|
node.push(child);
|
|
node = child.children;
|
|
}
|
|
|
|
return root;
|
|
}
|
|
|
|
export function createNavModel(title: string, ...tabs: string[]): NavModel {
|
|
const node: NavModelItem = {
|
|
id: title,
|
|
text: title,
|
|
icon: 'fa fa-fw fa-warning',
|
|
subTitle: 'subTitle',
|
|
url: title,
|
|
children: [],
|
|
breadcrumbs: [],
|
|
};
|
|
|
|
const children = [];
|
|
|
|
for (const tab of tabs) {
|
|
children.push({
|
|
id: tab,
|
|
icon: 'icon',
|
|
subTitle: 'subTitle',
|
|
url: title,
|
|
text: title,
|
|
active: false,
|
|
});
|
|
}
|
|
|
|
children[0].active = true;
|
|
|
|
node.children = children;
|
|
|
|
return {
|
|
node: node,
|
|
main: node,
|
|
};
|
|
}
|