forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
x-pack/plugins/security_solution/public/common/hooks/use_get_stateful_query_bar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { useMemo } from 'react'; | ||
import { useKibana } from '../lib/kibana'; | ||
|
||
export const useGetStatefulQueryBar = () => { | ||
const { | ||
services: { | ||
navigation: { | ||
ui: { createTopNavWithCustomContext }, | ||
}, | ||
unifiedSearch, | ||
customDataService, | ||
}, | ||
} = useKibana(); | ||
|
||
const { | ||
ui: { getCustomSearchBar }, | ||
} = unifiedSearch; | ||
|
||
const CustomSearchBar = useMemo( | ||
() => | ||
getCustomSearchBar({ | ||
data: customDataService, | ||
}), | ||
[customDataService, getCustomSearchBar] | ||
); | ||
|
||
const CustomStatefulTopNavKqlQueryBar = useMemo(() => { | ||
const customUnifiedSearch = { | ||
...unifiedSearch, | ||
ui: { | ||
...unifiedSearch.ui, | ||
SearchBar: CustomSearchBar, | ||
AggregateQuerySearchBar: CustomSearchBar, | ||
}, | ||
}; | ||
|
||
return createTopNavWithCustomContext(customUnifiedSearch); | ||
}, [CustomSearchBar, createTopNavWithCustomContext, unifiedSearch]); | ||
|
||
return { | ||
CustomStatefulTopNavKqlQueryBar, | ||
}; | ||
}; |