2018-09-02 09:11:21 -05:00
|
|
|
import { NavModel, NavModelItem } from 'app/types';
|
|
|
|
|
2017-12-28 10:01:28 -06:00
|
|
|
export const backendSrv = {
|
|
|
|
get: jest.fn(),
|
2018-01-11 08:42:45 -06:00
|
|
|
getDashboard: jest.fn(),
|
2018-02-01 06:21:24 -06:00
|
|
|
getDashboardByUid: jest.fn(),
|
2018-02-01 15:32:26 -06:00
|
|
|
getFolderByUid: jest.fn(),
|
2018-01-01 11:54:23 -06:00
|
|
|
post: jest.fn(),
|
2017-12-28 10:01:28 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
export function createNavTree(...args) {
|
2018-08-26 10:14:40 -05:00
|
|
|
const root = [];
|
2017-12-28 10:01:28 -06:00
|
|
|
let node = root;
|
2018-08-26 10:14:40 -05:00
|
|
|
for (const arg of args) {
|
|
|
|
const child = { id: arg, url: `/url/${arg}`, text: `${arg}-Text`, children: [] };
|
2017-12-28 10:01:28 -06:00
|
|
|
node.push(child);
|
|
|
|
node = child.children;
|
|
|
|
}
|
2018-01-11 08:42:45 -06:00
|
|
|
|
2017-12-28 10:01:28 -06:00
|
|
|
return root;
|
|
|
|
}
|
2018-09-02 09:11:21 -05:00
|
|
|
|
2018-09-02 12:36:36 -05:00
|
|
|
export function createNavModel(title: string, ...tabs: string[]): NavModel {
|
2018-09-02 09:11:21 -05:00
|
|
|
const node: NavModelItem = {
|
|
|
|
id: title,
|
|
|
|
text: title,
|
|
|
|
icon: 'fa fa-fw fa-warning',
|
|
|
|
subTitle: 'subTitle',
|
|
|
|
url: title,
|
|
|
|
children: [],
|
|
|
|
breadcrumbs: [],
|
|
|
|
};
|
|
|
|
|
2018-09-07 10:55:38 -05:00
|
|
|
for (const tab of tabs) {
|
2018-09-02 09:11:21 -05:00
|
|
|
node.children.push({
|
|
|
|
id: tab,
|
|
|
|
icon: 'icon',
|
|
|
|
subTitle: 'subTitle',
|
|
|
|
url: title,
|
|
|
|
text: title,
|
2018-09-02 12:36:36 -05:00
|
|
|
active: false,
|
2018-09-02 09:11:21 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-09-02 12:36:36 -05:00
|
|
|
node.children[0].active = true;
|
|
|
|
|
2018-09-02 09:11:21 -05:00
|
|
|
return {
|
|
|
|
node: node,
|
|
|
|
main: node,
|
|
|
|
};
|
|
|
|
}
|