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 { ProcessLogPanel } from 'views/process-log-panel/process-log-panel';
24 import { ChangeWorkflowDialog } from 'views-components/run-process-dialog/change-workflow-dialog';
25 import { CreateProjectDialog } from 'views-components/dialog-forms/create-project-dialog';
26 import { CreateCollectionDialog } from 'views-components/dialog-forms/create-collection-dialog';
27 import { CopyCollectionDialog } from 'views-components/dialog-forms/copy-collection-dialog';
28 import { CopyProcessDialog } from 'views-components/dialog-forms/copy-process-dialog';
29 import { UpdateCollectionDialog } from 'views-components/dialog-forms/update-collection-dialog';
30 import { UpdateProcessDialog } from 'views-components/dialog-forms/update-process-dialog';
31 import { UpdateProjectDialog } from 'views-components/dialog-forms/update-project-dialog';
32 import { MoveProcessDialog } from 'views-components/dialog-forms/move-process-dialog';
33 import { MoveProjectDialog } from 'views-components/dialog-forms/move-project-dialog';
34 import { MoveCollectionDialog } from 'views-components/dialog-forms/move-collection-dialog';
35 import { FilesUploadCollectionDialog } from 'views-components/dialog-forms/files-upload-collection-dialog';
36 import { PartialCopyCollectionDialog } from 'views-components/dialog-forms/partial-copy-collection-dialog';
37 import { ProcessCommandDialog } from 'views-components/process-command-dialog/process-command-dialog';
38 import { RemoveProcessDialog } from 'views-components/process-remove-dialog/process-remove-dialog';
39 import { MainContentBar } from 'views-components/main-content-bar/main-content-bar';
40 import { Grid } from '@material-ui/core';
41 import { TrashPanel } from "views/trash-panel/trash-panel";
42 import { SharedWithMePanel } from 'views/shared-with-me-panel/shared-with-me-panel';
43 import { RunProcessPanel } from 'views/run-process-panel/run-process-panel';
44 import SplitterLayout from 'react-splitter-layout';
45 import { WorkflowPanel } from 'views/workflow-panel/workflow-panel';
46 import { SearchResultsPanel } from 'views/search-results-panel/search-results-panel';
47 import { SshKeyPanel } from 'views/ssh-key-panel/ssh-key-panel';
48 import { SshKeyAdminPanel } from 'views/ssh-key-panel/ssh-key-admin-panel';
49 import { SiteManagerPanel } from "views/site-manager-panel/site-manager-panel";
50 import { MyAccountPanel } from 'views/my-account-panel/my-account-panel';
51 import { SharingDialog } from 'views-components/sharing-dialog/sharing-dialog';
52 import { NotFoundDialog } from 'views-components/not-found-dialog/not-found-dialog';
53 import { AdvancedTabDialog } from 'views-components/advanced-tab-dialog/advanced-tab-dialog';
54 import { ProcessInputDialog } from 'views-components/process-input-dialog/process-input-dialog';
55 import { VirtualMachineUserPanel } from 'views/virtual-machine-panel/virtual-machine-user-panel';
56 import { VirtualMachineAdminPanel } from 'views/virtual-machine-panel/virtual-machine-admin-panel';
57 import { ResourcePropertiesDialog } from 'views-components/resource-properties-dialog/resource-properties-dialog';
58 import { RepositoriesPanel } from 'views/repositories-panel/repositories-panel';
59 import { KeepServicePanel } from 'views/keep-service-panel/keep-service-panel';
60 import { ApiClientAuthorizationPanel } from 'views/api-client-authorization-panel/api-client-authorization-panel';
61 import { LinkPanel } from 'views/link-panel/link-panel';
62 import { RepositoriesSampleGitDialog } from 'views-components/repositories-sample-git-dialog/repositories-sample-git-dialog';
63 import { RepositoryAttributesDialog } from 'views-components/repository-attributes-dialog/repository-attributes-dialog';
64 import { CreateRepositoryDialog } from 'views-components/dialog-forms/create-repository-dialog';
65 import { RemoveRepositoryDialog } from 'views-components/repository-remove-dialog/repository-remove-dialog';
66 import { CreateSshKeyDialog } from 'views-components/dialog-forms/create-ssh-key-dialog';
67 import { PublicKeyDialog } from 'views-components/ssh-keys-dialog/public-key-dialog';
68 import { RemoveApiClientAuthorizationDialog } from 'views-components/api-client-authorizations-dialog/remove-dialog';
69 import { RemoveKeepServiceDialog } from 'views-components/keep-services-dialog/remove-dialog';
70 import { RemoveLinkDialog } from 'views-components/links-dialog/remove-dialog';
71 import { RemoveSshKeyDialog } from 'views-components/ssh-keys-dialog/remove-dialog';
72 import { RemoveVirtualMachineDialog } from 'views-components/virtual-machines-dialog/remove-dialog';
73 import { AttributesApiClientAuthorizationDialog } from 'views-components/api-client-authorizations-dialog/attributes-dialog';
74 import { AttributesKeepServiceDialog } from 'views-components/keep-services-dialog/attributes-dialog';
75 import { AttributesLinkDialog } from 'views-components/links-dialog/attributes-dialog';
76 import { AttributesSshKeyDialog } from 'views-components/ssh-keys-dialog/attributes-dialog';
77 import { VirtualMachineAttributesDialog } from 'views-components/virtual-machines-dialog/attributes-dialog';
78 import { UserPanel } from 'views/user-panel/user-panel';
79 import { UserAttributesDialog } from 'views-components/user-dialog/attributes-dialog';
80 import { CreateUserDialog } from 'views-components/dialog-forms/create-user-dialog';
81 import { HelpApiClientAuthorizationDialog } from 'views-components/api-client-authorizations-dialog/help-dialog';
82 import { UserManageDialog } from 'views-components/user-dialog/manage-dialog';
83 import { SetupShellAccountDialog } from 'views-components/dialog-forms/setup-shell-account-dialog';
84 import { GroupsPanel } from 'views/groups-panel/groups-panel';
85 import { RemoveGroupDialog } from 'views-components/groups-dialog/remove-dialog';
86 import { GroupAttributesDialog } from 'views-components/groups-dialog/attributes-dialog';
87 import { GroupDetailsPanel } from 'views/group-details-panel/group-details-panel';
88 import { RemoveGroupMemberDialog } from 'views-components/groups-dialog/member-remove-dialog';
89 import { GroupMemberAttributesDialog } from 'views-components/groups-dialog/member-attributes-dialog';
90 import { PartialCopyToCollectionDialog } from 'views-components/dialog-forms/partial-copy-to-collection-dialog';
91 import { PublicFavoritePanel } from 'views/public-favorites-panel/public-favorites-panel';
92 import { LinkAccountPanel } from 'views/link-account-panel/link-account-panel';
93 import { FedLogin } from './fed-login';
94 import { CollectionsContentAddressPanel } from 'views/collection-content-address-panel/collection-content-address-panel';
95 import { AllProcessesPanel } from '../all-processes-panel/all-processes-panel';
96 import { NotFoundPanel } from '../not-found-panel/not-found-panel';
97 import { AutoLogout } from 'views-components/auto-logout/auto-logout';
98 import { RestoreCollectionVersionDialog } from 'views-components/collections-dialog/restore-version-dialog';
99 import { WebDavS3InfoDialog } from 'views-components/webdav-s3-dialog/webdav-s3-dialog';
100 import { pluginConfig } from 'plugins';
101 import { ElementListReducer } from 'common/plugintypes';
103 type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
105 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
107 paddingTop: theme.spacing.unit * 7,
108 background: theme.palette.background.default
114 '& > .layout-splitter': {
119 paddingTop: theme.spacing.unit,
123 paddingTop: theme.spacing.unit,
128 paddingLeft: theme.spacing.unit * 3,
129 paddingRight: theme.spacing.unit * 3,
130 // Reserve vertical space for app bar + MainContentBar
131 minHeight: `calc(100vh - ${theme.spacing.unit * 16}px)`,
136 interface WorkbenchDataProps {
137 isUserActive: boolean;
138 isNotLinking: boolean;
139 sessionIdleTimeout: number;
142 type WorkbenchPanelProps = WithStyles<CssRules> & WorkbenchDataProps;
144 const defaultSplitterSize = 90;
146 const getSplitterInitialSize = () => {
147 const splitterSize = localStorage.getItem('splitterSize');
148 return splitterSize ? Number(splitterSize) : defaultSplitterSize;
151 const saveSplitterSize = (size: number) => localStorage.setItem('splitterSize', size.toString());
154 <Route path={Routes.PROJECTS} component={ProjectPanel} />
155 <Route path={Routes.COLLECTIONS} component={CollectionPanel} />
156 <Route path={Routes.FAVORITES} component={FavoritePanel} />
157 <Route path={Routes.ALL_PROCESSES} component={AllProcessesPanel} />
158 <Route path={Routes.PROCESSES} component={ProcessPanel} />
159 <Route path={Routes.TRASH} component={TrashPanel} />
160 <Route path={Routes.PROCESS_LOGS} component={ProcessLogPanel} />
161 <Route path={Routes.SHARED_WITH_ME} component={SharedWithMePanel} />
162 <Route path={Routes.RUN_PROCESS} component={RunProcessPanel} />
163 <Route path={Routes.WORKFLOWS} component={WorkflowPanel} />
164 <Route path={Routes.SEARCH_RESULTS} component={SearchResultsPanel} />
165 <Route path={Routes.VIRTUAL_MACHINES_USER} component={VirtualMachineUserPanel} />
166 <Route path={Routes.VIRTUAL_MACHINES_ADMIN} component={VirtualMachineAdminPanel} />
167 <Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
168 <Route path={Routes.SSH_KEYS_USER} component={SshKeyPanel} />
169 <Route path={Routes.SSH_KEYS_ADMIN} component={SshKeyAdminPanel} />
170 <Route path={Routes.SITE_MANAGER} component={SiteManagerPanel} />
171 <Route path={Routes.KEEP_SERVICES} component={KeepServicePanel} />
172 <Route path={Routes.USERS} component={UserPanel} />
173 <Route path={Routes.API_CLIENT_AUTHORIZATIONS} component={ApiClientAuthorizationPanel} />
174 <Route path={Routes.MY_ACCOUNT} component={MyAccountPanel} />
175 <Route path={Routes.GROUPS} component={GroupsPanel} />
176 <Route path={Routes.GROUP_DETAILS} component={GroupDetailsPanel} />
177 <Route path={Routes.LINKS} component={LinkPanel} />
178 <Route path={Routes.PUBLIC_FAVORITES} component={PublicFavoritePanel} />
179 <Route path={Routes.LINK_ACCOUNT} component={LinkAccountPanel} />
180 <Route path={Routes.COLLECTIONS_CONTENT_ADDRESS} component={CollectionsContentAddressPanel} />
183 const reduceRoutesFn: (a: React.ReactElement[],
184 b: ElementListReducer) => React.ReactElement[] = (a, b) => b(a);
186 routes = React.createElement(React.Fragment, null, pluginConfig.centerPanelList.reduce(reduceRoutesFn, React.Children.toArray(routes.props.children)));
188 export const WorkbenchPanel =
189 withStyles(styles)((props: WorkbenchPanelProps) =>
190 <Grid container item xs className={props.classes.root}>
191 {props.sessionIdleTimeout > 0 && <AutoLogout />}
192 <Grid container item xs className={props.classes.container}>
193 <SplitterLayout customClassName={props.classes.splitter} percentage={true}
194 primaryIndex={0} primaryMinSize={10}
195 secondaryInitialSize={getSplitterInitialSize()} secondaryMinSize={40}
196 onSecondaryPaneSizeChange={saveSplitterSize}>
197 {props.isUserActive && props.isNotLinking && <Grid container item xs component='aside' direction='column' className={props.classes.asidePanel}>
200 <Grid container item xs component="main" direction="column" className={props.classes.contentWrapper}>
202 {props.isNotLinking && <MainContentBar />}
204 <Grid item xs className={props.classes.content}>
206 {routes.props.children}
207 <Route path={Routes.NO_MATCH} component={NotFoundPanel} />
216 <AdvancedTabDialog />
217 <AttributesApiClientAuthorizationDialog />
218 <AttributesKeepServiceDialog />
219 <AttributesLinkDialog />
220 <AttributesSshKeyDialog />
221 <ChangeWorkflowDialog />
223 <CopyCollectionDialog />
224 <CopyProcessDialog />
225 <CreateCollectionDialog />
226 <CreateProjectDialog />
227 <CreateRepositoryDialog />
228 <CreateSshKeyDialog />
232 <FilesUploadCollectionDialog />
233 <GroupAttributesDialog />
234 <GroupMemberAttributesDialog />
235 <HelpApiClientAuthorizationDialog />
236 <MoveCollectionDialog />
237 <MoveProcessDialog />
238 <MoveProjectDialog />
239 <MultipleFilesRemoveDialog />
241 <PartialCopyCollectionDialog />
242 <PartialCopyToCollectionDialog />
243 <ProcessCommandDialog />
244 <ProcessInputDialog />
245 <ResourcePropertiesDialog />
246 <RestoreCollectionVersionDialog />
247 <RemoveApiClientAuthorizationDialog />
248 <RemoveGroupDialog />
249 <RemoveGroupMemberDialog />
250 <RemoveKeepServiceDialog />
252 <RemoveProcessDialog />
253 <RemoveRepositoryDialog />
254 <RemoveSshKeyDialog />
255 <RemoveVirtualMachineDialog />
257 <RepositoryAttributesDialog />
258 <RepositoriesSampleGitDialog />
259 <RichTextEditorDialog />
260 <SetupShellAccountDialog />
264 <UpdateCollectionDialog />
265 <UpdateProcessDialog />
266 <UpdateProjectDialog />
267 <UserAttributesDialog />
269 <VirtualMachineAttributesDialog />
271 <WebDavS3InfoDialog />
272 {React.createElement(React.Fragment, null, pluginConfig.dialogs)}