X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e6039bec0497aa7e1391958e5c4f84bbaeef653e..8c6209c45e4720c66dd53640142cbc9111748246:/src/store/side-panel/side-panel-reducer.ts diff --git a/src/store/side-panel/side-panel-reducer.ts b/src/store/side-panel/side-panel-reducer.ts index a0da7db9bb..8d170b383b 100644 --- a/src/store/side-panel/side-panel-reducer.ts +++ b/src/store/side-panel/side-panel-reducer.ts @@ -3,22 +3,27 @@ // SPDX-License-Identifier: AGPL-3.0 import * as _ from "lodash"; -import actions, { SidePanelAction } from './side-panel-action'; +import { sidePanelActions, SidePanelAction } from './side-panel-action'; import { SidePanelItem } from '../../components/side-panel/side-panel'; import { ProjectsIcon, ShareMeIcon, WorkflowIcon, RecentIcon, FavoriteIcon, TrashIcon } from "../../components/icon/icon"; +import { dataExplorerActions } from "../data-explorer/data-explorer-action"; +import { Dispatch } from "react-redux"; +import { FAVORITE_PANEL_ID } from "../../views/favorite-panel/favorite-panel"; +import { push } from "react-router-redux"; export type SidePanelState = SidePanelItem[]; -const sidePanelReducer = (state: SidePanelState = sidePanelData, action: SidePanelAction) => { +export const sidePanelReducer = (state: SidePanelState = sidePanelData, action: SidePanelAction) => { if (state.length === 0) { return sidePanelData; } else { - return actions.match(action, { - TOGGLE_SIDE_PANEL_ITEM_OPEN: itemId => state.map(it => itemId === it.id && it.open === false ? {...it, open: true} : {...it, open: false}), + return sidePanelActions.match(action, { + TOGGLE_SIDE_PANEL_ITEM_OPEN: itemId => + state.map(it => ({...it, open: itemId === it.id && it.open === false})), TOGGLE_SIDE_PANEL_ITEM_ACTIVE: itemId => { const sidePanel = _.cloneDeep(state); resetSidePanelActivity(sidePanel); - sidePanel.map(it => { + sidePanel.forEach(it => { if (it.id === itemId) { it.active = true; } @@ -77,6 +82,11 @@ export const sidePanelData = [ name: "Favorites", icon: FavoriteIcon, active: false, + activeAction: (dispatch: Dispatch) => { + dispatch(push("/favorites")); + dispatch(dataExplorerActions.RESET_PAGINATION({id: FAVORITE_PANEL_ID})); + dispatch(dataExplorerActions.REQUEST_ITEMS({id: FAVORITE_PANEL_ID})); + } }, { id: SidePanelIdentifiers.Trash, @@ -91,5 +101,3 @@ function resetSidePanelActivity(sidePanel: SidePanelItem[]) { t.active = false; } } - -export default sidePanelReducer;