X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/83ca43a7dccc99e1036992a7a968b0c8bd1bc9f1..cba0f400f56889778321bdc0fdcf6cee236f6a79:/src/views/workbench/workbench.tsx

diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index f1f00885..ef5fe215 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -3,31 +3,47 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-
-import { StyleRulesCallback, Theme, WithStyles, withStyles } from '@material-ui/core/styles';
-import Drawer from '@material-ui/core/Drawer';
+import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
 import { connect, DispatchProp } from "react-redux";
 import { Route, Switch } from "react-router";
-import authActions from "../../store/auth/auth-action";
-import { User } from "../../models/user";
-import { RootState } from "../../store/store";
-import MainAppBar, { MainAppBarActionProps, MainAppBarMenuItem } from '../../components/main-app-bar/main-app-bar';
-import { Breadcrumb } from '../../components/breadcrumbs/breadcrumbs';
+import { login, logout } from "~/store/auth/auth-action";
+import { User } from "~/models/user";
+import { RootState } from "~/store/store";
+import { MainAppBar, MainAppBarActionProps, MainAppBarMenuItem } from '~/views-components/main-app-bar/main-app-bar';
 import { push } from 'react-router-redux';
-import projectActions from "../../store/project/project-action";
-import ProjectTree from '../../components/project-tree/project-tree';
-import { TreeItem, TreeItemStatus } from "../../components/tree/tree";
-import { Project } from "../../models/project";
-import { projectService } from '../../services/services';
-import { getTreePath } from '../../store/project/project-reducer';
-import DataExplorer from '../data-explorer/data-explorer';
-
-const drawerWidth = 240;
-const appBarHeight = 102;
-
-type CssRules = 'root' | 'appBar' | 'drawerPaper' | 'content' | 'contentWrapper' | 'toolbar';
-
-const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
+import { ProjectPanel } from "~/views/project-panel/project-panel";
+import { DetailsPanel } from '~/views-components/details-panel/details-panel';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { detailsPanelActions } from "~/store/details-panel/details-panel-action";
+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 { Snackbar } from '~/views-components/snackbar/snackbar';
+import { CollectionPanel } from '../collection-panel/collection-panel';
+import { AuthService } from "~/services/auth-service/auth-service";
+import { RenameFileDialog } from '~/views-components/rename-file-dialog/rename-file-dialog';
+import { FileRemoveDialog } from '~/views-components/file-remove-dialog/file-remove-dialog';
+import { MultipleFilesRemoveDialog } from '~/views-components/file-remove-dialog/multiple-files-remove-dialog';
+import { Routes } from '~/routes/routes';
+import { SidePanel } from '~/views-components/side-panel/side-panel';
+import { ProcessPanel } from '~/views/process-panel/process-panel';
+import { Breadcrumbs } from '~/views-components/breadcrumbs/breadcrumbs';
+import { CreateProjectDialog } from '~/views-components/dialog-forms/create-project-dialog';
+import { CreateCollectionDialog } from '~/views-components/dialog-forms/create-collection-dialog';
+import { CopyCollectionDialog } from '~/views-components/dialog-forms/copy-collection-dialog';
+import { UpdateCollectionDialog } from '~/views-components/dialog-forms/update-collection-dialog';
+import { UpdateProjectDialog } from '~/views-components/dialog-forms/update-project-dialog';
+import { MoveProjectDialog } from '~/views-components/dialog-forms/move-project-dialog';
+import { MoveCollectionDialog } from '~/views-components/dialog-forms/move-collection-dialog';
+
+import { FilesUploadCollectionDialog } from '~/views-components/dialog-forms/files-upload-collection-dialog';
+import { PartialCopyCollectionDialog } from '~/views-components/dialog-forms/partial-copy-collection-dialog';
+
+const APP_BAR_HEIGHT = 100;
+
+type CssRules = 'root' | 'appBar' | 'content' | 'contentWrapper';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     root: {
         flexGrow: 1,
         zIndex: 1,
@@ -39,51 +55,46 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
     },
     appBar: {
         zIndex: theme.zIndex.drawer + 1,
-        backgroundColor: '#692498',
         position: "absolute",
         width: "100%"
     },
