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