strengthened type checking in various new components Arvados-DCO-1.1-Signed-off-by...
authorLisa Knox <lisaknox83@gmail.com>
Mon, 19 Dec 2022 01:06:10 +0000 (20:06 -0500)
committerLisa Knox <lisaknox83@gmail.com>
Mon, 19 Dec 2022 01:06:10 +0000 (20:06 -0500)
src/store/side-panel/side-panel-reducer.tsx
src/views/main-panel/main-panel-root.tsx

index c37d7e5199fe07dba9153c7f540567f6351ed9ea..a6ed03b6ab0a35bffb6cdf9e02e4bd8985d098d1 100644 (file)
@@ -4,11 +4,15 @@
 
 import { sidePanelActions } from "./side-panel-action"
 
+interface SidePanelState {
+  collapsedState: boolean
+}
+
 const sidePanelInitialState = {
   collapsedState: false
 }
 
-export const sidePanelReducer = (state = sidePanelInitialState, action)=>{
+export const sidePanelReducer = (state: SidePanelState = sidePanelInitialState, action)=>{
   if(action.type === sidePanelActions.TOGGLE_COLLAPSE) return {...state, collapsedState: action.payload}
   return state
 }
\ No newline at end of file
index ea3ad41c41da89442c9ea46cf8077858ff8c1edc..543e9c635190e89068e3b9ce8079ccf5f30b352b 100644 (file)
@@ -35,34 +35,38 @@ export interface MainPanelRootDataProps {
     sidePanelIsCollapsed: boolean;
 }
 
-type MainPanelRootProps = MainPanelRootDataProps & WithStyles<CssRules>;
+interface MainPanelRootDispatchProps {
+    toggleSidePanel: () => void
+}
+
+type MainPanelRootProps = MainPanelRootDataProps & MainPanelRootDispatchProps & WithStyles<CssRules>;
 
 export const MainPanelRoot = withStyles(styles)(
-    (props: MainPanelRootProps | any) =>{
-        const{ classes, loading, working, user, buildInfo, uuidPrefix,
-            isNotLinking, isLinkingPath, siteBanner, sessionIdleTimeout, sidePanelIsCollapsed } = props
-            return loading
+    ({ classes, loading, working, user, buildInfo, uuidPrefix,
+        isNotLinking, isLinkingPath, siteBanner, sessionIdleTimeout, 
+        sidePanelIsCollapsed, toggleSidePanel }: MainPanelRootProps) =>{
+        return loading
             ? <WorkbenchLoadingScreen />
             : <>
-                {isNotLinking && <MainAppBar
-                    user={user}
-                    buildInfo={buildInfo}
-                    uuidPrefix={uuidPrefix}
-                    siteBanner={siteBanner}
-                    sidePanelIsCollapsed={sidePanelIsCollapsed}
-                    toggleSidePanel={props.toggleSidePanel}
-                    >
-                    {working
-                        ? <LinearProgress color="secondary" data-cy="linear-progress" />
-                        : null}
-                </MainAppBar>}
-                <Grid container direction="column" className={classes.root}>
-                    {user
-                        ? (user.isActive || (!user.isActive && isLinkingPath)
-                        ? <WorkbenchPanel isNotLinking={isNotLinking} isUserActive={user.isActive} sessionIdleTimeout={sessionIdleTimeout} sidePanelIsCollapsed={sidePanelIsCollapsed}/>
-                        : <InactivePanel />)
-                        : <LoginPanel />}
-                </Grid>
-            </>
-}
+            {isNotLinking && <MainAppBar
+                user={user}
+                buildInfo={buildInfo}
+                uuidPrefix={uuidPrefix}
+                siteBanner={siteBanner}
+                sidePanelIsCollapsed={sidePanelIsCollapsed}
+                toggleSidePanel={toggleSidePanel}
+                >
+                {working
+                    ? <LinearProgress color="secondary" data-cy="linear-progress" />
+                    : null}
+            </MainAppBar>}
+            <Grid container direction="column" className={classes.root}>
+                {user
+                    ? (user.isActive || (!user.isActive && isLinkingPath)
+                    ? <WorkbenchPanel isNotLinking={isNotLinking} isUserActive={user.isActive} sessionIdleTimeout={sessionIdleTimeout} sidePanelIsCollapsed={sidePanelIsCollapsed}/>
+                    : <InactivePanel />)
+                    : <LoginPanel />}
+            </Grid>
+        </>
+    }
 );