BrowseDashboards: Append orgId to folder URL (#96029)
* BrowseDashboards: Append orgId to folder URL * Extract folder URL creation logic
This commit is contained in:
@@ -6,7 +6,7 @@ import { DashboardViewItem } from 'app/features/search/types';
|
|||||||
|
|
||||||
import { contextSrv } from '../../../core/core';
|
import { contextSrv } from '../../../core/core';
|
||||||
import { AccessControlAction } from '../../../types';
|
import { AccessControlAction } from '../../../types';
|
||||||
import { isSharedWithMe } from '../components/utils';
|
import { getFolderURL, isSharedWithMe } from '../components/utils';
|
||||||
|
|
||||||
export const PAGE_SIZE = 50;
|
export const PAGE_SIZE = 50;
|
||||||
|
|
||||||
@@ -30,7 +30,6 @@ export async function listFolders(
|
|||||||
limit: pageSize,
|
limit: pageSize,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const subUrlPrefix = config.appSubUrl ?? '';
|
|
||||||
|
|
||||||
return folders.map((item) => ({
|
return folders.map((item) => ({
|
||||||
kind: 'folder',
|
kind: 'folder',
|
||||||
@@ -40,7 +39,7 @@ export async function listFolders(
|
|||||||
parentUID,
|
parentUID,
|
||||||
|
|
||||||
// URLs from the backend come with subUrlPrefix already included, so match that behaviour here
|
// URLs from the backend come with subUrlPrefix already included, so match that behaviour here
|
||||||
url: isSharedWithMe(item.uid) ? undefined : `${subUrlPrefix}/dashboards/f/${item.uid}/`,
|
url: isSharedWithMe(item.uid) ? undefined : getFolderURL(item.uid),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { config } from '@grafana/runtime';
|
import { config } from '@grafana/runtime';
|
||||||
|
import { contextSrv } from 'app/core/core';
|
||||||
|
|
||||||
import { DashboardViewItemWithUIItems } from '../types';
|
import { DashboardViewItemWithUIItems } from '../types';
|
||||||
|
|
||||||
@@ -9,3 +10,15 @@ export function makeRowID(baseId: string, item: DashboardViewItemWithUIItems) {
|
|||||||
export function isSharedWithMe(uid: string) {
|
export function isSharedWithMe(uid: string) {
|
||||||
return uid === config.sharedWithMeFolderUID;
|
return uid === config.sharedWithMeFolderUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Construct folder URL and append orgId to it
|
||||||
|
export function getFolderURL(uid: string) {
|
||||||
|
const { orgId } = contextSrv.user;
|
||||||
|
const subUrlPrefix = config.appSubUrl ?? '';
|
||||||
|
const url = `${subUrlPrefix}/dashboards/f/${uid}/`;
|
||||||
|
|
||||||
|
if (orgId) {
|
||||||
|
return `${url}?orgId=${orgId}`;
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user