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,
virtualMachines: virtualMachinesReducer,
repositories: repositoriesReducer,
keepServices: keepServicesReducer,
- linkAccountPanel: linkAccountPanelReducer
+ linkAccountPanel: linkAccountPanelReducer,
+ sidePanel: sidePanelReducer
});
import { ReactNode } from "react";
import { AdminMenu } from "views-components/main-app-bar/admin-menu";
import { pluginConfig } from 'plugins';
+import { CollapseLeftPanelTrigger } from 'views-components/side-panel/side-panel'
+// import { toggleSidePanel } from "store/store";
type CssRules = 'toolbar' | 'link';
children?: ReactNode;
uuidPrefix: string;
siteBanner: string;
+ sidePanelIsCollapsed: boolean;
+ toggleSidePanel: (collapsedState:boolean) => void
}
export type MainAppBarProps = MainAppBarDataProps & WithStyles<CssRules>;
(props: MainAppBarProps) => {
return <AppBar position="absolute">
<Toolbar className={props.classes.toolbar}>
+ <CollapseLeftPanelTrigger sidepanelcollapsed={props.sidePanelIsCollapsed}
+ toggleSidePanel={props.toggleSidePanel}
+ />
<Grid container justify="space-between">
{pluginConfig.appBarLeft || <Grid container item xs={3} direction="column" justify="center">
<Typography variant='h6' color="inherit" noWrap>
<span dangerouslySetInnerHTML={{ __html: props.siteBanner }} /> ({props.uuidPrefix})
</Link>
</Typography>
- <Typography variant="caption" color="inherit">{props.buildInfo}</Typography>
+ <Typography variant="caption" color="inherit">
+
+ {props.buildInfo}</Typography>
</Grid>}
<Grid
item
import { Dispatch } from 'redux';
import { connect } from 'react-redux';
import { navigateFromSidePanel } from 'store/side-panel/side-panel-action';
-import { Grid } from '@material-ui/core';
+import { Grid, Tooltip, IconButton } from '@material-ui/core';
import { SidePanelButton } from 'views-components/side-panel-button/side-panel-button';
import { RootState } from 'store/store';
+import MenuIcon from "@material-ui/icons/Menu";
+// import { IconButtonProps } from '@material-ui/core/IconButton';
+// import { toggleSidePanel } from 'store/store';
const DRAWER_WIDTH = 240;
<SidePanelTree {...props} />
</Grid>
));
+
+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" />
+ </IconButton>
+ </Tooltip>
+ };
\ No newline at end of file
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';
isLinkingPath: boolean;
siteBanner: string;
sessionIdleTimeout: number;
+ sidePanelIsCollapsed: boolean;
}
type MainPanelRootProps = MainPanelRootDataProps & WithStyles<CssRules>;
export const MainPanelRoot = withStyles(styles)(
- ({ classes, loading, working, user, buildInfo, uuidPrefix,
- isNotLinking, isLinkingPath, siteBanner, sessionIdleTimeout }: MainPanelRootProps) =>
- loading
+ (props: MainPanelRootProps | any) =>{
+ const{ classes, loading, working, user, buildInfo, uuidPrefix,
+ isNotLinking, isLinkingPath, siteBanner, sessionIdleTimeout, sidePanelIsCollapsed: sidePanelIsCollapsed } = props
+ return loading
? <WorkbenchLoadingScreen />
: <>
{isNotLinking && <MainAppBar
user={user}
buildInfo={buildInfo}
uuidPrefix={uuidPrefix}
- siteBanner={siteBanner}>
+ siteBanner={siteBanner}
+ sidePanelIsCollapsed={sidePanelIsCollapsed}
+ toggleSidePanel={props.toggleSidePanel}
+ >
{working
? <LinearProgress color="secondary" data-cy="linear-progress" />
: null}
<Grid container direction="column" className={classes.root}>
{user
? (user.isActive || (!user.isActive && isLinkingPath)
- ? <WorkbenchPanel isNotLinking={isNotLinking} isUserActive={user.isActive} sessionIdleTimeout={sessionIdleTimeout} />
- : <InactivePanel />)
+ ? <WorkbenchPanel isNotLinking={isNotLinking} isUserActive={user.isActive} sessionIdleTimeout={sessionIdleTimeout} sidePanelIsCollapsed={sidePanelIsCollapsed}/>
+ : <InactivePanel />)
: <LoginPanel />}
</Grid>
</>
+}
);
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";
const mapStateToProps = (state: RootState): MainPanelRootDataProps => {
return {
isNotLinking: state.linkAccountPanel.status === LinkAccountPanelStatus.NONE || state.linkAccountPanel.status === LinkAccountPanelStatus.INITIAL,
isLinkingPath: state.router.location ? matchLinkAccountRoute(state.router.location.pathname) !== null : false,
siteBanner: state.auth.config.clusterConfig.Workbench.SiteName,
- sessionIdleTimeout: parse(state.auth.config.clusterConfig.Workbench.IdleTimeout, 's') || 0
+ sessionIdleTimeout: parse(state.auth.config.clusterConfig.Workbench.IdleTimeout, 's') || 0,
+ sidePanelIsCollapsed: state.sidePanel.collapsedState,
};
};
-const mapDispatchToProps = null;
+const mapDispatchToProps = (dispatch) => {
+ return {
+ toggleSidePanel: (collapsedState)=>{
+ return dispatch(toggleSidePanel(collapsedState))
+ }
+ }
+};
export const MainPanel = connect(mapStateToProps, mapDispatchToProps)(MainPanelRoot);
import { WebDavS3InfoDialog } from 'views-components/webdav-s3-dialog/webdav-s3-dialog';
import { pluginConfig } from 'plugins';
import { ElementListReducer } from 'common/plugintypes';
+// import { toggleSidePanel } from 'store/store'
type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
isUserActive: boolean;
isNotLinking: boolean;
sessionIdleTimeout: number;
+ sidePanelIsCollapsed: boolean;
}
type WorkbenchPanelProps = WithStyles<CssRules> & WorkbenchDataProps;
routes = React.createElement(React.Fragment, null, pluginConfig.centerPanelList.reduce(reduceRoutesFn, React.Children.toArray(routes.props.children)));
+const applyCollapsedState = (isCollapsed) => {
+ const rightPanel: Element = document.getElementsByClassName('layout-pane')[1]
+ if(rightPanel) {
+ rightPanel.setAttribute('style', `width: ${isCollapsed ? 100 : getSplitterInitialSize()}%`)
+ }
+}
+
export const WorkbenchPanel =
withStyles(styles)((props: WorkbenchPanelProps) =>{
- const [isExpanded, setIsExpanded] = useState<boolean>(false)
-
- const expandRightPanel = (): void=> {
- const rightPanel: Element = document.getElementsByClassName('layout-pane')[1]
- rightPanel.setAttribute('style', `width: ${isExpanded ? getSplitterInitialSize() : 100}%`)
- setIsExpanded(!isExpanded)
- }
-
+ applyCollapsedState(props.sidePanelIsCollapsed)
return <Grid container item xs className={props.classes.root}>
{props.sessionIdleTimeout > 0 && <AutoLogout />}
<Grid container item xs className={props.classes.container}>
<SidePanel />
</Grid>}
<Grid container item xs component="main" direction="column" className={props.classes.contentWrapper}>
- <button onClick={expandRightPanel}>moveSplitter</button>
<Grid item xs>
{props.isNotLinking && <MainContentBar />}
</Grid>