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
This commit is contained in:
Alexa Vargas
2025-09-04 16:52:42 +02:00
committed by GitHub
parent 76c8fcf99d
commit 40bf167cb7
3 changed files with 4 additions and 1 deletions
@@ -70,6 +70,7 @@ export type QueryLibraryContextType = {
contextOverride?: string
) => void;
setNewQuery: (query?: QueryTemplate) => void;
onSelectQuery: (query: DataQuery) => void;
};
export const QueryLibraryContext = createContext<QueryLibraryContextType>({
@@ -91,6 +92,7 @@ export const QueryLibraryContext = createContext<QueryLibraryContextType>({
queryLibraryEnabled: false,
context: 'unknown',
triggerAnalyticsEvent: () => {},
onSelectQuery: () => {},
});
export function useQueryLibraryContext() {
@@ -19,6 +19,7 @@ export function QueryLibraryContextProviderMock(props: PropsWithChildren<Props>)
context: 'explore',
triggerAnalyticsEvent: jest.fn(),
setNewQuery: jest.fn(),
onSelectQuery: jest.fn(),
}}
>
{props.children}
@@ -393,8 +393,8 @@ export class QueryEditorRow<TQuery extends DataQuery> extends PureComponent<Prop
<MaybeQueryLibrarySaveButton
query={query}
app={app}
onSelectQuery={this.onSelectQueryFromLibrary}
onUpdateSuccess={this.onExitQueryLibraryEditingMode}
onSelectQuery={this.onSelectQueryFromLibrary}
/>
)}