-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.7] [Dashboard] fix searchSessionId not updated when pinned filter …
…changes (#151390) (#151742) # Backport This will backport the following commits from `main` to `8.7`: - [[Dashboard] fix searchSessionId not updated when pinned filter changes (#151390)](#151390) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nathan Reese","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-02-21T16:31:06Z","message":"[Dashboard] fix searchSessionId not updated when pinned filter changes (#151390)\n\nFixes #151219 and\r\nhttps://github.com//issues/151224\r\n\r\nPR separates shouldRefresh logic from unsavedChanges logic to account\r\nfor difference in filter check.\r\n\r\nshouldRefresh filter check:\r\n* includes pinned filters\r\n* excludes disabled filters\r\n* excludes $state so pinning/unpinning a filter does not cause a\r\nrefresh.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"cd910bee1cb062111e094c2744f153010e6b2e2c","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Dashboard","release_note:fix","Team:Presentation","loe:hours","impact:medium","auto-backport","v8.7.0","v8.8.0"],"number":151390,"url":"https://github.com/elastic/kibana/pull/151390","mergeCommit":{"message":"[Dashboard] fix searchSessionId not updated when pinned filter changes (#151390)\n\nFixes #151219 and\r\nhttps://github.com//issues/151224\r\n\r\nPR separates shouldRefresh logic from unsavedChanges logic to account\r\nfor difference in filter check.\r\n\r\nshouldRefresh filter check:\r\n* includes pinned filters\r\n* excludes disabled filters\r\n* excludes $state so pinning/unpinning a filter does not cause a\r\nrefresh.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"cd910bee1cb062111e094c2744f153010e6b2e2c"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/151390","number":151390,"mergeCommit":{"message":"[Dashboard] fix searchSessionId not updated when pinned filter changes (#151390)\n\nFixes #151219 and\r\nhttps://github.com//issues/151224\r\n\r\nPR separates shouldRefresh logic from unsavedChanges logic to account\r\nfor difference in filter check.\r\n\r\nshouldRefresh filter check:\r\n* includes pinned filters\r\n* excludes disabled filters\r\n* excludes $state so pinning/unpinning a filter does not cause a\r\nrefresh.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"cd910bee1cb062111e094c2744f153010e6b2e2c"}}]}] BACKPORT--> Co-authored-by: Nathan Reese <[email protected]>
- Loading branch information
1 parent
5aa2bdf
commit 748dfcb
Showing
5 changed files
with
171 additions
and
56 deletions.
There are no files selected for viewing
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
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
63 changes: 63 additions & 0 deletions
63
...hboard_container/embeddable/integrations/diff_state/dashboard_diffing_integration.test.ts
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,63 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { buildExistsFilter, disableFilter, pinFilter, toggleFilterNegated } from '@kbn/es-query'; | ||
import type { DataViewFieldBase, DataViewBase } from '@kbn/es-query'; | ||
import { getShouldRefresh } from './dashboard_diffing_integration'; | ||
import { DashboardContainer } from '../../dashboard_container'; | ||
import { DashboardContainerByValueInput } from '../../../../../common'; | ||
|
||
describe('getShouldRefresh', () => { | ||
const dashboardContainerMock = { | ||
untilInitialized: () => {}, | ||
} as unknown as DashboardContainer; | ||
|
||
const existsFilter = buildExistsFilter( | ||
{ | ||
name: 'myFieldName', | ||
} as DataViewFieldBase, | ||
{ | ||
id: 'myDataViewId', | ||
} as DataViewBase | ||
); | ||
|
||
test('should return true when pinned filters change', async () => { | ||
const pinnedFilter = pinFilter(existsFilter); | ||
const lastInput = { | ||
filters: [pinnedFilter], | ||
} as unknown as DashboardContainerByValueInput; | ||
const input = { | ||
filters: [toggleFilterNegated(pinnedFilter)], | ||
} as unknown as DashboardContainerByValueInput; | ||
expect(await getShouldRefresh.bind(dashboardContainerMock)(lastInput, { ...lastInput })).toBe( | ||
false | ||
); | ||
expect(await getShouldRefresh.bind(dashboardContainerMock)(lastInput, input)).toBe(true); | ||
}); | ||
|
||
test('should return false when disabled filters change', async () => { | ||
const disabledFilter = disableFilter(existsFilter); | ||
const lastInput = { | ||
filters: [disabledFilter], | ||
} as unknown as DashboardContainerByValueInput; | ||
const input = { | ||
filters: [toggleFilterNegated(disabledFilter)], | ||
} as unknown as DashboardContainerByValueInput; | ||
expect(await getShouldRefresh.bind(dashboardContainerMock)(lastInput, input)).toBe(false); | ||
}); | ||
|
||
test('should return false when pinned filter changes to unpinned', async () => { | ||
const lastInput = { | ||
filters: [existsFilter], | ||
} as unknown as DashboardContainerByValueInput; | ||
const input = { | ||
filters: [pinFilter(existsFilter)], | ||
} as unknown as DashboardContainerByValueInput; | ||
expect(await getShouldRefresh.bind(dashboardContainerMock)(lastInput, input)).toBe(false); | ||
}); | ||
}); |
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
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