Skip to content

Commit

Permalink
[ES|QL][Discover] Clean up the pinned filters while transitioning (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula authored Sep 25, 2024
1 parent b6e692c commit 933c69a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -762,10 +762,12 @@ describe('Test discover state actions', () => {
savedSearchWithQuery.searchSource.setField('query', query);
savedSearchWithQuery.searchSource.setField('filter', filters);
const { state } = await getState('/', { savedSearch: savedSearchWithQuery });
state.globalState?.set({ filters });
await state.actions.transitionFromDataViewToESQL(dataViewMock);
expect(state.appState.getState().query).toStrictEqual({
esql: 'FROM the-data-view-title | LIMIT 10',
});
expect(state.globalState?.get?.()?.filters).toStrictEqual([]);
expect(state.appState.getState().filters).toStrictEqual([]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ export function getDiscoverStateContainer({

const transitionFromDataViewToESQL = (dataView: DataView) => {
const queryString = getInitialESQLQuery(dataView);

appStateContainer.update({
query: { esql: queryString },
filters: [],
Expand All @@ -390,6 +391,9 @@ export function getDiscoverStateContainer({
},
columns: [],
});
// clears pinned filters
const globalState = globalStateContainer.get();
globalStateContainer.set({ ...globalState, filters: [] });
};

const onDataViewCreated = async (nextDataView: DataView) => {
Expand Down

0 comments on commit 933c69a

Please sign in to comment.