Add cluster render
[arvados-workbench2.git] / src / views / workbench / workbench.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as 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 { CurrentTokenDialog } from '~/views-components/current-token-dialog/current-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 { SiteManagerPanel } from "~/views/site-manager-panel/site-manager-panel";
49 import { MyAccountPanel } from '~/views/my-account-panel/my-account-panel';
50 import { SharingDialog } from '~/views-components/sharing-dialog/sharing-dialog';
51 import { AdvancedTabDialog } from '~/views-components/advanced-tab-dialog/advanced-tab-dialog';
52 import { ProcessInputDialog } from '~/views-components/process-input-dialog/process-input-dialog';
53 import { VirtualMachineUserPanel } from '~/views/virtual-machine-panel/virtual-machine-user-panel';
54 import { VirtualMachineAdminPanel } from '~/views/virtual-machine-panel/virtual-machine-admin-panel';
55 import { ProjectPropertiesDialog } from '~/views-components/project-properties-dialog/project-properties-dialog';
56 import { RepositoriesPanel } from '~/views/repositories-panel/repositories-panel';
57 import { KeepServicePanel } from '~/views/keep-service-panel/keep-service-panel';
58 import { ComputeNodePanel } from '~/views/compute-node-panel/compute-node-panel';
59 import { ApiClientAuthorizationPanel } from '~/views/api-client-authorization-panel/api-client-authorization-panel';
60 import { LinkPanel } from '~/views/link-panel/link-panel';
61 import { RepositoriesSampleGitDialog } from '~/views-components/repositories-sample-git-dialog/repositories-sample-git-dialog';
62 import { RepositoryAttributesDialog } from '~/views-components/repository-attributes-dialog/repository-attributes-dialog';
63 import { CreateRepositoryDialog } from '~/views-components/dialog-forms/create-repository-dialog';
64 import { RemoveRepositoryDialog } from '~/views-components/repository-remove-dialog/repository-remove-dialog';
65 import { CreateSshKeyDialog } from '~/views-components/dialog-forms/create-ssh-key-dialog';
66 import { PublicKeyDialog } from '~/views-components/ssh-keys-dialog/public-key-dialog';
67 import { RemoveApiClientAuthorizationDialog } from '~/views-components/api-client-authorizations-dialog/remove-dialog';
68 import { RemoveComputeNodeDialog } from '~/views-components/compute-nodes-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 { AttributesComputeNodeDialog } from '~/views-components/compute-nodes-dialog/attributes-dialog';
75 import { AttributesKeepServiceDialog } from '~/views-components/keep-services-dialog/attributes-dialog';
76 import { AttributesLinkDialog } from '~/views-components/links-dialog/attributes-dialog';
77 import { AttributesSshKeyDialog } from '~/views-components/ssh-keys-dialog/attributes-dialog';
78 import { VirtualMachineAttributesDialog } from '~/views-components/virtual-machines-dialog/attributes-dialog';
79 import { UserPanel } from '~/views/user-panel/user-panel';
80 import { UserAttributesDialog } from '~/views-components/user-dialog/attributes-dialog';
81 import { CreateUserDialog } from '~/views-components/dialog-forms/create-user-dialog';
82 import { HelpApiClientAuthorizationDialog } from '~/views-components/api-client-authorizations-dialog/help-dialog';
83 import { GroupsPanel } from '~/views/groups-panel/groups-panel';
84 import { CreateGroupDialog } from '~/views-components/dialog-forms/create-group-dialog';
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 { AddGroupMembersDialog } from '~/views-components/dialog-forms/add-group-member-dialog';
91
92 type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
93
94 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
95     root: {
96         paddingTop: theme.spacing.unit * 7,
97         background: theme.palette.background.default
98     },
99     container: {
100         position: 'relative'
101     },
102     splitter: {
103         '& > .layout-splitter': {
104             width: '2px'
105         }
106     },
107     asidePanel: {
108         paddingTop: theme.spacing.unit,
109         height: '100%'
110     },
111     contentWrapper: {
112         paddingTop: theme.spacing.unit,
113         minWidth: 0
114     },
115     content: {
116         minWidth: 0,
117         paddingLeft: theme.spacing.unit * 3,
118         paddingRight: theme.spacing.unit * 3,
119     }
120 });
121
122 type WorkbenchPanelProps = WithStyles<CssRules>;
123
124 const defaultSplitterSize = 90;
125
126 const getSplitterInitialSize = () => {
127     const splitterSize = localStorage.getItem('splitterSize');
128     return splitterSize ? Number(splitterSize) : defaultSplitterSize;
129 };
130
131 const saveSplitterSize = (size: number) => localStorage.setItem('splitterSize', size.toString());
132
133 export const WorkbenchPanel =
134     withStyles(styles)(({ classes }: WorkbenchPanelProps) =>
135         <Grid container item xs className={classes.root}>
136             <Grid container item xs className={classes.container}>
137                 <SplitterLayout customClassName={classes.splitter} percentage={true}
138                                 primaryIndex={0} primaryMinSize={10}
139                                 secondaryInitialSize={getSplitterInitialSize()} secondaryMinSize={40}
140                                 onSecondaryPaneSizeChange={saveSplitterSize}>
141                     <Grid container item xs component='aside' direction='column' className={classes.asidePanel}>
142                         <SidePanel />
143                     </Grid>
144                     <Grid container item xs component="main" direction="column" className={classes.contentWrapper}>
145                         <Grid item>
146                             <MainContentBar />
147                         </Grid>
148                         <Grid item xs className={classes.content}>
149                             <Switch>
150                                 <Route path={Routes.PROJECTS} component={ProjectPanel} />
151                                 <Route path={Routes.COLLECTIONS} component={CollectionPanel} />
152                                 <Route path={Routes.FAVORITES} component={FavoritePanel} />
153                                 <Route path={Routes.PROCESSES} component={ProcessPanel} />
154                                 <Route path={Routes.TRASH} component={TrashPanel} />
155                                 <Route path={Routes.PROCESS_LOGS} component={ProcessLogPanel} />
156                                 <Route path={Routes.SHARED_WITH_ME} component={SharedWithMePanel} />
157                                 <Route path={Routes.RUN_PROCESS} component={RunProcessPanel} />
158                                 <Route path={Routes.WORKFLOWS} component={WorkflowPanel} />
159                                 <Route path={Routes.SEARCH_RESULTS} component={SearchResultsPanel} />
160                                 <Route path={Routes.VIRTUAL_MACHINES_USER} component={VirtualMachineUserPanel} />
161                                 <Route path={Routes.VIRTUAL_MACHINES_ADMIN} component={VirtualMachineAdminPanel} />
162                                 <Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
163                                 <Route path={Routes.SSH_KEYS_USER} component={SshKeyPanel} />
164                                 <Route path={Routes.SSH_KEYS_ADMIN} component={SshKeyPanel} />
165                                 <Route path={Routes.SITE_MANAGER} component={SiteManagerPanel} />
166                                 <Route path={Routes.KEEP_SERVICES} component={KeepServicePanel} />
167                                 <Route path={Routes.USERS} component={UserPanel} />
168                                 <Route path={Routes.COMPUTE_NODES} component={ComputeNodePanel} />
169                                 <Route path={Routes.API_CLIENT_AUTHORIZATIONS} component={ApiClientAuthorizationPanel} />
170                                 <Route path={Routes.MY_ACCOUNT} component={MyAccountPanel} />
171                                 <Route path={Routes.GROUPS} component={GroupsPanel} />
172                                 <Route path={Routes.GROUP_DETAILS} component={GroupDetailsPanel} />
173                                 <Route path={Routes.LINKS} component={LinkPanel} />
174                             </Switch>
175                         </Grid>
176                     </Grid>
177                 </SplitterLayout>
178             </Grid>
179             <Grid item>
180                 <DetailsPanel />
181             </Grid>
182             <AddGroupMembersDialog />
183             <AdvancedTabDialog />
184             <AttributesApiClientAuthorizationDialog />
185             <AttributesComputeNodeDialog />
186             <AttributesKeepServiceDialog />
187             <AttributesLinkDialog />
188             <AttributesSshKeyDialog />
189             <ChangeWorkflowDialog />
190             <ContextMenu />
191             <CopyCollectionDialog />
192             <CopyProcessDialog />
193             <CreateCollectionDialog />
194             <CreateGroupDialog />
195             <CreateProjectDialog />
196             <CreateRepositoryDialog />
197             <CreateSshKeyDialog />
198             <CreateUserDialog />
199             <CurrentTokenDialog />
200             <FileRemoveDialog />
201             <FilesUploadCollectionDialog />
202             <GroupAttributesDialog />
203             <GroupMemberAttributesDialog />
204             <HelpApiClientAuthorizationDialog />
205             <MoveCollectionDialog />
206             <MoveProcessDialog />
207             <MoveProjectDialog />
208             <MultipleFilesRemoveDialog />
209             <PublicKeyDialog />
210             <PartialCopyCollectionDialog />
211             <ProcessCommandDialog />
212             <ProcessInputDialog />
213             <ProjectPropertiesDialog />
214             <RemoveApiClientAuthorizationDialog />
215             <RemoveComputeNodeDialog />
216             <RemoveGroupDialog />
217             <RemoveGroupMemberDialog />
218             <RemoveKeepServiceDialog />
219             <RemoveLinkDialog />
220             <RemoveProcessDialog />
221             <RemoveRepositoryDialog />
222             <RemoveSshKeyDialog />
223             <RemoveVirtualMachineDialog />
224             <RenameFileDialog />
225             <RepositoryAttributesDialog />
226             <RepositoriesSampleGitDialog />
227             <RichTextEditorDialog />
228             <SharingDialog />
229             <Snackbar />
230             <UpdateCollectionDialog />
231             <UpdateProcessDialog />
232             <UpdateProjectDialog />
233             <UserAttributesDialog />
234             <VirtualMachineAttributesDialog />
235         </Grid>
236     );