From 9004a33fe4598b83a8cce315cc28528b3d224a12 Mon Sep 17 00:00:00 2001 From: Michal Klobukowski Date: Tue, 10 Jul 2018 14:34:27 +0200 Subject: [PATCH] Add double click handler Feature #13777 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- src/components/data-explorer/data-explorer.tsx | 2 ++ src/components/data-table/data-table.tsx | 4 +++- src/views-components/data-explorer/data-explorer.tsx | 5 ++++- src/views/project-panel/project-panel.tsx | 2 ++ src/views/workbench/workbench.tsx | 4 +++- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/data-explorer/data-explorer.tsx b/src/components/data-explorer/data-explorer.tsx index 09a32726..9b099acb 100644 --- a/src/components/data-explorer/data-explorer.tsx +++ b/src/components/data-explorer/data-explorer.tsx @@ -24,6 +24,7 @@ interface DataExplorerProps { page: number; onSearch: (value: string) => void; onRowClick: (item: T) => void; + onRowDoubleClick: (item: T) => void; onColumnToggle: (column: DataColumn) => void; onContextAction: (action: ContextMenuAction, item: T) => void; onSortToggle: (column: DataColumn) => void; @@ -67,6 +68,7 @@ class DataExplorer extends React.Component this.props.onRowClick(item)} + onRowDoubleClick={(_, item: T) => this.props.onRowDoubleClick(item)} onRowContextMenu={this.openContextMenu} onFiltersChange={this.props.onFiltersChange} onSortToggle={this.props.onSortToggle} /> diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx index 5372128f..c657e116 100644 --- a/src/components/data-table/data-table.tsx +++ b/src/components/data-table/data-table.tsx @@ -15,6 +15,7 @@ export interface DataTableProps { items: T[]; columns: DataColumns; onRowClick: (event: React.MouseEvent, item: T) => void; + onRowDoubleClick: (event: React.MouseEvent, item: T) => void; onRowContextMenu: (event: React.MouseEvent, item: T) => void; onSortToggle: (column: DataColumn) => void; onFiltersChange: (filters: DataTableFilterItem[], column: DataColumn) => void; @@ -68,11 +69,12 @@ class DataTable extends React.Component & } renderBodyRow = (item: T, index: number) => { - const { onRowClick, onRowContextMenu } = this.props; + const { onRowClick, onRowDoubleClick, onRowContextMenu } = this.props; return onRowClick && onRowClick(event, item)} + onDoubleClick={event => onRowDoubleClick && onRowDoubleClick(event, item) } onContextMenu={event => onRowContextMenu && onRowContextMenu(event, item)}> {this.mapVisibleColumns((column, index) => ( diff --git a/src/views-components/data-explorer/data-explorer.tsx b/src/views-components/data-explorer/data-explorer.tsx index f89bc65e..5ff8c66b 100644 --- a/src/views-components/data-explorer/data-explorer.tsx +++ b/src/views-components/data-explorer/data-explorer.tsx @@ -16,13 +16,14 @@ interface Props { id: string; contextActions: ContextMenuActionGroup[]; onRowClick: (item: any) => void; + onRowDoubleClick: (item: any) => void; onContextAction: (action: ContextMenuAction, item: any) => void; } const mapStateToProps = (state: RootState, { id, contextActions }: Props) => getDataExplorer(state.dataExplorer, id); -const mapDispatchToProps = (dispatch: Dispatch, { id, contextActions, onRowClick, onContextAction }: Props) => ({ +const mapDispatchToProps = (dispatch: Dispatch, { id, contextActions, onRowClick, onRowDoubleClick, onContextAction }: Props) => ({ onSearch: (searchValue: string) => { dispatch(actions.SET_SEARCH_VALUE({ id, searchValue })); }, @@ -51,6 +52,8 @@ const mapDispatchToProps = (dispatch: Dispatch, { id, contextActions, onRowClick onRowClick, + onRowDoubleClick, + onContextAction }); diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx index c1d66603..0708b163 100644 --- a/src/views/project-panel/project-panel.tsx +++ b/src/views/project-panel/project-panel.tsx @@ -26,6 +26,7 @@ export interface ProjectPanelFilter extends DataTableFilterItem { type ProjectPanelProps = { currentItemId: string, onItemClick: (item: ProjectPanelItem) => void, + onItemDoubleClick: (item: ProjectPanelItem) => void, onItemRouteChange: (itemId: string) => void } & DispatchProp @@ -49,6 +50,7 @@ class ProjectPanel extends React.Component { id={PROJECT_PANEL_ID} contextActions={contextMenuActions} onRowClick={this.props.onItemClick} + onRowDoubleClick={this.props.onItemDoubleClick} onContextAction={this.executeAction} />; ; } diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 11f36948..fac96268 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -209,9 +209,11 @@ class Workbench extends React.Component { renderProjectPanel = (props: RouteComponentProps<{ id: string }>) => this.props.dispatch(setProjectItem(itemId, ItemMode.ACTIVE))} onItemClick={item => { - this.props.dispatch(setProjectItem(item.uuid, ItemMode.ACTIVE)); this.props.dispatch(loadDetails(item.uuid, item.kind as ResourceKind)); }} + onItemDoubleClick={item => { + this.props.dispatch(setProjectItem(item.uuid, ItemMode.ACTIVE)); + }} {...props} /> } -- 2.30.2