2019-04-30 09:46:46 -05:00
|
|
|
import { Team, TeamPermissionLevel } from 'app/types';
|
2018-09-13 07:10:51 -05:00
|
|
|
import config from 'app/core/config';
|
2019-06-18 10:17:27 -05:00
|
|
|
import { NavModelItem, NavModel } from '@grafana/data';
|
2018-09-13 07:10:51 -05:00
|
|
|
|
|
|
|
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,
|
2020-04-16 06:49:58 -05:00
|
|
|
icon: 'users-alt',
|
2018-09-13 07:10:51 -05:00
|
|
|
id: `team-members-${team.id}`,
|
|
|
|
text: 'Members',
|
|
|
|
url: `org/teams/edit/${team.id}/members`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
active: false,
|
2020-04-16 06:49:58 -05:00
|
|
|
icon: 'sliders-v-alt',
|
2018-09-13 07:10:51 -05:00
|
|
|
id: `team-settings-${team.id}`,
|
|
|
|
text: 'Settings',
|
|
|
|
url: `org/teams/edit/${team.id}/settings`,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2020-01-17 08:44:12 -06:00
|
|
|
if (config.licenseInfo.hasLicense) {
|
2018-09-13 07:10:51 -05:00
|
|
|
navModel.children.push({
|
|
|
|
active: false,
|
2020-04-16 06:49:58 -05:00
|
|
|
icon: 'sync',
|
2018-09-13 07:10:51 -05:00
|
|
|
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,
|
2019-03-14 08:24:13 -05:00
|
|
|
permission: TeamPermissionLevel.Member,
|
2018-09-13 07:10:51 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
let node: NavModelItem;
|
|
|
|
|
|
|
|
// find active page
|
2020-07-08 04:05:20 -05:00
|
|
|
for (const child of main.children!) {
|
|
|
|
if (child.id!.indexOf(pageName) > 0) {
|
2018-09-13 07:10:51 -05:00
|
|
|
child.active = true;
|
|
|
|
node = child;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
main: main,
|
2020-07-08 04:05:20 -05:00
|
|
|
node: node!,
|
2018-09-13 07:10:51 -05:00
|
|
|
};
|
|
|
|
}
|