2023-04-17 05:08:24 -05:00
|
|
|
import { Chance } from 'chance';
|
|
|
|
|
|
|
|
import { DashboardViewItem } from 'app/features/search/types';
|
|
|
|
|
2023-04-19 14:44:07 -05:00
|
|
|
import { DashboardsTreeItem, UIDashboardViewItem } from '../types';
|
|
|
|
|
|
|
|
export function wellFormedEmptyFolder(
|
|
|
|
seed = 1,
|
|
|
|
partial?: Partial<DashboardsTreeItem<UIDashboardViewItem>>
|
|
|
|
): DashboardsTreeItem<UIDashboardViewItem> {
|
|
|
|
const random = Chance(seed);
|
2023-04-17 05:08:24 -05:00
|
|
|
|
|
|
|
return {
|
|
|
|
item: {
|
|
|
|
kind: 'ui-empty-folder',
|
2023-04-19 14:44:07 -05:00
|
|
|
uid: random.guid(),
|
2023-04-17 05:08:24 -05:00
|
|
|
},
|
|
|
|
level: 0,
|
|
|
|
isOpen: false,
|
2023-04-19 14:44:07 -05:00
|
|
|
...partial,
|
2023-04-17 05:08:24 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-04-19 14:44:07 -05:00
|
|
|
export function wellFormedDashboard(
|
|
|
|
seed = 1,
|
|
|
|
partial?: Partial<DashboardsTreeItem<DashboardViewItem>>,
|
|
|
|
itemPartial?: Partial<DashboardViewItem>
|
|
|
|
): DashboardsTreeItem<DashboardViewItem> {
|
|
|
|
const random = Chance(seed);
|
|
|
|
|
2023-04-17 05:08:24 -05:00
|
|
|
return {
|
|
|
|
item: {
|
|
|
|
kind: 'dashboard',
|
|
|
|
title: random.sentence({ words: 3 }),
|
|
|
|
uid: random.guid(),
|
|
|
|
tags: [random.word()],
|
2023-04-19 14:44:07 -05:00
|
|
|
...itemPartial,
|
2023-04-17 05:08:24 -05:00
|
|
|
},
|
|
|
|
level: 0,
|
|
|
|
isOpen: false,
|
2023-04-19 14:44:07 -05:00
|
|
|
...partial,
|
2023-04-17 05:08:24 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-04-19 14:44:07 -05:00
|
|
|
export function wellFormedFolder(
|
|
|
|
seed = 1,
|
|
|
|
partial?: Partial<DashboardsTreeItem<DashboardViewItem>>,
|
|
|
|
itemPartial?: Partial<DashboardViewItem>
|
|
|
|
): DashboardsTreeItem<DashboardViewItem> {
|
|
|
|
const random = Chance(seed);
|
2023-05-15 07:26:55 -05:00
|
|
|
const uid = random.guid();
|
2023-04-19 14:44:07 -05:00
|
|
|
|
2023-04-17 05:08:24 -05:00
|
|
|
return {
|
|
|
|
item: {
|
|
|
|
kind: 'folder',
|
|
|
|
title: random.sentence({ words: 3 }),
|
2023-05-15 07:26:55 -05:00
|
|
|
uid,
|
|
|
|
url: `/dashboards/f/${uid}`,
|
2023-04-19 14:44:07 -05:00
|
|
|
...itemPartial,
|
2023-04-17 05:08:24 -05:00
|
|
|
},
|
|
|
|
level: 0,
|
|
|
|
isOpen: true,
|
2023-04-19 14:44:07 -05:00
|
|
|
...partial,
|
2023-04-17 05:08:24 -05:00
|
|
|
};
|
|
|
|
}
|
2023-04-19 14:44:07 -05:00
|
|
|
|
|
|
|
export function wellFormedTree() {
|
|
|
|
let seed = 1;
|
|
|
|
|
|
|
|
// prettier-ignore so its easier to see the tree structure
|
|
|
|
/* prettier-ignore */ const folderA = wellFormedFolder(seed++);
|
|
|
|
/* prettier-ignore */ const folderA_folderA = wellFormedFolder(seed++, { level: 1}, { parentUID: folderA.item.uid });
|
|
|
|
/* prettier-ignore */ const folderA_folderB = wellFormedFolder(seed++, { level: 1}, { parentUID: folderA.item.uid });
|
|
|
|
/* prettier-ignore */ const folderA_folderB_dashbdA = wellFormedDashboard(seed++, { level: 2}, { parentUID: folderA_folderB.item.uid });
|
|
|
|
/* prettier-ignore */ const folderA_folderB_dashbdB = wellFormedDashboard(seed++, { level: 2}, { parentUID: folderA_folderB.item.uid });
|
|
|
|
/* prettier-ignore */ const folderA_folderC = wellFormedFolder(seed++, { level: 1},{ parentUID: folderA.item.uid });
|
|
|
|
/* prettier-ignore */ const folderA_folderC_dashbdA = wellFormedDashboard(seed++, { level: 2}, { parentUID: folderA_folderC.item.uid });
|
|
|
|
/* prettier-ignore */ const folderA_folderC_dashbdB = wellFormedDashboard(seed++, { level: 2}, { parentUID: folderA_folderC.item.uid });
|
|
|
|
/* prettier-ignore */ const folderA_dashbdD = wellFormedDashboard(seed++, { level: 1}, { parentUID: folderA.item.uid });
|
|
|
|
/* prettier-ignore */ const folderB = wellFormedFolder(seed++);
|
|
|
|
/* prettier-ignore */ const folderB_empty = wellFormedEmptyFolder(seed++);
|
|
|
|
/* prettier-ignore */ const folderC = wellFormedFolder(seed++);
|
|
|
|
/* prettier-ignore */ const dashbdD = wellFormedDashboard(seed++);
|
|
|
|
/* prettier-ignore */ const dashbdE = wellFormedDashboard(seed++);
|
|
|
|
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
folderA,
|
|
|
|
folderA_folderA,
|
|
|
|
folderA_folderB,
|
|
|
|
folderA_folderB_dashbdA,
|
|
|
|
folderA_folderB_dashbdB,
|
|
|
|
folderA_folderC,
|
|
|
|
folderA_folderC_dashbdA,
|
|
|
|
folderA_folderC_dashbdB,
|
|
|
|
folderA_dashbdD,
|
|
|
|
folderB,
|
|
|
|
folderB_empty,
|
|
|
|
folderC,
|
|
|
|
dashbdD,
|
|
|
|
dashbdE,
|
|
|
|
],
|
|
|
|
{
|
|
|
|
folderA,
|
|
|
|
folderA_folderA,
|
|
|
|
folderA_folderB,
|
|
|
|
folderA_folderB_dashbdA,
|
|
|
|
folderA_folderB_dashbdB,
|
|
|
|
folderA_folderC,
|
|
|
|
folderA_folderC_dashbdA,
|
|
|
|
folderA_folderC_dashbdB,
|
|
|
|
folderA_dashbdD,
|
|
|
|
folderB,
|
|
|
|
folderB_empty,
|
|
|
|
folderC,
|
|
|
|
dashbdD,
|
|
|
|
dashbdE,
|
|
|
|
},
|
|
|
|
] as const;
|
|
|
|
}
|