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 if (state.length === 0) {
16 return actions.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 const sidePanelData = [
42 icon: "fas fa-th fa-fw",
48 name: "Shared with me",
49 icon: "fas fa-users fa-fw",
55 icon: "fas fa-cogs fa-fw",
61 icon: "icon-time fa-fw",
67 icon: "fas fa-star fa-fw",
73 icon: "fas fa-trash-alt fa-fw",
78 function resetSidePanelActivity(sidePanel: SidePanelItem[]) {
79 for (const t of sidePanel) {
84 export default sidePanelReducer;