1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as _ from "lodash";
7 import actions, { SidePanelAction } from './side-panel-action';
8 import { SidePanelItem } from '../../components/side-panel/side-panel';
10 export type SidePanelState = SidePanelItem[];
12 const sidePanelReducer = (state: SidePanelState = sidePanelData, action: SidePanelAction) => {
13 return actions.match(action, {
14 TOGGLE_SIDE_PANEL_ITEM_OPEN: () => {
15 const sidePanel = _.cloneDeep(state);
16 sidePanel[0].open = !sidePanel[0].open;
19 TOGGLE_SIDE_PANEL_ITEM_ACTIVE: itemId => {
20 const sidePanel = _.cloneDeep(state);
21 resetSidePanelActivity(sidePanel);
23 if (it.id === itemId) {
27 resetProjectsCollapse(sidePanel);
34 export const sidePanelData = [
38 icon: "fas fa-th fa-fw",
44 name: "Shared with me",
45 icon: "fas fa-users fa-fw",
51 icon: "fas fa-cogs fa-fw",
57 icon: "icon-time fa-fw",
63 icon: "fas fa-star fa-fw",
69 icon: "fas fa-trash-alt fa-fw",
74 function resetSidePanelActivity(sidePanel: SidePanelItem[]) {
75 for (const t of sidePanel) {
80 function resetProjectsCollapse(sidePanel: SidePanelItem[]) {
81 if (!sidePanel[0].active) {
82 sidePanel[0].open = false;
86 export default sidePanelReducer;