[v11.3.x] Folders: Don't show error pop-up if the user can't fetch the root folder (#95600)

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

(cherry picked from commit 092a1813ef)

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-10-30 11:06:06 +00:00
committed by GitHub
co-authored by Ieva
parent 7f36355451
commit 1540c767cc
2 changed files with 8 additions and 3 deletions
@@ -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 };