mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
BrowseDashboards: Limit the type for folder parents to just a few fields (#94244)
* BrowseDashboards: Limit the type for folder parents to just title, uid, and url * export type, use in buildNavModel
This commit is contained in:
@@ -3,7 +3,7 @@ import { config } from '@grafana/runtime';
|
|||||||
import { t } from 'app/core/internationalization';
|
import { t } from 'app/core/internationalization';
|
||||||
import { contextSrv } from 'app/core/services/context_srv';
|
import { contextSrv } from 'app/core/services/context_srv';
|
||||||
import { getNavSubTitle } from 'app/core/utils/navBarItem-translations';
|
import { getNavSubTitle } from 'app/core/utils/navBarItem-translations';
|
||||||
import { AccessControlAction, FolderDTO } from 'app/types';
|
import { AccessControlAction, FolderDTO, FolderParent } from 'app/types';
|
||||||
|
|
||||||
export const FOLDER_ID = 'manage-folder';
|
export const FOLDER_ID = 'manage-folder';
|
||||||
|
|
||||||
@@ -13,7 +13,9 @@ export const getAlertingTabID = (folderUID: string) => `folder-alerting-${folder
|
|||||||
export const getPermissionsTabID = (folderUID: string) => `folder-permissions-${folderUID}`;
|
export const getPermissionsTabID = (folderUID: string) => `folder-permissions-${folderUID}`;
|
||||||
export const getSettingsTabID = (folderUID: string) => `folder-settings-${folderUID}`;
|
export const getSettingsTabID = (folderUID: string) => `folder-settings-${folderUID}`;
|
||||||
|
|
||||||
export function buildNavModel(folder: FolderDTO, parents = folder.parents): NavModelItem {
|
export function buildNavModel(folder: FolderDTO | FolderParent, parentsArg?: FolderParent[]): NavModelItem {
|
||||||
|
const parents = parentsArg ?? ('parents' in folder ? folder.parents : undefined);
|
||||||
|
|
||||||
const model: NavModelItem = {
|
const model: NavModelItem = {
|
||||||
icon: 'folder',
|
icon: 'folder',
|
||||||
id: FOLDER_ID,
|
id: FOLDER_ID,
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ export interface FolderListItemDTO {
|
|||||||
title: string;
|
title: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type FolderParent = Pick<FolderDTO, 'title' | 'uid' | 'url'>;
|
||||||
|
|
||||||
export interface FolderDTO extends WithAccessControlMetadata {
|
export interface FolderDTO extends WithAccessControlMetadata {
|
||||||
canAdmin: boolean;
|
canAdmin: boolean;
|
||||||
canDelete: boolean;
|
canDelete: boolean;
|
||||||
@@ -15,7 +17,9 @@ export interface FolderDTO extends WithAccessControlMetadata {
|
|||||||
hasAcl: boolean;
|
hasAcl: boolean;
|
||||||
id: number;
|
id: number;
|
||||||
parentUid?: string;
|
parentUid?: string;
|
||||||
parents?: FolderDTO[];
|
|
||||||
|
// The API does actually return a full FolderDTO here, but we want to restrict it to just a few properties
|
||||||
|
parents?: FolderParent[];
|
||||||
title: string;
|
title: string;
|
||||||
uid: string;
|
uid: string;
|
||||||
updated: string;
|
updated: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user