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