mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
wip: dashboard permissions to redux
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { FolderState } from 'app/types';
|
||||
import { DashboardAcl, DashboardAclDTO } from 'app/types/acl';
|
||||
import { Action, ActionTypes } from './actions';
|
||||
import { processAclItems } from 'app/core/utils/acl';
|
||||
|
||||
export const inititalState: FolderState = {
|
||||
id: 0,
|
||||
@@ -36,36 +36,6 @@ export const folderReducer = (state = inititalState, action: Action): FolderStat
|
||||
return state;
|
||||
};
|
||||
|
||||
function processAclItems(items: DashboardAclDTO[]): DashboardAcl[] {
|
||||
return items.map(processAclItem).sort((a, b) => b.sortRank - a.sortRank || a.name.localeCompare(b.name));
|
||||
}
|
||||
|
||||
function processAclItem(dto: DashboardAclDTO): DashboardAcl {
|
||||
const item = dto as DashboardAcl;
|
||||
|
||||
item.sortRank = 0;
|
||||
if (item.userId > 0) {
|
||||
item.name = item.userLogin;
|
||||
item.sortRank = 10;
|
||||
} else if (item.teamId > 0) {
|
||||
item.name = item.team;
|
||||
item.sortRank = 20;
|
||||
} else if (item.role) {
|
||||
item.icon = 'fa fa-fw fa-street-view';
|
||||
item.name = item.role;
|
||||
item.sortRank = 30;
|
||||
if (item.role === 'Editor') {
|
||||
item.sortRank += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.inherited) {
|
||||
item.sortRank += 100;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
export default {
|
||||
folder: folderReducer,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user