1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
7 import { Route, Switch } from "react-router";
8 import { ProjectPanel } from "views/project-panel/project-panel";
9 import { DetailsPanel } from 'views-components/details-panel/details-panel';
10 import { ArvadosTheme } from 'common/custom-theme';
11 import { ContextMenu } from "views-components/context-menu/context-menu";
12 import { FavoritePanel } from "../favorite-panel/favorite-panel";
13 import { TokenDialog } from 'views-components/token-dialog/token-dialog';
14 import { RichTextEditorDialog } from 'views-components/rich-text-editor-dialog/rich-text-editor-dialog';
15 import { Snackbar } from 'views-components/snackbar/snackbar';
16 import { CollectionPanel } from '../collection-panel/collection-panel';
17 import { RenameFileDialog } from 'views-components/rename-file-dialog/rename-file-dialog';
18 import { FileRemoveDialog } from 'views-components/file-remove-dialog/file-remove-dialog';
19 import { MultipleFilesRemoveDialog } from 'views-components/file-remove-dialog/multiple-files-remove-dialog';
20 import { Routes } from 'routes/routes';
21 import { SidePanel } from 'views-components/side-panel/side-panel';
22 import { ProcessPanel } from 'views/process-panel/process-panel';
23 import { ChangeWorkflowDialog } from 'views-components/run-process-dialog/change-workflow-dialog';
24 import { CreateProjectDialog } from 'views-components/dialog-forms/create-project-dialog';
25 import { CreateCollectionDialog } from 'views-components/dialog-forms/create-collection-dialog';
26 import { CopyCollectionDialog } from 'views-components/dialog-forms/copy-collection-dialog';
27 import { CopyProcessDialog } from 'views-components/dialog-forms/copy-process-dialog';
28 import { UpdateCollectionDialog } from 'views-components/dialog-forms/update-collection-dialog';
29 import { UpdateProcessDialog } from 'views-components/dialog-forms/update-process-dialog';
30 import { UpdateProjectDialog } from 'views-components/dialog-forms/update-project-dialog';
31 import { MoveProcessDialog } from 'views-components/dialog-forms/move-process-dialog';
32 import { MoveProjectDialog } from 'views-components/dialog-forms/move-project-dialog';
33 import { MoveCollectionDialog } from 'views-components/dialog-forms/move-collection-dialog';
34 import { FilesUploadCollectionDialog } from 'views-components/dialog-forms/files-upload-collection-dialog';
35 import { PartialCopyToNewCollectionDialog } from 'views-components/dialog-forms/partial-copy-to-new-collection-dialog';
36 import { PartialCopyToExistingCollectionDialog } from 'views-components/dialog-forms/partial-copy-to-existing-collection-dialog';
37 import { PartialCopyToSeparateCollectionsDialog } from 'views-components/dialog-forms/partial-copy-to-separate-collections-dialog';
38 import { PartialMoveToNewCollectionDialog } from 'views-components/dialog-forms/partial-move-to-new-collection-dialog';
39 import { PartialMoveToExistingCollectionDialog } from 'views-components/dialog-forms/partial-move-to-existing-collection-dialog';
40 import { PartialMoveToSeparateCollectionsDialog } from 'views-components/dialog-forms/partial-move-to-separate-collections-dialog';
41 import { RemoveProcessDialog } from 'views-components/process-remove-dialog/process-remove-dialog';
42 import { MainContentBar } from 'views-components/main-content-bar/main-content-bar';
43 import { Grid } from '@material-ui/core';
44 import { TrashPanel } from "views/trash-panel/trash-panel";
45 import { SharedWithMePanel } from 'views/shared-with-me-panel/shared-with-me-panel';
46 import { RunProcessPanel } from 'views/run-process-panel/run-process-panel';
47 import SplitterLayout from 'react-splitter-layout';
48 import { WorkflowPanel } from 'views/workflow-panel/workflow-panel';
49 import { RegisteredWorkflowPanel } from 'views/workflow-panel/registered-workflow-panel';
50 import { SearchResultsPanel } from 'views/search-results-panel/search-results-panel';
51 import { SshKeyPanel } from 'views/ssh-key-panel/ssh-key-panel';
52 import { SshKeyAdminPanel } from 'views/ssh-key-panel/ssh-key-admin-panel';
53 import { SiteManagerPanel } from "views/site-manager-panel/site-manager-panel";
54 import { UserProfilePanel } from 'views/user-profile-panel/user-profile-panel';
55 import { SharingDialog } from 'views-components/sharing-dialog/sharing-dialog';
56 import { NotFoundDialog } from 'views-components/not-found-dialog/not-found-dialog';
57 import { AdvancedTabDialog } from 'views-components/advanced-tab-dialog/advanced-tab-dialog';
58 import { ProcessInputDialog } from 'views-components/process-input-dialog/process-input-dialog';
59 import { VirtualMachineUserPanel } from 'views/virtual-machine-panel/virtual-machine-user-panel';
60 import { VirtualMachineAdminPanel } from 'views/virtual-machine-panel/virtual-machine-admin-panel';
61 import { RepositoriesPanel } from 'views/repositories-panel/repositories-panel';
62 import { KeepServicePanel } from 'views/keep-service-panel/keep-service-panel';
63 import { ApiClientAuthorizationPanel } from 'views/api-client-authorization-panel/api-client-authorization-panel';
64 import { LinkPanel } from 'views/link-panel/link-panel';
65 import { RepositoriesSampleGitDialog } from 'views-components/repositories-sample-git-dialog/repositories-sample-git-dialog';
66 import { RepositoryAttributesDialog } from 'views-components/repository-attributes-dialog/repository-attributes-dialog';
67 import { CreateRepositoryDialog } from 'views-components/dialog-forms/create-repository-dialog';
68 import { RemoveRepositoryDialog } from 'views-components/repository-remove-dialog/repository-remove-dialog';
69 import { CreateSshKeyDialog } from 'views-components/dialog-forms/create-ssh-key-dialog';
70 import { PublicKeyDialog } from 'views-components/ssh-keys-dialog/public-key-dialog';
71 import { RemoveApiClientAuthorizationDialog } from 'views-components/api-client-authorizations-dialog/remove-dialog';
72 import { RemoveKeepServiceDialog } from 'views-components/keep-services-dialog/remove-dialog';
73 import { RemoveLinkDialog } from 'views-components/links-dialog/remove-dialog';
74 import { RemoveSshKeyDialog } from 'views-components/ssh-keys-dialog/remove-dialog';
75 import { VirtualMachineAttributesDialog } from 'views-components/virtual-machines-dialog/attributes-dialog';
76 import { RemoveVirtualMachineDialog } from 'views-components/virtual-machines-dialog/remove-dialog';
77 import { RemoveVirtualMachineLoginDialog } from 'views-components/virtual-machines-dialog/remove-login-dialog';
78 import { VirtualMachineAddLoginDialog } from 'views-components/virtual-machines-dialog/add-login-dialog';
79 import { AttributesApiClientAuthorizationDialog } from 'views-components/api-client-authorizations-dialog/attributes-dialog';
80 import { AttributesKeepServiceDialog } from 'views-components/keep-services-dialog/attributes-dialog';
81 import { AttributesLinkDialog } from 'views-components/links-dialog/attributes-dialog';
82 import { AttributesSshKeyDialog } from 'views-components/ssh-keys-dialog/attributes-dialog';
83 import { UserPanel } from 'views/user-panel/user-panel';
84 import { UserAttributesDialog } from 'views-components/user-dialog/attributes-dialog';
85 import { CreateUserDialog } from 'views-components/dialog-forms/create-user-dialog';
86 import { HelpApiClientAuthorizationDialog } from 'views-components/api-client-authorizations-dialog/help-dialog';
87 import { DeactivateDialog } from 'views-components/user-dialog/deactivate-dialog';
88 import { ActivateDialog } from 'views-components/user-dialog/activate-dialog';
89 import { SetupDialog } from 'views-components/user-dialog/setup-dialog';
90 import { GroupsPanel } from 'views/groups-panel/groups-panel';
91 import { RemoveGroupDialog } from 'views-components/groups-dialog/remove-dialog';
92 import { GroupAttributesDialog } from 'views-components/groups-dialog/attributes-dialog';
93 import { GroupDetailsPanel } from 'views/group-details-panel/group-details-panel';
94 import { RemoveGroupMemberDialog } from 'views-components/groups-dialog/member-remove-dialog';
95 import { GroupMemberAttributesDialog } from 'views-components/groups-dialog/member-attributes-dialog';
96 import { PublicFavoritePanel } from 'views/public-favorites-panel/public-favorites-panel';
97 import { LinkAccountPanel } from 'views/link-account-panel/link-account-panel';
98 import { FedLogin } from './fed-login';
99 import { CollectionsContentAddressPanel } from 'views/collection-content-address-panel/collection-content-address-panel';
100 import { AllProcessesPanel } from '../all-processes-panel/all-processes-panel';
101 import { NotFoundPanel } from '../not-found-panel/not-found-panel';
102 import { AutoLogout } from 'views-components/auto-logout/auto-logout';
103 import { RestoreCollectionVersionDialog } from 'views-components/collections-dialog/restore-version-dialog';
104 import { WebDavS3InfoDialog } from 'views-components/webdav-s3-dialog/webdav-s3-dialog';
105 import { pluginConfig } from 'plugins';
106 import { ElementListReducer } from 'common/plugintypes';
107 import { COLLAPSE_ICON_SIZE } from 'views-components/side-panel-toggle/side-panel-toggle'
108 import { Banner } from 'views-components/baner/banner';
110 type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
112 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
114 paddingTop: theme.spacing.unit * 7,
115 background: theme.palette.background.default
121 '& > .layout-splitter': {
124 '& > .layout-splitter-disabled': {
125 pointerEvents: 'none',
130 paddingTop: theme.spacing.unit,
134 paddingTop: theme.spacing.unit,
139 paddingLeft: theme.spacing.unit * 3,
140 paddingRight: theme.spacing.unit * 3,
141 // Reserve vertical space for app bar + MainContentBar
142 minHeight: `calc(100vh - ${theme.spacing.unit * 16}px)`,
147 interface WorkbenchDataProps {
148 isUserActive: boolean;
149 isNotLinking: boolean;
150 sessionIdleTimeout: number;
151 sidePanelIsCollapsed: boolean;
154 type WorkbenchPanelProps = WithStyles<CssRules> & WorkbenchDataProps;
156 const defaultSplitterSize = 90;
158 const getSplitterInitialSize = () => {
159 const splitterSize = localStorage.getItem('splitterSize');
160 return splitterSize ? Number(splitterSize) : defaultSplitterSize;
163 const saveSplitterSize = (size: number) => localStorage.setItem('splitterSize', size.toString());
166 <Route path={Routes.PROJECTS} component={ProjectPanel} />
167 <Route path={Routes.COLLECTIONS} component={CollectionPanel} />
168 <Route path={Routes.FAVORITES} component={FavoritePanel} />
169 <Route path={Routes.ALL_PROCESSES} component={AllProcessesPanel} />
170 <Route path={Routes.PROCESSES} component={ProcessPanel} />
171 <Route path={Routes.TRASH} component={TrashPanel} />
172 <Route path={Routes.SHARED_WITH_ME} component={SharedWithMePanel} />
173 <Route path={Routes.RUN_PROCESS} component={RunProcessPanel} />
174 <Route path={Routes.REGISTEREDWORKFLOW} component={RegisteredWorkflowPanel} />
175 <Route path={Routes.WORKFLOWS} component={WorkflowPanel} />
176 <Route path={Routes.SEARCH_RESULTS} component={SearchResultsPanel} />
177 <Route path={Routes.VIRTUAL_MACHINES_USER} component={VirtualMachineUserPanel} />
178 <Route path={Routes.VIRTUAL_MACHINES_ADMIN} component={VirtualMachineAdminPanel} />
179 <Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
180 <Route path={Routes.SSH_KEYS_USER} component={SshKeyPanel} />
181 <Route path={Routes.SSH_KEYS_ADMIN} component={SshKeyAdminPanel} />
182 <Route path={Routes.SITE_MANAGER} component={SiteManagerPanel} />
183 <Route path={Routes.KEEP_SERVICES} component={KeepServicePanel} />
184 <Route path={Routes.USERS} component={UserPanel} />
185 <Route path={Routes.API_CLIENT_AUTHORIZATIONS} component={ApiClientAuthorizationPanel} />
186 <Route path={Routes.MY_ACCOUNT} component={UserProfilePanel} />
187 <Route path={Routes.USER_PROFILE} component={UserProfilePanel} />
188 <Route path={Routes.GROUPS} component={GroupsPanel} />
189 <Route path={Routes.GROUP_DETAILS} component={GroupDetailsPanel} />
190 <Route path={Routes.LINKS} component={LinkPanel} />
191 <Route path={Routes.PUBLIC_FAVORITES} component={PublicFavoritePanel} />
192 <Route path={Routes.LINK_ACCOUNT} component={LinkAccountPanel} />
193 <Route path={Routes.COLLECTIONS_CONTENT_ADDRESS} component={CollectionsContentAddressPanel} />
196 const reduceRoutesFn: (a: React.ReactElement[],
197 b: ElementListReducer) => React.ReactElement[] = (a, b) => b(a);
199 routes = React.createElement(React.Fragment, null, pluginConfig.centerPanelList.reduce(reduceRoutesFn, React.Children.toArray(routes.props.children)));
201 const applyCollapsedState = (isCollapsed) => {
202 const rightPanel: Element = document.getElementsByClassName('layout-pane')[1]
203 const totalWidth: number = document.getElementsByClassName('splitter-layout')[0]?.clientWidth
204 const rightPanelExpandedWidth = ((totalWidth - COLLAPSE_ICON_SIZE)) / (totalWidth / 100)
206 rightPanel.setAttribute('style', `width: ${isCollapsed ? rightPanelExpandedWidth : getSplitterInitialSize()}%`)
208 const splitter = document.getElementsByClassName('layout-splitter')[0]
209 isCollapsed ? splitter?.classList.add('layout-splitter-disabled') : splitter?.classList.remove('layout-splitter-disabled')
213 export const WorkbenchPanel =
214 withStyles(styles)((props: WorkbenchPanelProps) => {
216 //panel size will not scale automatically on window resize, so we do it manually
217 window.addEventListener('resize', () => applyCollapsedState(props.sidePanelIsCollapsed))
218 applyCollapsedState(props.sidePanelIsCollapsed)
220 return <Grid container item xs className={props.classes.root}>
221 {props.sessionIdleTimeout > 0 && <AutoLogout />}
222 <Grid container item xs className={props.classes.container}>
223 <SplitterLayout customClassName={props.classes.splitter} percentage={true}
224 primaryIndex={0} primaryMinSize={10}
225 secondaryInitialSize={getSplitterInitialSize()} secondaryMinSize={40}
226 onSecondaryPaneSizeChange={saveSplitterSize}>
227 {props.isUserActive && props.isNotLinking && <Grid container item xs component='aside' direction='column' className={props.classes.asidePanel}>
230 <Grid container item xs component="main" direction="column" className={props.classes.contentWrapper}>
232 {props.isNotLinking && <MainContentBar />}
234 <Grid item xs className={props.classes.content}>
236 {routes.props.children}
237 <Route path={Routes.NO_MATCH} component={NotFoundPanel} />
246 <AdvancedTabDialog />
247 <AttributesApiClientAuthorizationDialog />
248 <AttributesKeepServiceDialog />
249 <AttributesLinkDialog />
250 <AttributesSshKeyDialog />
251 <ChangeWorkflowDialog />
253 <CopyCollectionDialog />
254 <CopyProcessDialog />
255 <CreateCollectionDialog />
256 <CreateProjectDialog />
257 <CreateRepositoryDialog />
258 <CreateSshKeyDialog />
262 <FilesUploadCollectionDialog />
263 <GroupAttributesDialog />
264 <GroupMemberAttributesDialog />
265 <HelpApiClientAuthorizationDialog />
266 <MoveCollectionDialog />
267 <MoveProcessDialog />
268 <MoveProjectDialog />
269 <MultipleFilesRemoveDialog />
271 <PartialCopyToNewCollectionDialog />
272 <PartialCopyToExistingCollectionDialog />
273 <PartialCopyToSeparateCollectionsDialog />
274 <PartialMoveToNewCollectionDialog />
275 <PartialMoveToExistingCollectionDialog />
276 <PartialMoveToSeparateCollectionsDialog />
277 <ProcessInputDialog />
278 <RestoreCollectionVersionDialog />
279 <RemoveApiClientAuthorizationDialog />
280 <RemoveGroupDialog />
281 <RemoveGroupMemberDialog />
282 <RemoveKeepServiceDialog />
284 <RemoveProcessDialog />
285 <RemoveRepositoryDialog />
286 <RemoveSshKeyDialog />
287 <RemoveVirtualMachineDialog />
288 <RemoveVirtualMachineLoginDialog />
289 <VirtualMachineAddLoginDialog />
291 <RepositoryAttributesDialog />
292 <RepositoriesSampleGitDialog />
293 <RichTextEditorDialog />
297 <UpdateCollectionDialog />
298 <UpdateProcessDialog />
299 <UpdateProjectDialog />
300 <UserAttributesDialog />
304 <VirtualMachineAttributesDialog />
306 <WebDavS3InfoDialog />
308 {React.createElement(React.Fragment, null, pluginConfig.dialogs)}