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
pull/94268/head
Josh Hunt 9 months ago committed by GitHub
parent e43e430e6a
commit c7c66ccf4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      public/app/features/folders/state/navModel.ts
  2. 6
      public/app/types/folders.ts

@ -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…
Cancel
Save