+class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
+ state = {
+ contextMenu: {
+ anchorEl: undefined
+ },
+ isCreationDialogOpen: false,
+ 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())
+ }
+ ]
+ },
+ isDetailsPanelOpened: false
+ };
+
+ mainAppBarActions: MainAppBarActionProps = {
+ onBreadcrumbClick: ({ itemId }: NavBreadcrumb) => {
+ this.props.dispatch<any>(setProjectItem(itemId, ItemMode.BOTH));
+ },
+ onSearch: searchText => {
+ this.setState({ searchText });
+ this.props.dispatch(push(`/search?q=${searchText}`));
+ },
+ onMenuItemClick: (menuItem: NavMenuItem) => menuItem.action(),
+ onDetailsPanelToggle: () => {
+ this.setState(prev => ({ isDetailsPanelOpened: !prev.isDetailsPanelOpened }));
+ }
+ };
+
+ 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));
+ }
+
+ 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: {} });
+ }
+