mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
BrowseDashboards: Append orgId to folder URL (#96029)
* BrowseDashboards: Append orgId to folder URL * Extract folder URL creation logic
This commit is contained in:
parent
a45deafc96
commit
6bfb24c7b0
@ -6,7 +6,7 @@ import { DashboardViewItem } from 'app/features/search/types';
|
||||
|
||||
import { contextSrv } from '../../../core/core';
|
||||
import { AccessControlAction } from '../../../types';
|
||||
import { isSharedWithMe } from '../components/utils';
|
||||
import { getFolderURL, isSharedWithMe } from '../components/utils';
|
||||
|
||||
export const PAGE_SIZE = 50;
|
||||
|
||||
@ -30,7 +30,6 @@ export async function listFolders(
|
||||
limit: pageSize,
|
||||
});
|
||||
}
|
||||
const subUrlPrefix = config.appSubUrl ?? '';
|
||||
|
||||
return folders.map((item) => ({
|
||||
kind: 'folder',
|
||||
@ -40,7 +39,7 @@ export async function listFolders(
|
||||
parentUID,
|
||||
|
||||
// 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 { contextSrv } from 'app/core/core';
|
||||
|
||||
import { DashboardViewItemWithUIItems } from '../types';
|
||||
|
||||
@ -9,3 +10,15 @@ export function makeRowID(baseId: string, item: DashboardViewItemWithUIItems) {
|
||||
export function isSharedWithMe(uid: string) {
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user