1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { connect } from "react-redux";
6 import { RootState } from "../../store/store";
7 import { DataExplorer as DataExplorerComponent } from "../../components/data-explorer/data-explorer";
8 import { getDataExplorer } from "../../store/data-explorer/data-explorer-reducer";
9 import { Dispatch } from "redux";
10 import { dataExplorerActions } 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";
16 onRowClick: (item: any) => void;
17 onContextMenu: (event: React.MouseEvent<HTMLElement>, item: any) => void;
18 onRowDoubleClick: (item: any) => void;
19 extractKey?: (item: any) => React.Key;
22 const mapStateToProps = (state: RootState, { id }: Props) =>
23 getDataExplorer(state.dataExplorer, id);
25 const mapDispatchToProps = (dispatch: Dispatch, { id, onRowClick, onRowDoubleClick, onContextMenu }: Props) => ({
26 onSearch: (searchValue: string) => {
27 dispatch(dataExplorerActions.SET_SEARCH_VALUE({ id, searchValue }));
30 onColumnToggle: (column: DataColumn<any>) => {
31 dispatch(dataExplorerActions.TOGGLE_COLUMN({ id, columnName: column.name }));
34 onSortToggle: (column: DataColumn<any>) => {
35 dispatch(dataExplorerActions.TOGGLE_SORT({ id, columnName: column.name }));
38 onFiltersChange: (filters: DataTableFilterItem[], column: DataColumn<any>) => {
39 dispatch(dataExplorerActions.SET_FILTERS({ id, columnName: column.name, filters }));
42 onChangePage: (page: number) => {
43 dispatch(dataExplorerActions.SET_PAGE({ id, page }));
46 onChangeRowsPerPage: (rowsPerPage: number) => {
47 dispatch(dataExplorerActions.SET_ROWS_PER_PAGE({ id, rowsPerPage }));
57 export const DataExplorer = connect(mapStateToProps, mapDispatchToProps)(DataExplorerComponent);