-    drawerPaper: {
-        position: 'relative',
-        width: drawerWidth,
-    },
     contentWrapper: {
         backgroundColor: theme.palette.background.default,
         display: "flex",
         flexGrow: 1,
         minWidth: 0,
-        paddingTop: appBarHeight
+        paddingTop: APP_BAR_HEIGHT
     },
     content: {
-        padding: theme.spacing.unit * 3,
+        padding: `${theme.spacing.unit}px ${theme.spacing.unit * 3}px`,
         overflowY: "auto",
-        flexGrow: 1
+        flexGrow: 1,
+        position: 'relative'
     },
-    toolbar: theme.mixins.toolbar
 });
 
 interface WorkbenchDataProps {
-    projects: Array<TreeItem<Project>>;
     user?: User;
+    currentToken?: string;
 }
 
-interface WorkbenchActionProps {
+interface WorkbenchGeneralProps {
+    authService: AuthService;
+    buildInfo: string;
 }
 
-type WorkbenchProps = WorkbenchDataProps & WorkbenchActionProps & DispatchProp & WithStyles<CssRules>;
-
-interface NavBreadcrumb extends Breadcrumb {
-    itemId: string;
-    status: TreeItemStatus;
+interface WorkbenchActionProps {
 }
 
+type WorkbenchProps = WorkbenchDataProps & WorkbenchGeneralProps & WorkbenchActionProps & DispatchProp<any> & WithStyles<CssRules>;
+
 interface NavMenuItem extends MainAppBarMenuItem {
     action: () => void;
 }
 
 interface WorkbenchState {
+    isCurrentTokenDialogOpen: boolean;
     anchorEl: any;
-    breadcrumbs: NavBreadcrumb[];
     searchText: string;
     menuItems: {
         accountMenu: NavMenuItem[],
@@ -92,111 +103,111 @@ interface WorkbenchState {
     };
 }
 
-class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
-    state = {
-        anchorEl: null,
-        searchText: "",
-        breadcrumbs: [],
-        menuItems: {
-            accountMenu: [
-                {
-                    label: "Logout",
-                    action: () => this.props.dispatch(authActions.LOGOUT())
-                },
-                {
-                    label: "My account",
-                    action: () => this.props.dispatch(push("/my-account"))
-                }
-            ],
-            helpMenu: [
-                {
-                    label: "Help",
-                    action: () => this.props.dispatch(push("/help"))
+export const Workbench = withStyles(styles)(
+    connect<WorkbenchDataProps>(
+        (state: RootState) => ({
+            user: state.auth.user,
+            currentToken: state.auth.apiToken,
+        })
+    )(
+        class extends React.Component<WorkbenchProps, WorkbenchState> {
+            state = {
+                isCurrentTokenDialogOpen: false,
+                anchorEl: null,
+                searchText: "",
+                breadcrumbs: [],
+                menuItems: {
+                    accountMenu: [
+                        {
+                            label: 'Current token',
+                            action: () => this.toggleCurrentTokenModal()
+                        },
+                        {
+                            label: "Logout",
+                            action: () => this.props.dispatch(logout())
+                        },
+                        {
+                            label: "My account",
+                            action: () => this.props.dispatch(push("/my-account"))
+                        }
+                    ],
+                    helpMenu: [
+                        {
+                            label: "Help",
+                            action: () => this.props.dispatch(push("/help"))
+                        }
+                    ],
+                    anonymousMenu: [
+                        {
+                            label: "Sign in",
+                            action: () => this.props.dispatch(login())
+                        }
+                    ]
                 }
-            ],
-            anonymousMenu: [
-                {
-                    label: "Sign in",
-                    action: () => this.props.dispatch(authActions.LOGIN())
-                }
-            ]
-        }
-    };
-
+            };
+
+            render() {
+                const { classes, user } = this.props;
+                return (
+                    <div className={classes.root}>
+                        <div className={classes.appBar}>
+                            <MainAppBar
+                                breadcrumbs={Breadcrumbs}
+                                searchText={this.state.searchText}
+                                user={this.props.user}
+                                menuItems={this.state.menuItems}
+                                buildInfo={this.props.buildInfo}
+                                {...this.mainAppBarActions} />
+                        </div>
+                        {user && <SidePanel />}
+                        <main className={classes.contentWrapper}>
+                            <div className={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} />
+                                </Switch>
+                            </div>
+                            {user && <DetailsPanel />}
+                        </main>
+                        <ContextMenu />
+                        <Snackbar />
+                        <CreateProjectDialog />
+                        <CreateCollectionDialog />
+                        <RenameFileDialog />
+                        <PartialCopyCollectionDialog />
+                        <FileRemoveDialog />
+                        <CopyCollectionDialog />
+                        <FileRemoveDialog />
+                        <MultipleFilesRemoveDialog />
+                        <UpdateCollectionDialog />
+                        <FilesUploadCollectionDialog />
+                        <UpdateProjectDialog />
+                        <MoveCollectionDialog />
+                        <MoveProjectDialog />
+                        <CurrentTokenDialog
+                            currentToken={this.props.currentToken}
+                            open={this.state.isCurrentTokenDialogOpen}
+                            handleClose={this.toggleCurrentTokenModal} />
+                    </div>
+                );
+            }
 
-    mainAppBarActions: MainAppBarActionProps = {
-        onBreadcrumbClick: ({ itemId, status }: NavBreadcrumb) => {
-            this.toggleProjectTreeItem(itemId, status);
-        },
-        onSearch: searchText => {
-            this.setState({ searchText });
-            this.props.dispatch(push(`/search?q=${searchText}`));
-        },
-        onMenuItemClick: (menuItem: NavMenuItem) => menuItem.action()
-    };
+            mainAppBarActions: MainAppBarActionProps = {
+                onSearch: searchText => {
+                    this.setState({ searchText });
+                    this.props.dispatch(push(`/search?q=${searchText}`));
+                },
+                onMenuItemClick: (menuItem: NavMenuItem) => menuItem.action(),
+                onDetailsPanelToggle: () => {
+                    this.props.dispatch(detailsPanelActions.TOGGLE_DETAILS_PANEL());
+                },
+            };
 
-    toggleProjectTreeItem = (itemId: string, status: TreeItemStatus) => {
-        if (status === TreeItemStatus.Loaded) {
-            this.openProjectItem(itemId);
-        } else {
-            this.props.dispatch<any>(projectService.getProjectList(itemId)).then(() => this.openProjectItem(itemId));
+            toggleCurrentTokenModal = () => {
+                this.setState({ isCurrentTokenDialogOpen: !this.state.isCurrentTokenDialogOpen });
+            }
         }
-    }
-
-    openProjectItem = (itemId: string) => {
-        const branch = getTreePath(this.props.projects, itemId);
-        this.setState({
-            breadcrumbs: branch.map(item => ({
-                label: item.data.name,
-                itemId: item.data.uuid,
-                status: item.status
-            }))
-        });
-        this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM(itemId));
-        this.props.dispatch(push(`/project/${itemId}`));
-    }
-
-    render() {
-        const { classes, user } = this.props;
-        return (
-            <div className={classes.root}>
-                <div className={classes.appBar}>
-                    <MainAppBar
-                        breadcrumbs={this.state.breadcrumbs}
-                        searchText={this.state.searchText}
-                        user={this.props.user}
-                        menuItems={this.state.menuItems}
-                        {...this.mainAppBarActions}
-                    />
-                </div>
-                {user &&
-                    <Drawer
-                        variant="permanent"
-                        classes={{
-                            paper: classes.drawerPaper,
-                        }}>
-                        <div className={classes.toolbar} />
-                        <ProjectTree
-                            projects={this.props.projects}
-                            toggleProjectTreeItem={this.toggleProjectTreeItem} />
-                    </Drawer>}
-                <main className={classes.contentWrapper}>
-                    <div className={classes.content}>
-                        <Switch>
-                            <Route path="/project/:name" component={DataExplorer} />
-                        </Switch>
-                    </div>
-                </main>
-            </div>
-        );
-    }
-}
-
-export default connect<WorkbenchDataProps>(
-    (state: RootState) => ({
-        projects: state.projects,
-        user: state.auth.user
-    })
-)(
-    withStyles(styles)(Workbench)
+    )
 );
