}
};
-export const setProjectItem = (projects: Array<TreeItem<Project>>, itemId: string, itemKind: ResourceKind) => (dispatch: Dispatch) => {
+export enum ItemMode {
+ BOTH,
+ OPEN,
+ ACTIVE
+}
+
+export const setProjectItem = (projects: Array<TreeItem<Project>>, itemId: string, itemKind: ResourceKind, itemMode: ItemMode) => (dispatch: Dispatch) => {
const openProjectItem = (resource: Resource) => {
- dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_OPEN(resource.uuid));
- dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(resource.uuid));
- dispatch(sidePanelActions.RESET_SIDE_PANEL_ACTIVITY(resource.uuid));
+ if (itemMode === ItemMode.OPEN || itemMode === ItemMode.BOTH) {
+ dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_OPEN(resource.uuid));
+ }
+
+ if (itemMode === ItemMode.ACTIVE || itemMode === ItemMode.BOTH) {
+ dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(resource.uuid));
+ dispatch(sidePanelActions.RESET_SIDE_PANEL_ACTIVITY(resource.uuid));
+ }
+
dispatch(push(getResourceUrl({...resource, kind: itemKind})));
};
const treeItem = findTreeItem(projects, itemId);
dispatch<any>(getProjectList(itemId))
.then(() => openProjectItem(treeItem.data));
}
- dispatch<any>(getCollectionList(itemId));
-
- // if (item.type === ResourceKind.PROJECT || item.type === ResourceKind.LEVEL_UP) {
- // this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM(item.uuid));
- // }
- // this.props.dispatch<any>(getCollectionList(item.uuid));
-
+ if (itemMode === ItemMode.ACTIVE || itemMode === ItemMode.BOTH) {
+ dispatch<any>(getCollectionList(itemId));
+ }
}
};
-
- // toggleProjectTreeItemActive = (itemId: string, status: TreeItemStatus) => {
- // if (status === TreeItemStatus.Loaded) {
- // this.openProjectItem(itemId);
- // this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(itemId));
- // this.props.dispatch(sidePanelActions.RESET_SIDE_PANEL_ACTIVITY(itemId));
- // } else {
- // this.props.dispatch<any>(getProjectList(itemId))
- // .then(() => {
- // this.openProjectItem(itemId);
- // this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(itemId));
- // this.props.dispatch(sidePanelActions.RESET_SIDE_PANEL_ACTIVITY(itemId));
- // });
- // }
- // }
import { RootState } from '../../store/store';
import { connect, DispatchProp } from 'react-redux';
import { CollectionState } from "../../store/collection/collection-reducer";
-import { setProjectItem } from "../../store/navigation/navigation-action";
+import { ItemMode, setProjectItem } from "../../store/navigation/navigation-action";
import ProjectExplorer, { ProjectExplorerContextActions } from "../../views-components/project-explorer/project-explorer";
import { projectExplorerItems } from "./project-panel-selectors";
import { ProjectExplorerItem } from "../../views-components/project-explorer/project-explorer-item";
}
goToItem = (item: ProjectExplorerItem) => {
- this.props.dispatch<any>(setProjectItem(this.props.projects.items, item.uuid, item.kind));
+ this.props.dispatch<any>(setProjectItem(this.props.projects.items, item.uuid, item.kind, ItemMode.BOTH));
}
}
import sidePanelActions from '../../store/side-panel/side-panel-action';
import SidePanel, { SidePanelItem } from '../../components/side-panel/side-panel';
import { ResourceKind } from "../../models/resource";
-import { setProjectItem } from "../../store/navigation/navigation-action";
+import { ItemMode, setProjectItem } from "../../store/navigation/navigation-action";
const drawerWidth = 240;
const appBarHeight = 102;
projects={this.props.projects}
toggleOpen={itemId =>
this.props.dispatch<any>(
- setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT)
+ setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT, ItemMode.OPEN)
)}
toggleActive={itemId =>
this.props.dispatch<any>(
- setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT)
+ setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT, ItemMode.ACTIVE)
)}
/>
</SidePanel>
<main className={classes.contentWrapper}>
<div className={classes.content}>
<Switch>
- <Route path="/project/:name" component={ProjectPanel} />
+ <Route path="/projects/:name" component={ProjectPanel} />
</Switch>
</div>
</main>
);
}
}
-/*
- <ProjectTree
- projects={this.props.projects}
- toggleProjectTreeItem={itemId =>
- this.props.dispatch<any>(
- setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT)
- )}/>
-*/
export default connect<WorkbenchDataProps>(
(state: RootState) => ({