refs #14781-font-color-on-process-logs-were-black-on-black-bg
[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 { UserManageDialog } from '~/views-components/user-dialog/manage-dialog';
84 import { SetupShellAccountDialog } from '~/views-components/dialog-forms/setup-shell-account-dialog';
85 import { GroupsPanel } from '~/views/groups-panel/groups-panel';
86 import { CreateGroupDialog } from '~/views-components/dialog-forms/create-group-dialog';
87 import { RemoveGroupDialog } from '~/views-components/groups-dialog/remove-dialog';
88 import { GroupAttributesDialog } from '~/views-components/groups-dialog/attributes-dialog';
89 import { GroupDetailsPanel } from '~/views/group-details-panel/group-details-panel';
90 import { RemoveGroupMemberDialog } from '~/views-components/groups-dialog/member-remove-dialog';
91 import { GroupMemberAttributesDialog } from '~/views-components/groups-dialog/member-attributes-dialog';
92 import { AddGroupMembersDialog } from '~/views-components/dialog-forms/add-group-member-dialog';
93
94 type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
95
96 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
97     root: {
98         paddingTop: theme.spacing.unit * 7,
99         background: theme.palette.background.default
100     },
101     container: {
102         position: 'relative'
103     },
104     splitter: {
105         '& > .layout-splitter': {
106             width: '2px'
107         }
108     },
109     asidePanel: {
110         paddingTop: theme.spacing.unit,
111         height: '100%'
112     },
113     contentWrapper: {
114         paddingTop: theme.spacing.unit,
115         minWidth: 0
116     },
117     content: {
118         minWidth: 0,
119         paddingLeft: theme.spacing.unit * 3,
120         paddingRight: theme.spacing.unit * 3,
121     }
122 });
123
124 type WorkbenchPanelProps = WithStyles<CssRules>;
125
126 const defaultSplitterSize = 90;
127
128 const getSplitterInitialSize = () => {
129     const splitterSize = localStorage.getItem('splitterSize');
130     return splitterSize ? Number(splitterSize) : defaultSplitterSize;
131 };
132
133 const saveSplitterSize = (size: number) => localStorage.setItem('splitterSize', size.toString());
134
135 export const WorkbenchPanel =
136     withStyles(styles)(({ classes }: WorkbenchPanelProps) =>
137         <Grid container item xs className={classes.root}>
138             <Grid container item xs className={classes.container}>
139                 <SplitterLayout customClassName={classes.splitter} percentage={true}
140                                 primaryIndex={0} primaryMinSize={10}
141                                 secondaryInitialSize={getSplitterInitialSize()} secondaryMinSize={40}
142                                 onSecondaryPaneSizeChange={saveSplitterSize}>
143                     <Grid container item xs component='aside' direction='column' className={classes.asidePanel}>
144                         <SidePanel />
145                     </Grid>
146                     <Grid container item xs component="main" direction="column" className={classes.contentWrapper}>
147                         <Grid item>
148                             <MainContentBar />
149                         </Grid>
150                         <Grid item xs className={classes.content}>
151                             <Switch>
152                                 <Route path={Routes.PROJECTS} component={ProjectPanel} />
153                                 <Route path={Routes.COLLECTIONS} component={CollectionPanel} />
154                                 <Route path={Routes.FAVORITES} component={FavoritePanel} />
155                                 <Route path={Routes.PROCESSES} component={ProcessPanel} />
156                                 <Route path={Routes.TRASH} component={TrashPanel} />
157                                 <Route path={Routes.PROCESS_LOGS} component={ProcessLogPanel} />
158                                 <Route path={Routes.SHARED_WITH_ME} component={SharedWithMePanel} />
159                                 <Route path={Routes.RUN_PROCESS} component={RunProcessPanel} />
160                                 <Route path={Routes.WORKFLOWS} component={WorkflowPanel} />
161                                 <Route path={Routes.SEARCH_RESULTS} component={SearchResultsPanel} />
162                                 <Route path={Routes.VIRTUAL_MACHINES_USER} component={VirtualMachineUserPanel} />
163                                 <Route path={Routes.VIRTUAL_MACHINES_ADMIN} component={VirtualMachineAdminPanel} />
164                                 <Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
165                                 <Route path={Routes.SSH_KEYS_USER} component={SshKeyPanel} />
166                                 <Route path={Routes.SSH_KEYS_ADMIN} component={SshKeyPanel} />
167                                 <Route path={Routes.SITE_MANAGER} component={SiteManagerPanel} />
168                                 <Route path={Routes.KEEP_SERVICES} component={KeepServicePanel} />
169                                 <Route path={Routes.USERS} component={UserPanel} />
170                                 <Route path={Routes.COMPUTE_NODES} component={ComputeNodePanel} />
171                                 <Route path={Routes.API_CLIENT_AUTHORIZATIONS} component={ApiClientAuthorizationPanel} />
172                                 <Route path={Routes.MY_ACCOUNT} component={MyAccountPanel} />
173                                 <Route path={Routes.GROUPS} component={GroupsPanel} />
174                                 <Route path={Routes.GROUP_DETAILS} component={GroupDetailsPanel} />
175                                 <Route path={Routes.LINKS} component={LinkPanel} />
176                             </Switch>
177                         </Grid>
178                     </Grid>
179                 </SplitterLayout>
180             </Grid>
181             <Grid item>
182                 <DetailsPanel />
183             </Grid>
184             <AddGroupMembersDialog />
185             <AdvancedTabDialog />
186             <AttributesApiClientAuthorizationDialog />
187             <AttributesComputeNodeDialog />
188             <AttributesKeepServiceDialog />
189             <AttributesLinkDialog />
190             <AttributesSshKeyDialog />
191             <ChangeWorkflowDialog />
192             <ContextMenu />
193             <CopyCollectionDialog />
194             <CopyProcessDialog />
195             <CreateCollectionDialog />
196             <CreateGroupDialog />
197             <CreateProjectDialog />
198             <CreateRepositoryDialog />
199             <CreateSshKeyDialog />
200             <CreateUserDialog />
201             <CurrentTokenDialog />
202             <FileRemoveDialog />
203             <FilesUploadCollectionDialog />
204             <GroupAttributesDialog />
205             <GroupMemberAttributesDialog />
206             <HelpApiClientAuthorizationDialog />
207             <MoveCollectionDialog />
208             <MoveProcessDialog />
209             <MoveProjectDialog />
210             <MultipleFilesRemoveDialog />
211             <PublicKeyDialog />
212             <PartialCopyCollectionDialog />
213             <ProcessCommandDialog />
214             <ProcessInputDialog />
215             <ProjectPropertiesDialog />
216             <RemoveApiClientAuthorizationDialog />
217             <RemoveComputeNodeDialog />
218             <RemoveGroupDialog />
219             <RemoveGroupMemberDialog />
220             <RemoveKeepServiceDialog />
221             <RemoveLinkDialog />
222             <RemoveProcessDialog />
223             <RemoveRepositoryDialog />
224             <RemoveSshKeyDialog />
225             <RemoveVirtualMachineDialog />
226             <RenameFileDialog />
227             <RepositoryAttributesDialog />
228             <RepositoriesSampleGitDialog />
229             <RichTextEditorDialog />
230             <SetupShellAccountDialog />
231             <SharingDialog />
232             <Snackbar />
233             <UpdateCollectionDialog />
234             <UpdateProcessDialog />
235             <UpdateProjectDialog />
236             <UserAttributesDialog />
237             <UserManageDialog />
238             <VirtualMachineAttributesDialog />
239         </Grid>
240     );