File tree Expand file tree Collapse file tree 6 files changed +53
-67
lines changed
x-pack/legacy/plugins/infra/public
containers/logs/log_filter Expand file tree Collapse file tree 6 files changed +53
-67
lines changed Original file line number Diff line number Diff line change 55 */
66
77export * from './log_filter_state' ;
8- export * from './use_log_filter_url_state ' ;
8+ export * from './with_log_filter_url_state ' ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+ * or more contributor license agreements. Licensed under the Elastic License;
4+ * you may not use this file except in compliance with the Elastic License.
5+ */
6+
7+ import React , { useContext } from 'react' ;
8+ import { LogFilterState , LogFilterStateParams } from './log_filter_state' ;
9+ import { replaceStateKeyInQueryString , UrlStateContainer } from '../../../utils/url_state' ;
10+
11+ type LogFilterUrlState = LogFilterStateParams [ 'filterQueryAsKuery' ] ;
12+
13+ export const WithLogFilterUrlState : React . FC = ( ) => {
14+ const { filterQueryAsKuery, applyLogFilterQuery } = useContext ( LogFilterState . Context ) ;
15+ return (
16+ < UrlStateContainer
17+ urlState = { filterQueryAsKuery }
18+ urlStateKey = "logFilter"
19+ mapToUrlState = { mapToFilterQuery }
20+ onChange = { urlState => {
21+ if ( urlState ) {
22+ applyLogFilterQuery ( urlState . expression ) ;
23+ }
24+ } }
25+ onInitialize = { urlState => {
26+ if ( urlState ) {
27+ applyLogFilterQuery ( urlState . expression ) ;
28+ }
29+ } }
30+ />
31+ ) ;
32+ } ;
33+
34+ const mapToFilterQuery = ( value : any ) : LogFilterUrlState | undefined =>
35+ value ?. kind === 'kuery' && typeof value . expression === 'string'
36+ ? {
37+ kind : value . kind ,
38+ expression : value . expression ,
39+ }
40+ : undefined ;
41+
42+ export const replaceLogFilterInQueryString = ( expression : string ) =>
43+ replaceStateKeyInQueryString < LogFilterUrlState > ( 'logFilter' , {
44+ kind : 'kuery' ,
45+ expression,
46+ } ) ;
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import { PageContent } from '../../../components/page';
1515
1616import { WithSummary } from '../../../containers/logs/log_summary' ;
1717import { LogViewConfiguration } from '../../../containers/logs/log_view_configuration' ;
18- import { LogFilterState , useLogFilterUrlState } from '../../../containers/logs/log_filter' ;
18+ import { LogFilterState } from '../../../containers/logs/log_filter' ;
1919import {
2020 LogFlyout as LogFlyoutState ,
2121 WithFlyoutOptionsUrlState ,
@@ -42,9 +42,6 @@ export const LogsPageLogsContent: React.FunctionComponent = () => {
4242 flyoutItem,
4343 isLoading,
4444 } = useContext ( LogFlyoutState . Context ) ;
45-
46- useLogFilterUrlState ( ) ;
47-
4845 const { logSummaryHighlights } = useContext ( LogHighlightsState . Context ) ;
4946 const { applyLogFilterQuery } = useContext ( LogFilterState . Context ) ;
5047 return (
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import { LogFlyout } from '../../../containers/logs/log_flyout';
1010import { LogViewConfiguration } from '../../../containers/logs/log_view_configuration' ;
1111import { LogHighlightsState } from '../../../containers/logs/log_highlights/log_highlights' ;
1212import { LogPositionState } from '../../../containers/logs/log_position' ;
13- import { LogFilterState } from '../../../containers/logs/log_filter' ;
13+ import { LogFilterState , WithLogFilterUrlState } from '../../../containers/logs/log_filter' ;
1414import { LogEntriesState } from '../../../containers/logs/log_entries' ;
1515
1616import { Source } from '../../../containers/source' ;
@@ -19,7 +19,10 @@ const LogFilterStateProvider: React.FC = ({ children }) => {
1919 const { createDerivedIndexPattern } = useContext ( Source . Context ) ;
2020 const derivedIndexPattern = createDerivedIndexPattern ( 'logs' ) ;
2121 return (
22- < LogFilterState . Provider indexPattern = { derivedIndexPattern } > { children } </ LogFilterState . Provider >
22+ < LogFilterState . Provider indexPattern = { derivedIndexPattern } >
23+ < WithLogFilterUrlState />
24+ { children }
25+ </ LogFilterState . Provider >
2326 ) ;
2427} ;
2528
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments