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
pull/78011/head
Ieva 2 years ago committed by GitHub
parent 7d2d5fbe89
commit 6097ff255c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      public/app/features/browse-dashboards/api/services.ts

@ -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', {
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…
Cancel
Save