1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as _ from "lodash";
6 import { sidePanelActions, SidePanelAction } from './side-panel-action';
7 import { SidePanelItem } from '../../components/side-panel/side-panel';
8 import { ProjectsIcon, ShareMeIcon, WorkflowIcon, RecentIcon, FavoriteIcon, TrashIcon } from "../../components/icon/icon";
10 export type SidePanelState = SidePanelItem[];
12 export const sidePanelReducer = (state: SidePanelState = sidePanelData, action: SidePanelAction) => {
13 if (state.length === 0) {
16 return sidePanelActions.match(action, {
17 TOGGLE_SIDE_PANEL_ITEM_OPEN: itemId => state.map(it => itemId === it.id && it.open === false ? {...it, open: true} : {...it, open: false}),
18 TOGGLE_SIDE_PANEL_ITEM_ACTIVE: itemId => {
19 const sidePanel = _.cloneDeep(state);
20 resetSidePanelActivity(sidePanel);
22 if (it.id === itemId) {
28 RESET_SIDE_PANEL_ACTIVITY: () => {
29 const sidePanel = _.cloneDeep(state);
30 resetSidePanelActivity(sidePanel);
38 export enum SidePanelIdentifiers {
39 Projects = "Projects",
40 SharedWithMe = "SharedWithMe",
41 Workflows = "Workflows",
42 RecentOpen = "RecentOpen",
43 Favourites = "Favourites",
47 export const sidePanelData = [
49 id: SidePanelIdentifiers.Projects,
58 id: SidePanelIdentifiers.SharedWithMe,
59 name: "Shared with me",
64 id: SidePanelIdentifiers.Workflows,
70 id: SidePanelIdentifiers.RecentOpen,
76 id: SidePanelIdentifiers.Favourites,
82 id: SidePanelIdentifiers.Trash,
89 function resetSidePanelActivity(sidePanel: SidePanelItem[]) {
90 for (const t of sidePanel) {