From 40bf167cb7ce82958791eecfd090d2693a7c2419 Mon Sep 17 00:00:00 2001 From: Alexa Vargas <239999+axelavargas@users.noreply.github.com> Date: Thu, 4 Sep 2025 16:52:42 +0200 Subject: [PATCH] Saved Query: Add `onSelectQuery` to `QueryLibraryContext ` (#110536) * Saved Query: Remove onSelectQuery prop requirement from components using saved queries * preserve onSelectQueryCallback on SaveQuery * add missing onSelectQueryCallbacks --- .../app/features/explore/QueryLibrary/QueryLibraryContext.tsx | 2 ++ public/app/features/explore/QueryLibrary/mocks.tsx | 1 + public/app/features/query/components/QueryEditorRow.tsx | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/public/app/features/explore/QueryLibrary/QueryLibraryContext.tsx b/public/app/features/explore/QueryLibrary/QueryLibraryContext.tsx index 1930c56d81a..1531805c05c 100644 --- a/public/app/features/explore/QueryLibrary/QueryLibraryContext.tsx +++ b/public/app/features/explore/QueryLibrary/QueryLibraryContext.tsx @@ -70,6 +70,7 @@ export type QueryLibraryContextType = { contextOverride?: string ) => void; setNewQuery: (query?: QueryTemplate) => void; + onSelectQuery: (query: DataQuery) => void; }; export const QueryLibraryContext = createContext({ @@ -91,6 +92,7 @@ export const QueryLibraryContext = createContext({ queryLibraryEnabled: false, context: 'unknown', triggerAnalyticsEvent: () => {}, + onSelectQuery: () => {}, }); export function useQueryLibraryContext() { diff --git a/public/app/features/explore/QueryLibrary/mocks.tsx b/public/app/features/explore/QueryLibrary/mocks.tsx index ecef7d95870..718a3489a64 100644 --- a/public/app/features/explore/QueryLibrary/mocks.tsx +++ b/public/app/features/explore/QueryLibrary/mocks.tsx @@ -19,6 +19,7 @@ export function QueryLibraryContextProviderMock(props: PropsWithChildren) context: 'explore', triggerAnalyticsEvent: jest.fn(), setNewQuery: jest.fn(), + onSelectQuery: jest.fn(), }} > {props.children} diff --git a/public/app/features/query/components/QueryEditorRow.tsx b/public/app/features/query/components/QueryEditorRow.tsx index 438fd609db0..ea3f9db6983 100644 --- a/public/app/features/query/components/QueryEditorRow.tsx +++ b/public/app/features/query/components/QueryEditorRow.tsx @@ -393,8 +393,8 @@ export class QueryEditorRow extends PureComponent )}