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:
parent
e43e430e6a
commit
c7c66ccf4a
@ -3,7 +3,7 @@ import { config } from '@grafana/runtime';
|
||||
import { t } from 'app/core/internationalization';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
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';
|
||||
|
||||
@ -13,7 +13,9 @@ export const getAlertingTabID = (folderUID: string) => `folder-alerting-${folder
|
||||
export const getPermissionsTabID = (folderUID: string) => `folder-permissions-${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 = {
|
||||
icon: 'folder',
|
||||
id: FOLDER_ID,
|
||||
|
@ -5,6 +5,8 @@ export interface FolderListItemDTO {
|
||||
title: string;
|
||||
}
|
||||
|
||||
export type FolderParent = Pick<FolderDTO, 'title' | 'uid' | 'url'>;
|
||||
|
||||
export interface FolderDTO extends WithAccessControlMetadata {
|
||||
canAdmin: boolean;
|
||||
canDelete: boolean;
|
||||
@ -15,7 +17,9 @@ export interface FolderDTO extends WithAccessControlMetadata {
|
||||
hasAcl: boolean;
|
||||
id: number;
|
||||
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;
|
||||
uid: string;
|
||||
updated: string;
|
||||
|
Loading…
Reference in New Issue
Block a user