From: Daniel Kos Date: Tue, 24 Jul 2018 06:53:38 +0000 (+0200) Subject: Add getting items on favorites click X-Git-Tag: 1.2.0~31^2~9 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/1f37ef5dfe95421be1af2f821ea4a8499babc655 Add getting items on favorites click Feature #13753 Arvados-DCO-1.1-Signed-off-by: Daniel Kos --- diff --git a/src/components/side-panel/side-panel.tsx b/src/components/side-panel/side-panel.tsx index 0d275840..8622b68c 100644 --- a/src/components/side-panel/side-panel.tsx +++ b/src/components/side-panel/side-panel.tsx @@ -10,6 +10,7 @@ import { List, ListItem, ListItemIcon, Collapse } from "@material-ui/core"; import { SidePanelRightArrowIcon, IconType } from '../icon/icon'; import * as classnames from "classnames"; import { ListItemTextIcon } from '../list-item-text-icon/list-item-text-icon'; +import { Dispatch } from "redux"; type CssRules = 'active' | 'row' | 'root' | 'list' | 'iconClose' | 'iconOpen' | 'toggableIconContainer' | 'toggableIcon'; @@ -58,7 +59,7 @@ export interface SidePanelItem { open?: boolean; margin?: boolean; openAble?: boolean; - path?: string; + activeAction?: (dispatch: Dispatch) => void; } interface SidePanelDataProps { diff --git a/src/store/side-panel/side-panel-reducer.ts b/src/store/side-panel/side-panel-reducer.ts index 5dd5c012..8d170b38 100644 --- a/src/store/side-panel/side-panel-reducer.ts +++ b/src/store/side-panel/side-panel-reducer.ts @@ -6,6 +6,10 @@ import * as _ from "lodash"; 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[]; @@ -78,7 +82,11 @@ export const sidePanelData = [ name: "Favorites", icon: FavoriteIcon, active: false, - path: '/favorites' + 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, diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 3fec6d67..309b31af 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -255,7 +255,9 @@ export const Workbench = withStyles(styles)( this.props.dispatch(sidePanelActions.TOGGLE_SIDE_PANEL_ITEM_ACTIVE(itemId)); this.props.dispatch(projectActions.RESET_PROJECT_TREE_ACTIVITY(itemId)); const panelItem = this.props.sidePanelItems.find(it => it.id === itemId); - this.props.dispatch(push(panelItem && panelItem.path ? panelItem.path : "/")); + if (panelItem && panelItem.activeAction) { + panelItem.activeAction(this.props.dispatch); + } } handleCreationDialogOpen = (itemUuid: string) => {