mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Dashboard] Keep pinned filters on dashboard reset (#198770)
## Summary This PR fixes a bug where pinned filters would get removed when you reset a dashboard. https://github.com/user-attachments/assets/b43b0cb4-15e0-475b-a984-25a9c4ab5ee4 Closes: #166884
This commit is contained in:
parent
1411604dd0
commit
e3de6c4575
1 changed files with 8 additions and 0 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
import { PayloadAction } from '@reduxjs/toolkit';
|
||||
|
||||
import { isFilterPinned } from '@kbn/es-query';
|
||||
import {
|
||||
DashboardReduxState,
|
||||
DashboardStateFromSaveModal,
|
||||
|
@ -94,13 +95,20 @@ export const dashboardContainerReducers = {
|
|||
* `timeRestore` is `false`, this causes unecessary data fetches for the control group.
|
||||
* 2) The view mode, since resetting should never impact this - sometimes the Dashboard saved objects
|
||||
* have this saved in and we don't want resetting to cause unexpected view mode changes.
|
||||
* 3) Pinned filters.
|
||||
*/
|
||||
resetToLastSavedInput: (
|
||||
state: DashboardReduxState,
|
||||
action: PayloadAction<DashboardContainerInput>
|
||||
) => {
|
||||
const keepPinnedFilters = [
|
||||
...state.explicitInput.filters.filter(isFilterPinned),
|
||||
...action.payload.filters,
|
||||
];
|
||||
|
||||
state.explicitInput = {
|
||||
...action.payload,
|
||||
filters: keepPinnedFilters,
|
||||
...(!state.explicitInput.timeRestore && { timeRange: state.explicitInput.timeRange }),
|
||||
viewMode: state.explicitInput.viewMode,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue