X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/b0ea85a58cf15903e67c5a7161d7887b03af713e..e2ea20e09a5e5a629eee78145f35a9ed443a5867:/src/views/workbench/workbench.tsx?ds=sidebyside diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 1069de53..1d53842b 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -3,36 +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 '../../views-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 ProjectTree from '../../views-components/project-tree/project-tree'; -import { TreeItem } from "../../components/tree/tree"; -import { Project } from "../../models/project"; -import { getTreePath } from '../../store/project/project-reducer'; -import ProjectPanel from '../project-panel/project-panel'; -import sidePanelActions from '../../store/side-panel/side-panel-action'; -import SidePanel, { SidePanelItem } from '../../components/side-panel/side-panel'; -import { ResourceKind } from "../../models/resource"; -import { ItemMode, setProjectItem } from "../../store/navigation/navigation-action"; -import projectActions from "../../store/project/project-action"; - -const drawerWidth = 240; -const appBarHeight = 102; - -type CssRules = 'root' | 'appBar' | 'drawerPaper' | 'content' | 'contentWrapper' | 'toolbar'; - -const styles: StyleRulesCallback = (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 { SidePanel } from '~/views-components/side-panel/side-panel'; +import { Routes } from '~/routes/routes'; +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 { ProcessPanel } from '~/views/process-panel/process-panel'; +import { UploadCollectionFilesDialog } from '~/views-components/dialog-forms/upload-collection-files-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, @@ -44,52 +55,45 @@ const styles: StyleRulesCallback = (theme: Theme) => ({ }, appBar: { zIndex: theme.zIndex.drawer + 1, - backgroundColor: '#692498', position: "absolute", width: "100%" }, - drawerPaper: { - position: 'relative', - width: drawerWidth, - display: 'flex', - flexDirection: 'column', - }, 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>; - currentProjectId: string; user?: User; - sidePanelItems: SidePanelItem[]; + currentToken?: string; } -interface WorkbenchActionProps { +interface WorkbenchGeneralProps { + authService: AuthService; + buildInfo: string; } -type WorkbenchProps = WorkbenchDataProps & WorkbenchActionProps & DispatchProp & WithStyles; - -interface NavBreadcrumb extends Breadcrumb { - itemId: string; +interface WorkbenchActionProps { } +type WorkbenchProps = WorkbenchDataProps & WorkbenchGeneralProps & WorkbenchActionProps & DispatchProp & WithStyles; + interface NavMenuItem extends MainAppBarMenuItem { action: () => void; } interface WorkbenchState { + isCurrentTokenDialogOpen: boolean; anchorEl: any; searchText: string; menuItems: { @@ -99,122 +103,110 @@ interface WorkbenchState { }; } -class Workbench extends React.Component { - 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")) - } - ], - anonymousMenu: [ - { - label: "Sign in", - action: () => this.props.dispatch(authActions.LOGIN()) +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()) + } + ] } - ] - } - }; - - mainAppBarActions: MainAppBarActionProps = { - onBreadcrumbClick: ({ itemId }: NavBreadcrumb) => { - this.props.dispatch( - setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT, ItemMode.BOTH) - ); - }, - onSearch: searchText => { - this.setState({ searchText }); - this.props.dispatch(push(`/search?q=${searchText}`)); - }, - onMenuItemClick: (menuItem: NavMenuItem) => menuItem.action() - }; - - toggleSidePanelOpen = (itemId: string) => { - this.props.dispatch(sidePanelActions.TOGGLE_SIDE_PANEL_ITEM_OPEN(itemId)); - } - - toggleSidePanelActive = (itemId: string) => { - this.props.dispatch(sidePanelActions.TOGGLE_SIDE_PANEL_ITEM_ACTIVE(itemId)); - this.props.dispatch(projectActions.RESET_PROJECT_TREE_ACTIVITY(itemId)); - } - - render() { - const branch = getTreePath(this.props.projects, this.props.currentProjectId); - const breadcrumbs = branch.map(item => ({ - label: item.data.name, - itemId: item.data.uuid, - status: item.status - })); - - const { classes, user } = this.props; - return ( -
-
- -
- {user && - -
- - - this.props.dispatch( - setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT, ItemMode.OPEN) - )} - toggleActive={itemId => - this.props.dispatch( - setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT, ItemMode.ACTIVE) - )} - /> - - } -
-
- - - + }; + + 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()); + }, + }; -export default connect( - (state: RootState) => ({ - projects: state.projects.items, - currentProjectId: state.projects.currentItemId, - user: state.auth.user, - sidePanelItems: state.sidePanel - }) -)( - withStyles(styles)(Workbench) + toggleCurrentTokenModal = () => { + this.setState({ isCurrentTokenDialogOpen: !this.state.isCurrentTokenDialogOpen }); + } + } + ) );