Merge branch '17426-plug-ins' refs #17426
[arvados-workbench2.git] / src / views / workbench / workbench.tsx
index cca374d6738e9645f5183871252a20d66311a979..78ec3c87cb24bce04e5a7387963409d94db074df 100644 (file)
@@ -10,7 +10,7 @@ import { DetailsPanel } from '~/views-components/details-panel/details-panel';
 import { ArvadosTheme } from '~/common/custom-theme';
 import { ContextMenu } from "~/views-components/context-menu/context-menu";
 import { FavoritePanel } from "../favorite-panel/favorite-panel";
-import { CurrentTokenDialog } from '~/views-components/current-token-dialog/current-token-dialog';
+import { TokenDialog } from '~/views-components/token-dialog/token-dialog';
 import { RichTextEditorDialog } from '~/views-components/rich-text-editor-dialog/rich-text-editor-dialog';
 import { Snackbar } from '~/views-components/snackbar/snackbar';
 import { CollectionPanel } from '../collection-panel/collection-panel';
@@ -48,6 +48,7 @@ import { SshKeyPanel } from '~/views/ssh-key-panel/ssh-key-panel';
 import { SiteManagerPanel } from "~/views/site-manager-panel/site-manager-panel";
 import { MyAccountPanel } from '~/views/my-account-panel/my-account-panel';
 import { SharingDialog } from '~/views-components/sharing-dialog/sharing-dialog';
+import { NotFoundDialog } from '~/views-components/not-found-dialog/not-found-dialog';
 import { AdvancedTabDialog } from '~/views-components/advanced-tab-dialog/advanced-tab-dialog';
 import { ProcessInputDialog } from '~/views-components/process-input-dialog/process-input-dialog';
 import { VirtualMachineUserPanel } from '~/views/virtual-machine-panel/virtual-machine-user-panel';
@@ -90,6 +91,18 @@ import { GroupDetailsPanel } from '~/views/group-details-panel/group-details-pan
 import { RemoveGroupMemberDialog } from '~/views-components/groups-dialog/member-remove-dialog';
 import { GroupMemberAttributesDialog } from '~/views-components/groups-dialog/member-attributes-dialog';
 import { AddGroupMembersDialog } from '~/views-components/dialog-forms/add-group-member-dialog';
+import { PartialCopyToCollectionDialog } from '~/views-components/dialog-forms/partial-copy-to-collection-dialog';
+import { PublicFavoritePanel } from '~/views/public-favorites-panel/public-favorites-panel';
+import { LinkAccountPanel } from '~/views/link-account-panel/link-account-panel';
+import { FedLogin } from './fed-login';
+import { CollectionsContentAddressPanel } from '~/views/collection-content-address-panel/collection-content-address-panel';
+import { AllProcessesPanel } from '../all-processes-panel/all-processes-panel';
+import { NotFoundPanel } from '../not-found-panel/not-found-panel';
+import { AutoLogout } from '~/views-components/auto-logout/auto-logout';
+import { RestoreCollectionVersionDialog } from '~/views-components/collections-dialog/restore-version-dialog';
+import { WebDavS3InfoDialog } from '~/views-components/webdav-s3-dialog/webdav-s3-dialog';
+import { pluginConfig } from '~/plugins';
+import { ElementListReducer } from '~/common/plugintypes';
 
 type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
 
@@ -121,7 +134,13 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     }
 });
 
-type WorkbenchPanelProps = WithStyles<CssRules>;
+interface WorkbenchDataProps {
+    isUserActive: boolean;
+    isNotLinking: boolean;
+    sessionIdleTimeout: number;
+}
+
+type WorkbenchPanelProps = WithStyles<CssRules> & WorkbenchDataProps;
 
 const defaultSplitterSize = 90;
 
