1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { sidePanelActions, SidePanelAction } from './side-panel-action';
6 import { SidePanelItem } from '~/components/side-panel/side-panel';
7 import { ProjectsIcon, ShareMeIcon, WorkflowIcon, RecentIcon, FavoriteIcon, TrashIcon } from "~/components/icon/icon";
8 import { Dispatch } from "redux";
9 import { push } from "react-router-redux";
10 import { favoritePanelActions } from "../favorite-panel/favorite-panel-action";
11 import { projectPanelActions } from "../project-panel/project-panel-action";
12 import { projectActions } from "../project/project-action";
13 import { getProjectUrl } from "../../models/project";
14 import { columns as projectPanelColumns } from "../../views/project-panel/project-panel";
15 import { columns as favoritePanelColumns } from "../../views/favorite-panel/favorite-panel";
17 export type SidePanelState = SidePanelItem[];
19 export const sidePanelReducer = (state: SidePanelState = sidePanelItems, action: SidePanelAction) => {
20 return sidePanelActions.match(action, {
21 TOGGLE_SIDE_PANEL_ITEM_OPEN: itemId =>
22 state.map(it => ({...it, open: itemId === it.id && it.open === false})),
27 export enum SidePanelId {
28 PROJECTS = "Projects",
29 SHARED_WITH_ME = "SharedWithMe",
30 WORKFLOWS = "Workflows",
31 RECENT_OPEN = "RecentOpen",
32 FAVORITES = "Favourites",
36 export const sidePanelItems = [
38 id: SidePanelId.PROJECTS,
46 activeAction: (dispatch: Dispatch, uuid: string) => {
47 dispatch(push(getProjectUrl(uuid)));
48 dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(uuid));
49 dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
50 dispatch(projectPanelActions.RESET_PAGINATION());
51 dispatch(projectPanelActions.REQUEST_ITEMS());
55 id: SidePanelId.SHARED_WITH_ME,
56 name: "Shared with me",
60 activeAction: (dispatch: Dispatch) => {
61 dispatch(push("/shared"));
65 id: SidePanelId.WORKFLOWS,
70 activeAction: (dispatch: Dispatch) => {
71 dispatch(push("/workflows"));
75 id: SidePanelId.RECENT_OPEN,
80 activeAction: (dispatch: Dispatch) => {
81 dispatch(push("/recent"));
85 id: SidePanelId.FAVORITES,
90 activeAction: (dispatch: Dispatch) => {
91 dispatch(push("/favorites"));
92 dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
93 dispatch(favoritePanelActions.RESET_PAGINATION());
94 dispatch(favoritePanelActions.REQUEST_ITEMS());
98 id: SidePanelId.TRASH,
103 activeAction: (dispatch: Dispatch) => {
104 dispatch(push("/trash"));