mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -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 { queryResultToViewItem } from 'app/features/search/service/utils';
|
||||||
import { DashboardViewItem } from 'app/features/search/types';
|
import { DashboardViewItem } from 'app/features/search/types';
|
||||||
|
|
||||||
|
import { contextSrv } from '../../../core/core';
|
||||||
|
import { AccessControlAction } from '../../../types';
|
||||||
|
|
||||||
export const PAGE_SIZE = 50;
|
export const PAGE_SIZE = 50;
|
||||||
|
|
||||||
export async function listFolders(
|
export async function listFolders(
|
||||||
@ -18,11 +21,14 @@ export async function listFolders(
|
|||||||
|
|
||||||
const backendSrv = getBackendSrv();
|
const backendSrv = getBackendSrv();
|
||||||
|
|
||||||
const folders = await backendSrv.get<NestedFolderDTO[]>('/api/folders', {
|
let folders: NestedFolderDTO[] = [];
|
||||||
parentUid: parentUID,
|
if (contextSrv.hasPermission(AccessControlAction.FoldersRead)) {
|
||||||
page,
|
folders = await backendSrv.get<NestedFolderDTO[]>('/api/folders', {
|
||||||
limit: pageSize,
|
parentUid: parentUID,
|
||||||
});
|
page,
|
||||||
|
limit: pageSize,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return folders.map((item) => ({
|
return folders.map((item) => ({
|
||||||
kind: 'folder',
|
kind: 'folder',
|
||||||
|
Loading…
Reference in New Issue
Block a user