@@ -132,47 +151,62 @@ const getSplitterInitialSize = () => {
 
 const saveSplitterSize = (size: number) => localStorage.setItem('splitterSize', size.toString());
 
+let routes = <>
+    <Route path={Routes.PROJECTS} component={ProjectPanel} />
+    <Route path={Routes.COLLECTIONS} component={CollectionPanel} />
+    <Route path={Routes.FAVORITES} component={FavoritePanel} />
+    <Route path={Routes.ALL_PROCESSES} component={AllProcessesPanel} />
+    <Route path={Routes.PROCESSES} component={ProcessPanel} />
+    <Route path={Routes.TRASH} component={TrashPanel} />
+    <Route path={Routes.PROCESS_LOGS} component={ProcessLogPanel} />
+    <Route path={Routes.SHARED_WITH_ME} component={SharedWithMePanel} />
+    <Route path={Routes.RUN_PROCESS} component={RunProcessPanel} />
+    <Route path={Routes.WORKFLOWS} component={WorkflowPanel} />
+    <Route path={Routes.SEARCH_RESULTS} component={SearchResultsPanel} />
+    <Route path={Routes.VIRTUAL_MACHINES_USER} component={VirtualMachineUserPanel} />
+    <Route path={Routes.VIRTUAL_MACHINES_ADMIN} component={VirtualMachineAdminPanel} />
+    <Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
+    <Route path={Routes.SSH_KEYS_USER} component={SshKeyPanel} />
+    <Route path={Routes.SSH_KEYS_ADMIN} component={SshKeyPanel} />
+    <Route path={Routes.SITE_MANAGER} component={SiteManagerPanel} />
+    <Route path={Routes.KEEP_SERVICES} component={KeepServicePanel} />
+    <Route path={Routes.USERS} component={UserPanel} />
+    <Route path={Routes.COMPUTE_NODES} component={ComputeNodePanel} />
+    <Route path={Routes.API_CLIENT_AUTHORIZATIONS} component={ApiClientAuthorizationPanel} />
+    <Route path={Routes.MY_ACCOUNT} component={MyAccountPanel} />
+    <Route path={Routes.GROUPS} component={GroupsPanel} />
+    <Route path={Routes.GROUP_DETAILS} component={GroupDetailsPanel} />
+    <Route path={Routes.LINKS} component={LinkPanel} />
+    <Route path={Routes.PUBLIC_FAVORITES} component={PublicFavoritePanel} />
+    <Route path={Routes.LINK_ACCOUNT} component={LinkAccountPanel} />
+    <Route path={Routes.COLLECTIONS_CONTENT_ADDRESS} component={CollectionsContentAddressPanel} />
+</>;
+
+const reduceRoutesFn: (a: React.ReactElement[],
+    b: ElementListReducer) => React.ReactElement[] = (a, b) => b(a);
+
+routes = React.createElement(React.Fragment, null, pluginConfig.centerPanelList.reduce(reduceRoutesFn, React.Children.toArray(routes.props.children)));
+
 export const WorkbenchPanel =
-    withStyles(styles)(({ classes }: WorkbenchPanelProps) =>
-        <Grid container item xs className={classes.root}>
-            <Grid container item xs className={classes.container}>
-                <SplitterLayout customClassName={classes.splitter} percentage={true}
-                                primaryIndex={0} primaryMinSize={10}
-                                secondaryInitialSize={getSplitterInitialSize()} secondaryMinSize={40}
-                                onSecondaryPaneSizeChange={saveSplitterSize}>
-                    <Grid container item xs component='aside' direction='column' className={classes.asidePanel}>
+    withStyles(styles)((props: WorkbenchPanelProps) =>
+        <Grid container item xs className={props.classes.root}>
+            {props.sessionIdleTimeout > 0 && <AutoLogout />}
+            <Grid container item xs className={props.classes.container}>
+                <SplitterLayout customClassName={props.classes.splitter} percentage={true}
+                    primaryIndex={0} primaryMinSize={10}
+                    secondaryInitialSize={getSplitterInitialSize()} secondaryMinSize={40}
+                    onSecondaryPaneSizeChange={saveSplitterSize}>
+                    {props.isUserActive && props.isNotLinking && <Grid container item xs component='aside' direction='column' className={props.classes.asidePanel}>
                         <SidePanel />
-                    </Grid>
-                    <Grid container item xs component="main" direction="column" className={classes.contentWrapper}>
-                        <Grid item>
-                            <MainContentBar />
+                    </Grid>}
+                    <Grid container item xs component="main" direction="column" className={props.classes.contentWrapper}>
+                        <Grid item xs>
+                            {props.isNotLinking && <MainContentBar />}
                         </Grid>
-                        <Grid item xs className={classes.content}>
+                        <Grid item xs className={props.classes.content}>
                             <Switch>
-                                <Route path={Routes.PROJECTS} component={ProjectPanel} />
-                                <Route path={Routes.COLLECTIONS} component={CollectionPanel} />
-                                <Route path={Routes.FAVORITES} component={FavoritePanel} />
-                                <Route path={Routes.PROCESSES} component={ProcessPanel} />
-                                <Route path={Routes.TRASH} component={TrashPanel} />
-                                <Route path={Routes.PROCESS_LOGS} component={ProcessLogPanel} />
-                                <Route path={Routes.SHARED_WITH_ME} component={SharedWithMePanel} />
-                                <Route path={Routes.RUN_PROCESS} component={RunProcessPanel} />
-                                <Route path={Routes.WORKFLOWS} component={WorkflowPanel} />
-                                <Route path={Routes.SEARCH_RESULTS} component={SearchResultsPanel} />
-                                <Route path={Routes.VIRTUAL_MACHINES_USER} component={VirtualMachineUserPanel} />
-                                <Route path={Routes.VIRTUAL_MACHINES_ADMIN} component={VirtualMachineAdminPanel} />
-                                <Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
-                                <Route path={Routes.SSH_KEYS_USER} component={SshKeyPanel} />
-                                <Route path={Routes.SSH_KEYS_ADMIN} component={SshKeyPanel} />
-                                <Route path={Routes.SITE_MANAGER} component={SiteManagerPanel} />
-                                <Route path={Routes.KEEP_SERVICES} component={KeepServicePanel} />
-                                <Route path={Routes.USERS} component={UserPanel} />
-                                <Route path={Routes.COMPUTE_NODES} component={ComputeNodePanel} />
-                                <Route path={Routes.API_CLIENT_AUTHORIZATIONS} component={ApiClientAuthorizationPanel} />
-                                <Route path={Routes.MY_ACCOUNT} component={MyAccountPanel} />
-                                <Route path={Routes.GROUPS} component={GroupsPanel} />
-                                <Route path={Routes.GROUP_DETAILS} component={GroupDetailsPanel} />
-                                <Route path={Routes.LINKS} component={LinkPanel} />
+                                {routes}
+                                <Route path={Routes.NO_MATCH} component={NotFoundPanel} />
                             </Switch>
                         </Grid>
                     </Grid>
@@ -198,7 +232,7 @@ export const WorkbenchPanel =
             <CreateRepositoryDialog />
             <CreateSshKeyDialog />
             <CreateUserDialog />
-            <CurrentTokenDialog />
+            <TokenDialog />
             <FileRemoveDialog />
             <FilesUploadCollectionDialog />
             <GroupAttributesDialog />
@@ -210,9 +244,11 @@ export const WorkbenchPanel =
             <MultipleFilesRemoveDialog />
             <PublicKeyDialog />
             <PartialCopyCollectionDialog />
+            <PartialCopyToCollectionDialog />
             <ProcessCommandDialog />
             <ProcessInputDialog />
             <ProjectPropertiesDialog />
+            <RestoreCollectionVersionDialog />
             <RemoveApiClientAuthorizationDialog />
             <RemoveComputeNodeDialog />
             <RemoveGroupDialog />
@@ -229,6 +265,7 @@ export const WorkbenchPanel =
             <RichTextEditorDialog />
             <SetupShellAccountDialog />
             <SharingDialog />
+            <NotFoundDialog />
             <Snackbar />
             <UpdateCollectionDialog />
             <UpdateProcessDialog />
@@ -236,5 +273,8 @@ export const WorkbenchPanel =
             <UserAttributesDialog />
             <UserManageDialog />
             <VirtualMachineAttributesDialog />
+            <FedLogin />
+            <WebDavS3InfoDialog />
+            {React.createElement(React.Fragment, null, pluginConfig.dialogs)}
         </Grid>
     );