diff --git a/public/app/features/explore/QueryLibrary/QueryLibraryContext.tsx b/public/app/features/explore/QueryLibrary/QueryLibraryContext.tsx index ec11d830cd1..6f05b78689e 100644 --- a/public/app/features/explore/QueryLibrary/QueryLibraryContext.tsx +++ b/public/app/features/explore/QueryLibrary/QueryLibraryContext.tsx @@ -2,8 +2,9 @@ import { createContext, ReactNode, useContext } from 'react'; import { CoreApp } from '@grafana/data'; import { DataQuery } from '@grafana/schema'; +import { SavedQuery } from 'app/features/explore/QueryLibrary/types'; -import { OnSelectQueryType, QueryTemplate, QueryLibraryEventsPropertyMap } from './types'; +import { OnSelectQueryType, QueryLibraryEventsPropertyMap } from './types'; export type QueryLibraryDrawerOptions = { datasourceFilters?: string[]; @@ -70,7 +71,7 @@ export type QueryLibraryContextType = { properties?: QueryLibraryEventsPropertyMap, contextOverride?: string ) => void; - setNewQuery: (query?: QueryTemplate) => void; + setNewQuery: (query?: SavedQuery) => void; onSelectQuery: (query: DataQuery) => void; }; diff --git a/public/app/features/explore/QueryLibrary/types.ts b/public/app/features/explore/QueryLibrary/types.ts index e8890c0b778..c0934ccbf3b 100644 --- a/public/app/features/explore/QueryLibrary/types.ts +++ b/public/app/features/explore/QueryLibrary/types.ts @@ -10,18 +10,26 @@ export type OnSelectQueryType = (query: DataQuery) => void; export type QueryLibraryEventsPropertyMap = Record; -export type QueryTemplate = { +// flattened data from API response to facilitate structs +export type SavedQueryBase = { + uid: string; + title: string; + description: string; + tags: string[]; + isLocked: boolean; + isVisible: boolean; + createdAtTimestamp: number; + user: User; + targets: DataQuery[]; +}; +// this should actually be like this, but not posssible due to enterprise Spec +// & Required>; + +// our model of SavedQuery to use throughout the frontend +export type SavedQuery = { query: DataQuery; datasourceName?: string; - title?: string; - description?: string; - tags?: string[]; - isLocked?: boolean; - isVisible?: boolean; queryText?: string; datasourceRef?: DataSourceRef | null; datasourceType?: string; - createdAtTimestamp?: number; - user?: User; - uid?: string; -}; +} & Omit, 'targets'>;