Folders: Don't show error pop-up if the user can't fetch the root folder (#95569)

don't show error pop-up if the user can't read general folder
pull/95599/head^2
Ieva 8 months ago committed by GitHub
parent 87c2bc44b2
commit 092a1813ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      public/app/features/browse-dashboards/BrowseDashboardsPage.tsx
  2. 5
      public/app/features/browse-dashboards/api/browseDashboardsAPI.ts

@ -81,8 +81,10 @@ const BrowseDashboardsPage = memo(() => {
const hasSelection = useHasSelection();
const { data: rootFolder } = useGetFolderQuery('general');
let folder = folderDTO ? folderDTO : rootFolder;
// Fetch the root (aka general) folder if we're not in a specific folder
const { data: rootFolderDTO } = useGetFolderQuery(folderDTO ? skipToken : 'general');
const folder = folderDTO ?? rootFolderDTO;
const { canEditFolders, canEditDashboards, canCreateDashboards, canCreateFolders } = getFolderPermissions(folder);
const hasAdminRights = contextSrv.hasRole('Admin') || contextSrv.isGrafanaAdmin;

@ -66,12 +66,15 @@ interface HardDeleteDashboardArgs {
function createBackendSrvBaseQuery({ baseURL }: { baseURL: string }): BaseQueryFn<RequestOptions> {
async function backendSrvBaseQuery(requestOptions: RequestOptions) {
// Suppress error pop-up for root (aka 'general') folder
const isGeneralFolder = requestOptions.url === `/folders/general`;
requestOptions = isGeneralFolder ? { ...requestOptions, showErrorAlert: false } : requestOptions;
try {
const { data: responseData, ...meta } = await lastValueFrom(
getBackendSrv().fetch({
...requestOptions,
url: baseURL + requestOptions.url,
showErrorAlert: requestOptions.showErrorAlert,
})
);
return { data: responseData, meta };

Loading…
Cancel
Save