Add double click handler
[arvados-workbench2.git] / src / views-components / data-explorer / data-explorer.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { connect } from "react-redux";
6 import { RootState } from "../../store/store";
7 import DataExplorer from "../../components/data-explorer/data-explorer";
8 import { getDataExplorer } from "../../store/data-explorer/data-explorer-reducer";
9 import { Dispatch } from "redux";
10 import actions from "../../store/data-explorer/data-explorer-action";
11 import { DataColumn } from "../../components/data-table/data-column";
12 import { DataTableFilterItem } from "../../components/data-table-filters/data-table-filters";
13 import { ContextMenuAction, ContextMenuActionGroup } from "../../components/context-menu/context-menu";
14
15 interface Props {
16     id: string;
17     contextActions: ContextMenuActionGroup[];
18     onRowClick: (item: any) => void;
19     onRowDoubleClick: (item: any) => void;
20     onContextAction: (action: ContextMenuAction, item: any) => void;
21 }
22
23 const mapStateToProps = (state: RootState, { id, contextActions }: Props) =>
24     getDataExplorer(state.dataExplorer, id);
25
26 const mapDispatchToProps = (dispatch: Dispatch, { id, contextActions, onRowClick, onRowDoubleClick, onContextAction }: Props) => ({
27     onSearch: (searchValue: string) => {
28         dispatch(actions.SET_SEARCH_VALUE({ id, searchValue }));
29     },
30
31     onColumnToggle: (column: DataColumn<any>) => {
32         dispatch(actions.TOGGLE_COLUMN({ id, columnName: column.name }));
33     },
34
35     onSortToggle: (column: DataColumn<any>) => {
36         dispatch(actions.TOGGLE_SORT({ id, columnName: column.name }));
37     },
38
39     onFiltersChange: (filters: DataTableFilterItem[], column: DataColumn<any>) => {
40         dispatch(actions.SET_FILTERS({ id, columnName: column.name, filters }));
41     },
42
43     onChangePage: (page: number) => {
44         dispatch(actions.SET_PAGE({ id, page }));
45     },
46
47     onChangeRowsPerPage: (rowsPerPage: number) => {
48         dispatch(actions.SET_ROWS_PER_PAGE({ id, rowsPerPage }));
49     },
50
51     contextActions,
52
53     onRowClick,
54
55     onRowDoubleClick,
56
57     onContextAction
58 });
59
60 export default connect(mapStateToProps, mapDispatchToProps)(DataExplorer);
61