X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/10bc5987612b523f17cf5eb3918444de2f6a2562..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 ca26eeb643..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; } @@ -48,7 +53,7 @@ export const sidePanelData = [ { id: SidePanelIdentifiers.Projects, name: "Projects", - icon: "fas fa-th fa-fw", + icon: ProjectsIcon, open: false, active: false, margin: true, @@ -57,31 +62,36 @@ export const sidePanelData = [ { id: SidePanelIdentifiers.SharedWithMe, name: "Shared with me", - icon: "fas fa-users fa-fw", + icon: ShareMeIcon, active: false, }, { id: SidePanelIdentifiers.Workflows, name: "Workflows", - icon: "fas fa-cogs fa-fw", + icon: WorkflowIcon, active: false, }, { id: SidePanelIdentifiers.RecentOpen, name: "Recent open", - icon: "icon-time fa-fw", + icon: RecentIcon, active: false, }, { id: SidePanelIdentifiers.Favourites, name: "Favorites", - icon: "fas fa-star fa-fw", + 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, name: "Trash", - icon: "fas fa-trash-alt fa-fw", + icon: TrashIcon, active: false, } ]; @@ -91,5 +101,3 @@ function resetSidePanelActivity(sidePanel: SidePanelItem[]) { t.active = false; } } - -export default sidePanelReducer;