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:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user