1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
7 import { connect, DispatchProp } from "react-redux";
8 import { Route, Switch } from "react-router";
9 import { User } from "~/models/user";
10 import { RootState } from "~/store/store";
11 import { MainAppBar } from '~/views-components/main-app-bar/main-app-bar';
12 import { push } from 'react-router-redux';
13 import { ProjectPanel } from "~/views/project-panel/project-panel";
14 import { DetailsPanel } from '~/views-components/details-panel/details-panel';
15 import { ArvadosTheme } from '~/common/custom-theme';
16 import { detailsPanelActions } from "~/store/details-panel/details-panel-action";
17 import { ContextMenu } from "~/views-components/context-menu/context-menu";
18 import { FavoritePanel } from "../favorite-panel/favorite-panel";
19 import { CurrentTokenDialog } from '~/views-components/current-token-dialog/current-token-dialog';
20 import { Snackbar } from '~/views-components/snackbar/snackbar';
21 import { CollectionPanel } from '../collection-panel/collection-panel';
22 import { AuthService } from "~/services/auth-service/auth-service";
23 import { RenameFileDialog } from '~/views-components/rename-file-dialog/rename-file-dialog';
24 import { FileRemoveDialog } from '~/views-components/file-remove-dialog/file-remove-dialog';
25 import { MultipleFilesRemoveDialog } from '~/views-components/file-remove-dialog/multiple-files-remove-dialog';
26 import { Routes } from '~/routes/routes';
27 import { SidePanel } from '~/views-components/side-panel/side-panel';
28 import { ProcessPanel } from '~/views/process-panel/process-panel';
29 import { ProcessLogPanel } from '~/views/process-log-panel/process-log-panel';
30 import { CreateProjectDialog } from '~/views-components/dialog-forms/create-project-dialog';
31 import { CreateCollectionDialog } from '~/views-components/dialog-forms/create-collection-dialog';
32 import { CopyCollectionDialog } from '~/views-components/dialog-forms/copy-collection-dialog';
33 import { UpdateCollectionDialog } from '~/views-components/dialog-forms/update-collection-dialog';
34 import { UpdateProjectDialog } from '~/views-components/dialog-forms/update-project-dialog';
35 import { MoveProjectDialog } from '~/views-components/dialog-forms/move-project-dialog';
36 import { MoveCollectionDialog } from '~/views-components/dialog-forms/move-collection-dialog';
37 import { FilesUploadCollectionDialog } from '~/views-components/dialog-forms/files-upload-collection-dialog';
38 import { PartialCopyCollectionDialog } from '~/views-components/dialog-forms/partial-copy-collection-dialog';
40 import { TrashPanel } from "~/views/trash-panel/trash-panel";
41 import { MainContentBar } from '../../views-components/main-content-bar/main-content-bar';
42 import { Grid } from '@material-ui/core';
44 type CssRules = 'root' | 'contentWrapper' | 'content' | 'appBar';
46 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
53 background: theme.palette.background.default,
59 paddingLeft: theme.spacing.unit * 3,
60 paddingRight: theme.spacing.unit * 3,
67 interface WorkbenchDataProps {
69 currentToken?: string;
72 interface WorkbenchGeneralProps {
73 authService: AuthService;
77 type WorkbenchProps = WorkbenchDataProps & WorkbenchGeneralProps & DispatchProp<any> & WithStyles<CssRules>;
79 interface WorkbenchState {
80 isCurrentTokenDialogOpen: boolean;
85 export const Workbench = withStyles(styles)(
86 connect<WorkbenchDataProps>(
87 (state: RootState) => ({
88 user: state.auth.user,
89 currentToken: state.auth.apiToken,
92 class extends React.Component<WorkbenchProps, WorkbenchState> {
94 isCurrentTokenDialogOpen: false,
104 className={this.props.classes.root}>
105 <Grid className={this.props.classes.appBar}>
107 searchText={this.state.searchText}
108 user={this.props.user}
109 onSearch={this.onSearch} />
127 className={this.props.classes.contentWrapper}>
131 <Grid xs className={this.props.classes.content}>
133 <Route path={Routes.PROJECTS} component={ProjectPanel} />
134 <Route path={Routes.COLLECTIONS} component={CollectionPanel} />
135 <Route path={Routes.FAVORITES} component={FavoritePanel} />
136 <Route path={Routes.PROCESSES} component={ProcessPanel} />
137 <Route path={Routes.TRASH} component={TrashPanel} />
138 <Route path={Routes.PROCESS_LOGS} component={ProcessLogPanel} />
149 <CreateProjectDialog />
150 <CreateCollectionDialog />
152 <PartialCopyCollectionDialog />
154 <CopyCollectionDialog />
156 <MultipleFilesRemoveDialog />
157 <UpdateCollectionDialog />
158 <FilesUploadCollectionDialog />
159 <UpdateProjectDialog />
160 <MoveCollectionDialog />
161 <MoveProjectDialog />
163 currentToken={this.props.currentToken}
164 open={this.state.isCurrentTokenDialogOpen}
165 handleClose={this.toggleCurrentTokenModal} />
169 onSearch = (searchText: string) => {
170 this.setState({ searchText });
171 this.props.dispatch(push(`/search?q=${searchText}`));
174 toggleDetailsPanel = () => {
175 this.props.dispatch(detailsPanelActions.TOGGLE_DETAILS_PANEL());
178 toggleCurrentTokenModal = () => {
179 this.setState({ isCurrentTokenDialogOpen: !this.state.isCurrentTokenDialogOpen });