mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
* WIP: intial structure * Refactor: adds create library element endpoint * Feature: adds delete library element * wip * Refactor: adds get api * Refactor: adds get all api * Refactor: adds patch api * Refactor: changes to library_element_connection * Refactor: add get connections api * wip: in the middle of refactor * wip * Refactor: consolidating both api:s * Refactor: points front end to library elements api * Tests: Fixes broken test * LibraryPanels: removes feature toggle * Fix: fixes delete library elements in folder and adds tests * Tests: fixes snapshot * Refactor: adds service interfaces so they can be easily mocked * Refactor: changes order of tabs in manage folder * Refactor: fixes so link does not cover whole card * Refactor: fixes index string name * Update pkg/services/libraryelements/libraryelements.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Update pkg/services/libraryelements/libraryelements_permissions_test.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Update pkg/services/libraryelements/database.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Chore: changes after PR comments * Update libraryelements.go * Update libraryelements.go * Chore: updates after PR comments * Chore: trying to fix build error * Refactor: fixed stupid mistake * Update libraryelements.go * Chore: tries to fix build errors * Refactor: trying to fix MySQL key length * Update libraryelements.go * Update pkg/services/libraryelements/libraryelements.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Update pkg/services/librarypanels/librarypanels.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Refactor: changes after PR comments * Refactor: changes after PR comments * Tests: fixes tests * Refactor: renames connections to connectedDashboards Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
74 lines
1.5 KiB
TypeScript
74 lines
1.5 KiB
TypeScript
import { NavModel, NavModelItem } from '@grafana/data';
|
|
|
|
import { FolderDTO } from 'app/types';
|
|
|
|
export function buildNavModel(folder: FolderDTO): NavModelItem {
|
|
const model = {
|
|
icon: 'folder',
|
|
id: 'manage-folder',
|
|
subTitle: 'Manage folder dashboards and permissions',
|
|
url: '',
|
|
text: folder.title,
|
|
breadcrumbs: [{ title: 'Dashboards', url: 'dashboards' }],
|
|
children: [
|
|
{
|
|
active: false,
|
|
icon: 'apps',
|
|
id: `folder-dashboards-${folder.uid}`,
|
|
text: 'Dashboards',
|
|
url: folder.url,
|
|
},
|
|
],
|
|
};
|
|
|
|
model.children.push({
|
|
active: false,
|
|
icon: 'library-panel',
|
|
id: `folder-library-panels-${folder.uid}`,
|
|
text: 'Panels',
|
|
url: `${folder.url}/library-panels`,
|
|
});
|
|
|
|
if (folder.canAdmin) {
|
|
model.children.push({
|
|
active: false,
|
|
icon: 'lock',
|
|
id: `folder-permissions-${folder.uid}`,
|
|
text: 'Permissions',
|
|
url: `${folder.url}/permissions`,
|
|
});
|
|
}
|
|
|
|
if (folder.canSave) {
|
|
model.children.push({
|
|
active: false,
|
|
icon: 'cog',
|
|
id: `folder-settings-${folder.uid}`,
|
|
text: 'Settings',
|
|
url: `${folder.url}/settings`,
|
|
});
|
|
}
|
|
|
|
return model;
|
|
}
|
|
|
|
export function getLoadingNav(tabIndex: number): NavModel {
|
|
const main = buildNavModel({
|
|
id: 1,
|
|
uid: 'loading',
|
|
title: 'Loading',
|
|
url: 'url',
|
|
canSave: true,
|
|
canEdit: true,
|
|
canAdmin: true,
|
|
version: 0,
|
|
});
|
|
|
|
main.children![tabIndex].active = true;
|
|
|
|
return {
|
|
main: main,
|
|
node: main.children![tabIndex],
|
|
};
|
|
}
|