mirror of
https://github.com/grafana/grafana.git
synced 2025-01-07 14:43:42 -06:00
fd44c01675
* Chore: Fix typescript strict null errors * Added new limit * Fixed ts issue * fixed tests * trying to fix type inference * Fixing more ts errors * Revert tsconfig option * Fix * Fixed code * More fixes * fix tests * Updated snapshot * Chore: More ts strict null fixes * More fixes in some really messed up azure config components * More fixes, current count: 441 * 419 * More fixes * Fixed invalid initial state in explore * Fixing tests * Fixed tests * Explore fix * More fixes * Progress * Sub 300 * Fixed incorrect type * removed unused import
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { backendSrv } from 'app/core/services/backend_srv';
|
|
import { NavModel } from '@grafana/data';
|
|
|
|
export const loadFolderPage = (uid: string, activeChildId: string) => {
|
|
const navModel: Pick<NavModel, 'main'> = {
|
|
main: {
|
|
icon: 'folder-open',
|
|
id: 'manage-folder',
|
|
subTitle: 'Manage folder dashboards & permissions',
|
|
url: '',
|
|
text: '',
|
|
breadcrumbs: [{ title: 'Dashboards', url: 'dashboards' }],
|
|
children: [
|
|
{
|
|
active: activeChildId === 'manage-folder-dashboards',
|
|
icon: 'th-large',
|
|
id: 'manage-folder-dashboards',
|
|
text: 'Dashboards',
|
|
url: 'dashboards',
|
|
},
|
|
{
|
|
active: activeChildId === 'manage-folder-permissions',
|
|
icon: 'lock',
|
|
id: 'manage-folder-permissions',
|
|
text: 'Permissions',
|
|
url: 'dashboards/permissions',
|
|
},
|
|
{
|
|
active: activeChildId === 'manage-folder-settings',
|
|
icon: 'cog',
|
|
id: 'manage-folder-settings',
|
|
text: 'Settings',
|
|
url: 'dashboards/settings',
|
|
},
|
|
],
|
|
},
|
|
};
|
|
|
|
return backendSrv.getFolderByUid(uid).then(folder => {
|
|
const folderTitle = folder.title;
|
|
const folderUrl = folder.url;
|
|
navModel.main.text = folderTitle;
|
|
|
|
const dashTab = navModel.main.children!.find((child: any) => child.id === 'manage-folder-dashboards');
|
|
dashTab!.url = folderUrl;
|
|
|
|
if (folder.canAdmin) {
|
|
const permTab = navModel.main.children!.find((child: any) => child.id === 'manage-folder-permissions');
|
|
permTab!.url = folderUrl + '/permissions';
|
|
|
|
const settingsTab = navModel.main.children!.find((child: any) => child.id === 'manage-folder-settings');
|
|
settingsTab!.url = folderUrl + '/settings';
|
|
} else {
|
|
navModel.main.children = [dashTab!];
|
|
}
|
|
|
|
return { folder, model: navModel };
|
|
});
|
|
};
|