// SPDX-License-Identifier: AGPL-3.0
import * as React from 'react';
-import { StyleRulesCallback, Theme, WithStyles, withStyles } from '@material-ui/core/styles';
+import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import { connect, DispatchProp } from "react-redux";
import { Route, Switch, RouteComponentProps, withRouter } from "react-router";
import projectActions from "../../store/project/project-action";
import ProjectPanel from "../project-panel/project-panel";
import { sidePanelData } from '../../store/side-panel/side-panel-reducer';
+import DetailsPanel from '../../views-components/details-panel/details-panel';
+import { ArvadosTheme } from '../../common/custom-theme';
+import ContextMenu from '../../components/context-menu/context-menu';
+import { mockAnchorFromMouseEvent } from '../../components/popover/helpers';
const drawerWidth = 240;
-const appBarHeight = 102;
+const appBarHeight = 100;
type CssRules = 'root' | 'appBar' | 'drawerPaper' | 'content' | 'contentWrapper' | 'toolbar';
-const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
root: {
flexGrow: 1,
zIndex: 1,
},
appBar: {
zIndex: theme.zIndex.drawer + 1,
- backgroundColor: '#692498',
position: "absolute",
width: "100%"
},
paddingTop: appBarHeight
},
content: {
- padding: theme.spacing.unit * 3,
+ padding: `${theme.spacing.unit}px ${theme.spacing.unit * 3}px`,
overflowY: "auto",
flexGrow: 1
},
}
interface WorkbenchState {
+ contextMenu: {
+ anchorEl?: HTMLElement;
+ };
+ isCreationDialogOpen: boolean;
anchorEl: any;
searchText: string;
menuItems: {
helpMenu: NavMenuItem[],
anonymousMenu: NavMenuItem[]
};
+ isDetailsPanelOpened: boolean;
}
class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
state = {
+ contextMenu: {
+ anchorEl: undefined
+ },
+ isCreationDialogOpen: false,
anchorEl: null,
searchText: "",
breadcrumbs: [],
action: () => this.props.dispatch(authActions.LOGIN())
}
]
- }
+ },
+ isDetailsPanelOpened: false
};
mainAppBarActions: MainAppBarActionProps = {
this.setState({ searchText });
this.props.dispatch(push(`/search?q=${searchText}`));
},
- onMenuItemClick: (menuItem: NavMenuItem) => menuItem.action()
+ onMenuItemClick: (menuItem: NavMenuItem) => menuItem.action(),
+ onDetailsPanelToggle: () => {
+ this.setState(prev => ({ isDetailsPanelOpened: !prev.isDetailsPanelOpened }));
+ }
};
toggleSidePanelOpen = (itemId: string) => {
this.props.dispatch(projectActions.RESET_PROJECT_TREE_ACTIVITY(itemId));
}
+ handleCreationDialogOpen = () => {
+ this.setState({ isCreationDialogOpen: true });
+ }
+
+ handleCreationDialogClose = () => {
+ this.setState({ isCreationDialogOpen: false });
+ }
+
+ openContextMenu = (event: React.MouseEvent<HTMLElement>, item: any) => {
+ event.preventDefault();
+ this.setState({ contextMenu: { anchorEl: mockAnchorFromMouseEvent(event) } });
+ console.log(item);
+ }
+
+ closeContextMenu = () => {
+ this.setState({ contextMenu: {} });
+ }
+
render() {
const path = getTreePath(this.props.projects, this.props.currentProjectId);
const breadcrumbs = path.map(item => ({
<SidePanel
toggleOpen={this.toggleSidePanelOpen}
toggleActive={this.toggleSidePanelActive}
- sidePanelItems={this.props.sidePanelItems}>
+ sidePanelItems={this.props.sidePanelItems}
+ handleCreationDialogOpen={this.handleCreationDialogOpen}
+ handleCreationDialogClose={this.handleCreationDialogClose}>
<ProjectTree
projects={this.props.projects}
toggleOpen={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.OPEN))}
toggleActive={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.ACTIVE))}
+ handleCreationDialogOpen={this.handleCreationDialogOpen}
+ handleCreationDialogClose={this.handleCreationDialogClose}
/>
</SidePanel>
</Drawer>}
<Route path="/projects/:id" render={this.renderProjectPanel} />
</Switch>
</div>
+ <DetailsPanel
+ isOpened={this.state.isDetailsPanelOpened}
+ onCloseDrawer={this.mainAppBarActions.onDetailsPanelToggle} />
</main>
+ <ContextMenu
+ anchorEl={this.state.contextMenu.anchorEl}
+ actions={contextMenuActions}
+ onActionClick={console.log}
+ onClose={this.closeContextMenu} />
</div>
);
}
renderProjectPanel = (props: RouteComponentProps<{ id: string }>) => <ProjectPanel
onItemRouteChange={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.ACTIVE))}
onItemClick={item => this.props.dispatch<any>(setProjectItem(item.uuid, ItemMode.ACTIVE))}
+ onContextMenu={this.openContextMenu}
+ handleCreationDialogOpen={this.handleCreationDialogOpen}
+ handleCreationDialogClose={this.handleCreationDialogClose}
+ isCreationDialogOpen={this.state.isCreationDialogOpen}
{...props} />
}
+const contextMenuActions = [[{
+ icon: "fas fa-plus fa-fw",
+ name: "New project"
+}, {
+ icon: "fas fa-users fa-fw",
+ name: "Share"
+}, {
+ icon: "fas fa-sign-out-alt fa-fw",
+ name: "Move to"
+}, {
+ icon: "fas fa-star fa-fw",
+ name: "Add to favourite"
+}, {
+ icon: "fas fa-edit fa-fw",
+ name: "Rename"
+}, {
+ icon: "fas fa-copy fa-fw",
+ name: "Make a copy"
+}, {
+ icon: "fas fa-download fa-fw",
+ name: "Download"
+}], [{
+ icon: "fas fa-trash-alt fa-fw",
+ name: "Remove"
+}
+]];
+
export default connect<WorkbenchDataProps>(
(state: RootState) => ({
projects: state.projects.items,