Search: uncheck dashboards after moved (#25256)
(cherry picked from commit 10158c90e3)
This commit is contained in:
committed by
Marcus Andersson
parent
81a4f4addf
commit
170aba2cfb
@@ -1,4 +1,4 @@
|
|||||||
import { DashboardSectionItem, SearchAction } from '../types';
|
import { DashboardSection, DashboardSectionItem, SearchAction } from '../types';
|
||||||
import { TOGGLE_ALL_CHECKED, TOGGLE_CHECKED, MOVE_ITEMS, DELETE_ITEMS } from './actionTypes';
|
import { TOGGLE_ALL_CHECKED, TOGGLE_CHECKED, MOVE_ITEMS, DELETE_ITEMS } from './actionTypes';
|
||||||
import { dashboardsSearchState, DashboardsSearchState, searchReducer } from './dashboardSearch';
|
import { dashboardsSearchState, DashboardsSearchState, searchReducer } from './dashboardSearch';
|
||||||
import { mergeReducers } from '../utils';
|
import { mergeReducers } from '../utils';
|
||||||
@@ -46,13 +46,18 @@ const reducer = (state: ManageDashboardsState, action: SearchAction) => {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
case MOVE_ITEMS: {
|
case MOVE_ITEMS: {
|
||||||
const { dashboards, folder } = action.payload;
|
const dashboards: DashboardSectionItem[] = action.payload.dashboards;
|
||||||
const uids = dashboards.map((d: DashboardSectionItem) => d.uid);
|
const folder: DashboardSection = action.payload.folder;
|
||||||
|
const uids = dashboards.map(db => db.uid);
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
results: state.results.map(result => {
|
results: state.results.map(result => {
|
||||||
if (folder.id === result.id) {
|
if (folder.id === result.id) {
|
||||||
return { ...result, items: [...result.items, ...dashboards] };
|
return {
|
||||||
|
...result,
|
||||||
|
items: [...result.items, ...dashboards.map(db => ({ ...db, checked: false }))],
|
||||||
|
checked: false,
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
return { ...result, items: result.items.filter(item => !uids.includes(item.uid)) };
|
return { ...result, items: result.items.filter(item => !uids.includes(item.uid)) };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user