[ARVADOS-WORKBENCH2] updated: 1.1.4-169-g789dabb
Git user
git at public.curoverse.com
Sat Jun 30 09:13:48 EDT 2018
Summary of changes:
src/views/project-panel/project-panel.tsx | 22 +++++++++++++++++----
src/views/workbench/workbench.tsx | 32 +++++++++++++------------------
2 files changed, 31 insertions(+), 23 deletions(-)
via 789dabb5b8554237e5caa62a41a61f1793e8353e (commit)
from 81db818eb5a3404d0b98e6afbbbccc1ae064fd48 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 789dabb5b8554237e5caa62a41a61f1793e8353e
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Sat Jun 30 15:13:33 2018 +0200
Fix react issue with calling actions in render method, handle opening projects tree on item route change
Feature #13678
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx
index dd61e58..6bfa61e 100644
--- a/src/views/project-panel/project-panel.tsx
+++ b/src/views/project-panel/project-panel.tsx
@@ -12,16 +12,21 @@ import { DataTableFilterItem } from '../../components/data-table-filters/data-ta
import { ContextMenuAction } from '../../components/context-menu/context-menu';
import { DispatchProp, connect } from 'react-redux';
import actions from "../../store/data-explorer/data-explorer-action";
-import { setProjectItem, ItemMode } from "../../store/navigation/navigation-action";
import { DataColumns } from '../../components/data-table/data-table';
import { ResourceKind } from "../../models/resource";
import { RouteComponentProps } from 'react-router';
+import { RootState } from '../../store/store';
export const PROJECT_PANEL_ID = "projectPanel";
-type ProjectPanelProps = { onItemClick: (item: ProjectPanelItem) => void }
+type ProjectPanelProps = {
+ currentItemId: string,
+ onItemClick: (item: ProjectPanelItem) => void,
+ onItemRouteChange: (itemId: string) => void
+}
& DispatchProp
- & WithStyles<CssRules>;
+ & WithStyles<CssRules>
+ & RouteComponentProps<{ id: string }>;
class ProjectPanel extends React.Component<ProjectPanelProps> {
render() {
return <div>
@@ -54,6 +59,12 @@ class ProjectPanel extends React.Component<ProjectPanelProps> {
this.props.dispatch(actions.SET_COLUMNS({ id: PROJECT_PANEL_ID, columns }));
}
+ componentWillReceiveProps({ match, currentItemId }: ProjectPanelProps) {
+ if (match.params.id !== currentItemId) {
+ this.props.onItemRouteChange(match.params.id);
+ }
+ }
+
toggleColumn = (toggledColumn: DataColumn<ProjectPanelItem>) => {
this.props.dispatch(actions.TOGGLE_COLUMN({ id: PROJECT_PANEL_ID, columnName: toggledColumn.name }));
}
@@ -81,6 +92,7 @@ class ProjectPanel extends React.Component<ProjectPanelProps> {
changeRowsPerPage = (rowsPerPage: number) => {
this.props.dispatch(actions.SET_ROWS_PER_PAGE({ id: PROJECT_PANEL_ID, rowsPerPage }));
}
+
}
type CssRules = "toolbar" | "button";
@@ -213,4 +225,6 @@ const contextMenuActions = [[{
}
]];
-export default withStyles(styles)(connect()(ProjectPanel));
+export default withStyles(styles)(
+ connect((state: RootState) => ({ currentItemId: state.projects.currentItemId }))(
+ ProjectPanel));
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index 48cab3c..85ed90c 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -6,7 +6,7 @@ import * as React from 'react';
import { StyleRulesCallback, Theme, WithStyles, withStyles } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import { connect, DispatchProp } from "react-redux";
-import { Route, Switch, RouteComponentProps } from "react-router";
+import { Route, Switch, RouteComponentProps, withRouter } from "react-router";
import authActions from "../../store/auth/auth-action";
import dataExplorerActions from "../../store/data-explorer/data-explorer-action";
import { User } from "../../models/user";
@@ -27,6 +27,7 @@ import { ResourceKind } from "../../models/resource";
import { ItemMode, setProjectItem } from "../../store/navigation/navigation-action";
import projectActions from "../../store/project/project-action";
import ProjectPanel from "../project-panel/project-panel";
+import { sidePanelData } from '../../store/side-panel/side-panel-reducer';
const drawerWidth = 240;
const appBarHeight = 102;
@@ -184,14 +185,8 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
sidePanelItems={this.props.sidePanelItems}>
<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)
- )}
+ toggleOpen={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.OPEN))}
+ toggleActive={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.ACTIVE))}
/>
</SidePanel>
</Drawer>}
@@ -206,16 +201,15 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
);
}
- renderProjectPanel = (props: RouteComponentProps<{ id: string }>) => {
- if (props.match.params.id !== this.props.currentProjectId) {
- this.props.dispatch<any>(
- setProjectItem(props.match.params.id, ItemMode.ACTIVE)
- );
- }
- return <ProjectPanel
- onItemClick={item => this.props.dispatch<any>(
- setProjectItem(item.uuid, ItemMode.ACTIVE)
- )} />;
+ renderProjectPanel = (props: RouteComponentProps<{ id: string }>) => <ProjectPanel
+ onItemRouteChange={this.handleItemRouteChange}
+ onItemClick={item => this.props.dispatch<any>(setProjectItem(item.uuid, ItemMode.ACTIVE))}
+ {...props} />
+
+ handleItemRouteChange = (itemId: string) => {
+ this.props.dispatch<any>(sidePanelActions.RESET_SIDE_PANEL_ACTIVITY());
+ this.props.dispatch<any>(sidePanelActions.TOGGLE_SIDE_PANEL_ITEM_OPEN(sidePanelData[0].id));
+ this.props.dispatch<any>(setProjectItem(itemId, ItemMode.ACTIVE));
}
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list