mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
Dashboards: Fix dashboard listing when user can't list any folders (#77983)
* return empty list of folder if the user doesn't have the permissions to view folders * fix the empty folder list initialisation
This commit is contained in:
parent
7d2d5fbe89
commit
6097ff255c
@ -4,6 +4,9 @@ import { getGrafanaSearcher, NestedFolderDTO } from 'app/features/search/service
|
||||
import { queryResultToViewItem } from 'app/features/search/service/utils';
|
||||
import { DashboardViewItem } from 'app/features/search/types';
|
||||
|
||||
import { contextSrv } from '../../../core/core';
|
||||
import { AccessControlAction } from '../../../types';
|
||||
|
||||
export const PAGE_SIZE = 50;
|
||||
|
||||
export async function listFolders(
|
||||
@ -18,11 +21,14 @@ export async function listFolders(
|
||||
|
||||
const backendSrv = getBackendSrv();
|
||||
|
||||
const folders = await backendSrv.get<NestedFolderDTO[]>('/api/folders', {
|
||||
parentUid: parentUID,
|
||||
page,
|
||||
limit: pageSize,
|
||||
});
|
||||
let folders: NestedFolderDTO[] = [];
|
||||
if (contextSrv.hasPermission(AccessControlAction.FoldersRead)) {
|
||||
folders = await backendSrv.get<NestedFolderDTO[]>('/api/folders', {
|
||||
parentUid: parentUID,
|
||||
page,
|
||||
limit: pageSize,
|
||||
});
|
||||
}
|
||||
|
||||
return folders.map((item) => ({
|
||||
kind: 'folder',
|
||||
|
Loading…
Reference in New Issue
Block a user