Saved Query: Add closeGuard function to support modal warning for unsaved changes (#111940)

* Saved Query: Add closeGuard function to support modal warning for unsaved changes

* fix signature
This commit is contained in:
Alexa Vargas
2025-10-13 13:47:12 +02:00
committed by GitHub
parent f823e09e17
commit 32f1912311
2 changed files with 4 additions and 0 deletions
@@ -73,6 +73,8 @@ export type QueryLibraryContextType = {
) => void;
setNewQuery: (query?: SavedQuery) => void;
onSelectQuery: (query: DataQuery) => void;
/** Set a guard function that returns true to allow closing, false to prevent closing */
setCloseGuard: (shouldAllowClose: () => boolean) => void;
};
export const QueryLibraryContext = createContext<QueryLibraryContextType>({
@@ -95,6 +97,7 @@ export const QueryLibraryContext = createContext<QueryLibraryContextType>({
context: 'unknown',
triggerAnalyticsEvent: () => {},
onSelectQuery: () => {},
setCloseGuard: () => {},
});
export function useQueryLibraryContext() {
@@ -20,6 +20,7 @@ export function QueryLibraryContextProviderMock(props: PropsWithChildren<Props>)
triggerAnalyticsEvent: jest.fn(),
setNewQuery: jest.fn(),
onSelectQuery: jest.fn(),
setCloseGuard: jest.fn(),
}}
>
{props.children}