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