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

This commit is contained in:
Josh Hunt 2023-10-06 14:05:56 +00:00 committed by GitHub
parent 46c1c03183
commit c5914d92d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 6 deletions

View File

@ -539,7 +539,9 @@ export class BackendSrv implements BackendService {
queryParams.set('accesscontrol', 'true'); 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,
});
} }
} }

View File

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

View File

@ -93,8 +93,13 @@ async function fetchDashboard(
// get parent folder (if it exists) and put it in the store // get parent folder (if it exists) and put it in the store
// this will be used to populate the full breadcrumb trail // this will be used to populate the full breadcrumb trail
if (newBrowseDashboardsEnabled() && dashDTO.meta.folderUid) { 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) { if (args.fixUrl && dashDTO.meta.url && !playlistSrv.isPlaying) {
// check if the current url is correct (might be old slug) // check if the current url is correct (might be old slug)
const dashboardUrl = locationUtil.stripBaseFromUrl(dashDTO.meta.url); const dashboardUrl = locationUtil.stripBaseFromUrl(dashDTO.meta.url);