added side-panel-reducer file, minor code cleanup Arvados-DCO-1.1-Signed-off-by:...
authorLisa Knox <lisaknox83@gmail.com>
Mon, 19 Dec 2022 00:41:40 +0000 (19:41 -0500)
committerLisa Knox <lisaknox83@gmail.com>
Mon, 19 Dec 2022 00:41:40 +0000 (19:41 -0500)
src/store/side-panel/side-panel-action.ts
src/store/store.ts
src/views-components/side-panel/side-panel.tsx
src/views/main-panel/main-panel-root.tsx
src/views/main-panel/main-panel.tsx
src/views/workbench/workbench.tsx

index 9e8da28307fc410467c594ba75d702e96f9d5db8..e4f53ceaa6be6df93c35c0831fb4d8c93d986d59 100644 (file)
@@ -5,7 +5,17 @@
 import { Dispatch } from 'redux';
 import { navigateTo } from 'store/navigation/navigation-action';
 
+export const sidePanelActions = {
+    TOGGLE_COLLAPSE: 'TOGGLE_COLLAPSE'
+}
+
 export const navigateFromSidePanel = (id: string) =>
     (dispatch: Dispatch) => {
         dispatch<any>(navigateTo(id));
     };
+
+export const toggleSidePanel = (collapsedState: boolean) => {
+    return (dispatch) => {
+        dispatch({type: sidePanelActions.TOGGLE_COLLAPSE, payload: !collapsedState})
+    }
+}
\ No newline at end of file
index 2925d8f9593461b190dea92b406d6f2567cbc560..303b9dc054435abdd699b0aa0d5291e2839b2ec9 100644 (file)
@@ -73,6 +73,7 @@ import { ALL_PROCESSES_PANEL_ID } from './all-processes-panel/all-processes-pane
 import { Config } from 'common/config';
 import { pluginConfig } from 'plugins';
 import { MiddlewareListReducer } from 'common/plugintypes';
+import { sidePanelReducer } from './side-panel/side-panel-reducer'
 
 declare global {
     interface Window {
@@ -185,22 +186,6 @@ export function configureStore(history: History, services: ServiceRepository, co
     return createStore(rootReducer, enhancer);
 }
 
-//TODO: put sidePanel items in separate file and import
-export const toggleSidePanel = (collapsedState: boolean) => {
-    return (dispatch) => {
-        dispatch({type: 'TOGGLE_COLLAPSE', payload: !collapsedState})
-    }
-}
-
-const sidePanelInitialState = {
-    collapsedState: false
-}
-
-const sidePanelReducer = (state = sidePanelInitialState, action)=>{
-    if(action.type === 'TOGGLE_COLLAPSE') return {...state, collapsedState: action.payload}
-    return state
-}
-
 const createRootReducer = (services: ServiceRepository) => combineReducers({
     auth: authReducer(services),
     collectionPanel: collectionPanelReducer,
index dce8217a79636e9c856008a7c03963e9e7c4b395..3c4d19f878498e144625e34648a6e39ce811391c 100644 (file)
@@ -50,7 +50,6 @@ export const SidePanel = withStyles(styles)(
     ));
 
 export const CollapseLeftPanelTrigger = (props) =>{ 
-    console.log(props)
     return <Tooltip disableFocusListener title="Toggle Side Panel">
                 <IconButton onClick={()=>{props.toggleSidePanel(props.sidepanelcollapsed)}}>
                     <MenuIcon aria-label="Toggle Side Panel" />
index 2019f7bcefb484001cb9030828f55e417d60fba8..ea3ad41c41da89442c9ea46cf8077858ff8c1edc 100644 (file)
@@ -11,7 +11,6 @@ import { LoginPanel } from 'views/login-panel/login-panel';
 import { InactivePanel } from 'views/inactive-panel/inactive-panel';
 import { WorkbenchLoadingScreen } from 'views/workbench/workbench-loading-screen';
 import { MainAppBar } from 'views-components/main-app-bar/main-app-bar';
-import { toggleSidePanel } from 'store/store';
 
 type CssRules = 'root';
 
@@ -41,7 +40,7 @@ type MainPanelRootProps = MainPanelRootDataProps & WithStyles<CssRules>;
 export const MainPanelRoot = withStyles(styles)(
     (props: MainPanelRootProps | any) =>{
         const{ classes, loading, working, user, buildInfo, uuidPrefix,
-            isNotLinking, isLinkingPath, siteBanner, sessionIdleTimeout, sidePanelIsCollapsed: sidePanelIsCollapsed } = props
+            isNotLinking, isLinkingPath, siteBanner, sessionIdleTimeout, sidePanelIsCollapsed } = props
             return loading
             ? <WorkbenchLoadingScreen />
             : <>
index 0be47f4896a4f6ffa8b6d64b30bf59f7dbbe2eeb..fac3da67150f37cacfaf7a6a711c94361dea326e 100644 (file)
@@ -10,7 +10,7 @@ import { isSystemWorking } from 'store/progress-indicator/progress-indicator-red
 import { isWorkbenchLoading } from 'store/workbench/workbench-actions';
 import { LinkAccountPanelStatus } from 'store/link-account-panel/link-account-panel-reducer';
 import { matchLinkAccountRoute } from 'routes/routes';
-import { toggleSidePanel } from "store/store";
+import { toggleSidePanel } from "store/side-panel/side-panel-action";
 
 const mapStateToProps = (state: RootState): MainPanelRootDataProps => {
     return {
index d7ab911e0cff5b76ed293a6087ec586dea139fba..030ed6df9ac7f6cce62d385638b97f0dfe47c686 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import React, { useState } from 'react';
+import React from 'react';
 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
 import { Route, Switch } from "react-router";
 import { ProjectPanel } from "views/project-panel/project-panel";