X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/7f95b6ead934a15e849c7650a08475633a8bfb09..cba0f400f56889778321bdc0fdcf6cee236f6a79:/src/views/workbench/workbench.tsx diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 3767e7b0..ef5fe215 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -3,37 +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 AppBar from '@material-ui/core/AppBar'; -import Toolbar from '@material-ui/core/Toolbar'; -import Typography from '@material-ui/core/Typography'; +import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles'; import { connect, DispatchProp } from "react-redux"; -import ProjectList from "../../components/project-list/project-list"; import { Route, Switch } from "react-router"; -import { Link } from "react-router-dom"; -import Button from "@material-ui/core/Button/Button"; -import authActions from "../../store/auth/auth-action"; -import IconButton from "@material-ui/core/IconButton/IconButton"; -import Menu from "@material-ui/core/Menu/Menu"; -import MenuItem from "@material-ui/core/MenuItem/MenuItem"; -import { AccountCircle } from "@material-ui/icons"; -import { User } from "../../models/user"; -import Grid from "@material-ui/core/Grid/Grid"; -import { RootState } from "../../store/store"; -import projectActions from "../../store/project/project-action" - -import ProjectTree from '../../components/project-tree/project-tree'; -import { TreeItem } from "../../components/tree/tree"; -import { Project } from "../../models/project"; -import { projectService } from '../../services/services'; - -const drawerWidth = 240; - -type CssRules = 'root' | 'appBar' | 'drawerPaper' | 'content' | 'toolbar'; - -const styles: StyleRulesCallback = (theme: Theme) => ({ +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 { 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 = (theme: ArvadosTheme) => ({ root: { flexGrow: 1, zIndex: 1, @@ -45,147 +55,159 @@ const styles: StyleRulesCallback = (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: APP_BAR_HEIGHT }, content: { + padding: `${theme.spacing.unit}px ${theme.spacing.unit * 3}px`, + overflowY: "auto", flexGrow: 1, - backgroundColor: theme.palette.background.default, - padding: theme.spacing.unit * 3, - height: '100%', - minWidth: 0, + position: 'relative' }, - toolbar: theme.mixins.toolbar }); interface WorkbenchDataProps { - projects: Array>; user?: User; + currentToken?: string; } -interface WorkbenchActionProps { +interface WorkbenchGeneralProps { + authService: AuthService; + buildInfo: string; } -type WorkbenchProps = WorkbenchDataProps & WorkbenchActionProps & DispatchProp & WithStyles; - -interface WorkbenchState { - anchorEl: any; +interface WorkbenchActionProps { } -class Workbench extends React.Component { - constructor(props: WorkbenchProps) { - super(props); - this.state = { - anchorEl: null - } - } +type WorkbenchProps = WorkbenchDataProps & WorkbenchGeneralProps & WorkbenchActionProps & DispatchProp & WithStyles; - login = () => { - this.props.dispatch(authActions.LOGIN()); - }; - - logout = () => { - this.handleClose(); - this.props.dispatch(authActions.LOGOUT()); - }; - - handleOpenMenu = (event: React.MouseEvent) => { - this.setState({ - anchorEl: event.currentTarget - }); - }; - - handleClose = () => { - this.setState({ - anchorEl: null - }); - }; +interface NavMenuItem extends MainAppBarMenuItem { + action: () => void; +} - toggleProjectTreeItem = (itemId: string) => { - this.props.projects ? - this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM(itemId)) : ( - this.props.dispatch(projectService.getProjectList(itemId)).then(() => { - this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM(itemId)); - })) +interface WorkbenchState { + isCurrentTokenDialogOpen: boolean; + anchorEl: any; + searchText: string; + menuItems: { + accountMenu: NavMenuItem[], + helpMenu: NavMenuItem[], + anonymousMenu: NavMenuItem[] }; - - render() { - const {classes, user} = this.props; - return ( -
- - - - Arvados
Workbench 2 -
- {user ? - - - - {user.firstName} {user.lastName} - - - - - - - - - Logout - My account - - - : - - } -
-
- {user && - -
- - } -
-
- - - -
-
- ); - } } -export default connect( - (state: RootState) => ({ - projects: state.projects, - user: state.auth.user - }) -)( - withStyles(styles)(Workbench) +export const Workbench = withStyles(styles)( + connect( + (state: RootState) => ({ + user: state.auth.user, + currentToken: state.auth.apiToken, + }) + )( + class extends React.Component { + 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()) + } + ] + } + }; + + render() { + const { classes, user } = this.props; + return ( +
+
+ +
+ {user && } +
+
+ + + + + + +
+ {user && } +
+ + + + + + + + + + + + + + + + +
+ ); + } + + 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()); + }, + }; + + toggleCurrentTokenModal = () => { + this.setState({ isCurrentTokenDialogOpen: !this.state.isCurrentTokenDialogOpen }); + } + } + ) );