Skip to content

Commit 7f07675

Browse files
committed
cleanup
1 parent 4e7bff5 commit 7f07675

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

x-pack/solutions/observability/plugins/slo/public/pages/slos/components/slo_list_search_bar.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
*/
77

88
import { css } from '@emotion/react';
9+
import type { Query } from '@kbn/es-query';
910
import { i18n } from '@kbn/i18n';
1011
import { observabilityAppId } from '@kbn/observability-plugin/public';
11-
import React from 'react';
12+
import React, { useEffect } from 'react';
1213
import { useKibana } from '../../../hooks/use_kibana';
1314
import { useSloCrudLoading } from '../hooks/use_crud_loading';
1415
import { useSloSummaryDataView } from '../hooks/use_summary_dataview';
@@ -17,6 +18,7 @@ import { QuickFilters } from './common/quick_filters';
1718

1819
export function SloListSearchBar() {
1920
const {
21+
data: { query },
2022
unifiedSearch: {
2123
ui: { SearchBar },
2224
},
@@ -27,6 +29,18 @@ export function SloListSearchBar() {
2729

2830
const { isLoading: isDataViewLoading, data: dataView } = useSloSummaryDataView();
2931

32+
useEffect(() => {
33+
const sub = query.state$.subscribe(() => {
34+
const queryState = query.getState();
35+
onStateChange({
36+
kqlQuery: String((queryState.query as Query).query),
37+
filters: queryState.filters,
38+
});
39+
});
40+
41+
return () => sub.unsubscribe();
42+
}, [onStateChange, query]);
43+
3044
return (
3145
<div
3246
css={css`
@@ -36,14 +50,12 @@ export function SloListSearchBar() {
3650
`}
3751
>
3852
<SearchBar
39-
key={`${state.kqlQuery}-${JSON.stringify(state.filters)}`}
4053
appName={observabilityAppId}
4154
placeholder={PLACEHOLDER}
4255
indexPatterns={dataView ? [dataView] : []}
4356
isDisabled={isSloCrudLoading}
4457
renderQueryInputAppend={() => (
4558
<QuickFilters
46-
key={`quick-filters-${state.tagsFilter?.meta?.key}-${state.statusFilter?.meta?.key}`}
4759
dataView={dataView}
4860
initialState={state}
4961
loading={isSloCrudLoading || isDataViewLoading}

x-pack/solutions/observability/plugins/slo/public/pages/slos/components/slos_overview/overview_item.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ export function OverviewItem({
4444
}
4545
onStateChange({
4646
kqlQuery: query,
47-
filters: [],
48-
tagsFilter: undefined,
49-
statusFilter: undefined,
5047
});
5148
}}
5249
css={{

x-pack/solutions/observability/plugins/slo/public/pages/slos/hooks/use_url_search_state.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const DEFAULT_STATE: SearchState = {
4949

5050
export function useUrlSearchState(): {
5151
state: SearchState;
52-
onStateChange: (state: Partial<SearchState>, options?: { replace?: boolean }) => void;
52+
onStateChange: (state: Partial<SearchState>) => void;
5353
} {
5454
const [state, setState] = useState<SearchState>(DEFAULT_STATE);
5555
const history = useHistory();
@@ -84,14 +84,12 @@ export function useUrlSearchState(): {
8484
}, [urlStateStorage, sessionStorage]);
8585

8686
const onStateChange = useCallback(
87-
(newState: Partial<SearchState>, options?: { replace?: boolean }) => {
87+
(newState: Partial<SearchState>) => {
8888
const updatedState = { ...state, page: 0, ...newState };
8989
setState(() => updatedState);
9090

91-
// Use push (replace: false) by default to create new history entries
92-
// This allows back button to work properly
9391
urlStateStorage.current?.set(SLO_LIST_SEARCH_URL_STORAGE_KEY, updatedState, {
94-
replace: options?.replace ?? false,
92+
replace: false,
9593
});
9694

9795
// Discard search itself from session storage. Keep only view preferences

0 commit comments

Comments
 (0)