mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* 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
70 lines
1.6 KiB
TypeScript
70 lines
1.6 KiB
TypeScript
import { Team, TeamPermissionLevel } from 'app/types';
|
|
import config from 'app/core/config';
|
|
import { NavModelItem, NavModel } from '@grafana/data';
|
|
|
|
export function buildNavModel(team: Team): NavModelItem {
|
|
const navModel = {
|
|
img: team.avatarUrl,
|
|
id: 'team-' + team.id,
|
|
subTitle: 'Manage members & settings',
|
|
url: '',
|
|
text: team.name,
|
|
breadcrumbs: [{ title: 'Teams', url: 'org/teams' }],
|
|
children: [
|
|
{
|
|
active: false,
|
|
icon: 'users-alt',
|
|
id: `team-members-${team.id}`,
|
|
text: 'Members',
|
|
url: `org/teams/edit/${team.id}/members`,
|
|
},
|
|
{
|
|
active: false,
|
|
icon: 'sliders-v-alt',
|
|
id: `team-settings-${team.id}`,
|
|
text: 'Settings',
|
|
url: `org/teams/edit/${team.id}/settings`,
|
|
},
|
|
],
|
|
};
|
|
|
|
if (config.licenseInfo.hasLicense) {
|
|
navModel.children.push({
|
|
active: false,
|
|
icon: 'sync',
|
|
id: `team-groupsync-${team.id}`,
|
|
text: 'External group sync',
|
|
url: `org/teams/edit/${team.id}/groupsync`,
|
|
});
|
|
}
|
|
|
|
return navModel;
|
|
}
|
|
|
|
export function getTeamLoadingNav(pageName: string): NavModel {
|
|
const main = buildNavModel({
|
|
avatarUrl: 'public/img/user_profile.png',
|
|
id: 1,
|
|
name: 'Loading',
|
|
email: 'loading',
|
|
memberCount: 0,
|
|
permission: TeamPermissionLevel.Member,
|
|
});
|
|
|
|
let node: NavModelItem;
|
|
|
|
// find active page
|
|
for (const child of main.children!) {
|
|
if (child.id!.indexOf(pageName) > 0) {
|
|
child.active = true;
|
|
node = child;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return {
|
|
main: main,
|
|
node: node!,
|
|
};
|
|
}
|