X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1fd27a3f5cbf1ac44f2f70e0abcfb7072ed43684..2bd3f83db9934198b658b7035a7be65017b754d9:/src/views/workbench/workbench.tsx diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 030ed6df9a..445e86de66 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -4,12 +4,12 @@ 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"; +import { Route, Switch } from 'react-router'; +import { ProjectPanel } from 'views/project-panel/project-panel'; import { DetailsPanel } from 'views-components/details-panel/details-panel'; import { ArvadosTheme } from 'common/custom-theme'; -import { ContextMenu } from "views-components/context-menu/context-menu"; -import { FavoritePanel } from "../favorite-panel/favorite-panel"; +import { ContextMenu } from 'views-components/context-menu/context-menu'; +import { FavoritePanel } from '../favorite-panel/favorite-panel'; import { TokenDialog } from 'views-components/token-dialog/token-dialog'; import { RichTextEditorDialog } from 'views-components/rich-text-editor-dialog/rich-text-editor-dialog'; import { Snackbar } from 'views-components/snackbar/snackbar'; @@ -36,15 +36,16 @@ import { PartialCopyCollectionDialog } from 'views-components/dialog-forms/parti import { RemoveProcessDialog } from 'views-components/process-remove-dialog/process-remove-dialog'; import { MainContentBar } from 'views-components/main-content-bar/main-content-bar'; import { Grid } from '@material-ui/core'; -import { TrashPanel } from "views/trash-panel/trash-panel"; +import { TrashPanel } from 'views/trash-panel/trash-panel'; import { SharedWithMePanel } from 'views/shared-with-me-panel/shared-with-me-panel'; import { RunProcessPanel } from 'views/run-process-panel/run-process-panel'; import SplitterLayout from 'react-splitter-layout'; import { WorkflowPanel } from 'views/workflow-panel/workflow-panel'; +import { RegisteredWorkflowPanel } from 'views/workflow-panel/registered-workflow-panel'; import { SearchResultsPanel } from 'views/search-results-panel/search-results-panel'; import { SshKeyPanel } from 'views/ssh-key-panel/ssh-key-panel'; import { SshKeyAdminPanel } from 'views/ssh-key-panel/ssh-key-admin-panel'; -import { SiteManagerPanel } from "views/site-manager-panel/site-manager-panel"; +import { SiteManagerPanel } from 'views/site-manager-panel/site-manager-panel'; import { UserProfilePanel } from 'views/user-profile-panel/user-profile-panel'; import { SharingDialog } from 'views-components/sharing-dialog/sharing-dialog'; import { NotFoundDialog } from 'views-components/not-found-dialog/not-found-dialog'; @@ -99,30 +100,35 @@ import { RestoreCollectionVersionDialog } from 'views-components/collections-dia 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' +import { COLLAPSE_ICON_SIZE } from 'views-components/side-panel-toggle/side-panel-toggle'; +import { Banner } from 'views-components/baner/banner'; type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ root: { paddingTop: theme.spacing.unit * 7, - background: theme.palette.background.default + background: theme.palette.background.default, }, container: { - position: 'relative' + position: 'relative', }, splitter: { '& > .layout-splitter': { - width: '2px' - } + width: '2px', + }, + '& > .layout-splitter-disabled': { + pointerEvents: 'none', + cursor: 'pointer', + }, }, asidePanel: { paddingTop: theme.spacing.unit, - height: '100%' + height: '100%', }, contentWrapper: { paddingTop: theme.spacing.unit, - minWidth: 0 + minWidth: 0, }, content: { minWidth: 0, @@ -131,7 +137,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ // Reserve vertical space for app bar + MainContentBar minHeight: `calc(100vh - ${theme.spacing.unit * 16}px)`, display: 'flex', - } + }, }); interface WorkbenchDataProps { @@ -152,62 +158,82 @@ const getSplitterInitialSize = () => { const saveSplitterSize = (size: number) => localStorage.setItem('splitterSize', size.toString()); -let routes = <> - - - - - - - - - - - - - - - - - - - - - - - - - - - -; +let routes = ( + <> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); -const reduceRoutesFn: (a: React.ReactElement[], - b: ElementListReducer) => React.ReactElement[] = (a, b) => b(a); +const reduceRoutesFn: (a: React.ReactElement[], b: ElementListReducer) => React.ReactElement[] = (a, b) => b(a); -routes = React.createElement(React.Fragment, null, pluginConfig.centerPanelList.reduce(reduceRoutesFn, React.Children.toArray(routes.props.children))); +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()}%`) + const rightPanel: Element = document.getElementsByClassName('layout-pane')[1]; + const totalWidth: number = document.getElementsByClassName('splitter-layout')[0]?.clientWidth; + const rightPanelExpandedWidth = (totalWidth - COLLAPSE_ICON_SIZE) / (totalWidth / 100); + if (rightPanel) { + rightPanel.setAttribute('style', `width: ${isCollapsed ? rightPanelExpandedWidth : getSplitterInitialSize()}%`); } -} + const splitter = document.getElementsByClassName('layout-splitter')[0]; + isCollapsed ? splitter?.classList.add('layout-splitter-disabled') : splitter?.classList.remove('layout-splitter-disabled'); +}; + +export const WorkbenchPanel = withStyles(styles)((props: WorkbenchPanelProps) => { + //panel size will not scale automatically on window resize, so we do it manually + window.addEventListener('resize', () => applyCollapsedState(props.sidePanelIsCollapsed)); + applyCollapsedState(props.sidePanelIsCollapsed); -export const WorkbenchPanel = - withStyles(styles)((props: WorkbenchPanelProps) =>{ - applyCollapsedState(props.sidePanelIsCollapsed) - return + return ( + {props.sessionIdleTimeout > 0 && } - - {props.isUserActive && props.isNotLinking && - - } - + + {props.isUserActive && props.isNotLinking && ( + + + + )} + {props.isNotLinking && } @@ -280,6 +306,8 @@ export const WorkbenchPanel = + {React.createElement(React.Fragment, null, pluginConfig.dialogs)} - } + ); +});