diff --git a/public/app/features/explore/QueryLibrary/QueryLibraryContext.tsx b/public/app/features/explore/QueryLibrary/QueryLibraryContext.tsx index db9e131b771..4d72a56f1a1 100644 --- a/public/app/features/explore/QueryLibrary/QueryLibraryContext.tsx +++ b/public/app/features/explore/QueryLibrary/QueryLibraryContext.tsx @@ -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({ @@ -95,6 +97,7 @@ export const QueryLibraryContext = createContext({ context: 'unknown', triggerAnalyticsEvent: () => {}, onSelectQuery: () => {}, + setCloseGuard: () => {}, }); export function useQueryLibraryContext() { diff --git a/public/app/features/explore/QueryLibrary/mocks.tsx b/public/app/features/explore/QueryLibrary/mocks.tsx index a2af3c29278..bbac5371e3b 100644 --- a/public/app/features/explore/QueryLibrary/mocks.tsx +++ b/public/app/features/explore/QueryLibrary/mocks.tsx @@ -20,6 +20,7 @@ export function QueryLibraryContextProviderMock(props: PropsWithChildren) triggerAnalyticsEvent: jest.fn(), setNewQuery: jest.fn(), onSelectQuery: jest.fn(), + setCloseGuard: jest.fn(), }} > {props.children}