Skip to content

Commit

Permalink
[8.x] [ES|QL][Discover] Clean up the pinned filters while transitioni…
Browse files Browse the repository at this point in the history
…ng (#193817) (#194048)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL][Discover] Clean up the pinned filters while transitioning
(#193817)](#193817)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Stratoula
Kalafateli","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-25T17:32:47Z","message":"[ES|QL][Discover]
Clean up the pinned filters while transitioning
(#193817)","sha":"933c69a867627e19b0150aa252b0af5d1d01cb06","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:skip","v9.0.0","Team:DataDiscovery","backport:prev-minor","Feature:ES|QL","Team:ESQL","v8.16.0"],"title":"[ES|QL][Discover]
Clean up the pinned filters while
transitioning","number":193817,"url":"https://github.com/elastic/kibana/pull/193817","mergeCommit":{"message":"[ES|QL][Discover]
Clean up the pinned filters while transitioning
(#193817)","sha":"933c69a867627e19b0150aa252b0af5d1d01cb06"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193817","number":193817,"mergeCommit":{"message":"[ES|QL][Discover]
Clean up the pinned filters while transitioning
(#193817)","sha":"933c69a867627e19b0150aa252b0af5d1d01cb06"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Stratoula Kalafateli <[email protected]>
  • Loading branch information
kibanamachine and stratoula authored Sep 25, 2024
1 parent 52e6a19 commit dc4943f
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 dc4943f

Please sign in to comment.