Dashboards: Fix Dashboards not loading when user doesn't have permission on the parent folder (#76028)

pull/76142/head
Josh Hunt 2 years ago committed by GitHub
parent 46c1c03183
commit c5914d92d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      public/app/core/services/backend_srv.ts
  2. 12
      public/app/features/dashboard/containers/DashboardPage.tsx
  3. 7
      public/app/features/dashboard/state/initDashboard.ts

@ -539,7 +539,9 @@ export class BackendSrv implements BackendService {
queryParams.set('accesscontrol', 'true');
}
return this.get<FolderDTO>(`/api/folders/${uid}?${queryParams.toString()}`);
return this.get<FolderDTO>(`/api/folders/${uid}?${queryParams.toString()}`, undefined, undefined, {
showErrorAlert: false,
});
}
}

@ -449,10 +449,14 @@ function updateStatePageNavFromProps(props: Props, state: State): State {
if (folderUid && pageNav) {
if (newBrowseDashboardsEnabled()) {
const folderNavModel = getNavModel(navIndex, `folder-dashboards-${folderUid}`).main;
pageNav = {
...pageNav,
parentItem: folderNavModel,
};
// If the folder hasn't loaded (maybe user doesn't have permission on it?) then
// don't show the "page not found" breadcrumb
if (folderNavModel.id !== 'not-found') {
pageNav = {
...pageNav,
parentItem: folderNavModel,
};
}
} else {
// Check if folder changed
if (folderTitle && pageNav.parentItem?.text !== folderTitle) {

@ -93,8 +93,13 @@ async function fetchDashboard(
// get parent folder (if it exists) and put it in the store
// this will be used to populate the full breadcrumb trail
if (newBrowseDashboardsEnabled() && dashDTO.meta.folderUid) {
await dispatch(getFolderByUid(dashDTO.meta.folderUid));
try {
await dispatch(getFolderByUid(dashDTO.meta.folderUid));
} catch (err) {
console.warn('Error fetching parent folder', dashDTO.meta.folderUid, 'for dashboard', err);
}
}
if (args.fixUrl && dashDTO.meta.url && !playlistSrv.isPlaying) {
// check if the current url is correct (might be old slug)
const dashboardUrl = locationUtil.stripBaseFromUrl(dashDTO.meta.url);

Loading…
Cancel
Save