17532: Remove unused code in renderers
[arvados.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 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 { DataColumns } from "components/data-table/data-table";
13 import { DataTableFilters } from 'components/data-table-filters/data-table-filters-tree';
14
15 interface Props {
16     id: string;
17     onRowClick: (item: any) => void;
18     onContextMenu?: (event: React.MouseEvent<HTMLElement>, item: any, isAdmin?: boolean) => void;
19     onRowDoubleClick: (item: any) => void;
20     extractKey?: (item: any) => React.Key;
21 }
22
23 const mapStateToProps = (state: RootState, { id }: Props) => {
24     const progress = state.progressIndicator.find(p => p.id === id);
25     const working = progress && progress.working;
26     const currentRoute = state.router.location ? state.router.location.pathname : '';
27     const currentItemUuid = currentRoute === '/workflows' ? state.properties.workflowPanelDetailsUuid : state.detailsPanel.resourceUuid;
28     return { ...getDataExplorer(state.dataExplorer, id), working, paperKey: currentRoute, currentItemUuid };
29 };
30
31 const mapDispatchToProps = () => {
32     return (dispatch: Dispatch, { id, onRowClick, onRowDoubleClick, onContextMenu }: Props) => ({
33         onSetColumns: (columns: DataColumns<any>) => {
34             dispatch(dataExplorerActions.SET_COLUMNS({ id, columns }));
35         },
36
37         onSearch: (searchValue: string) => {
38             dispatch(dataExplorerActions.SET_EXPLORER_SEARCH_VALUE({ id, searchValue }));
39         },
40
41         onColumnToggle: (column: DataColumn<any>) => {
42             dispatch(dataExplorerActions.TOGGLE_COLUMN({ id, columnName: column.name }));
43         },
44
45         onSortToggle: (column: DataColumn<any>) => {
46             dispatch(dataExplorerActions.TOGGLE_SORT({ id, columnName: column.name }));
47         },
48
49         onFiltersChange: (filters: DataTableFilters, column: DataColumn<any>) => {
50             dispatch(dataExplorerActions.SET_FILTERS({ id, columnName: column.name, filters }));
51         },
52
53         onChangePage: (page: number) => {
54             dispatch(dataExplorerActions.SET_PAGE({ id, page }));
55         },
56
57         onChangeRowsPerPage: (rowsPerPage: number) => {
58             dispatch(dataExplorerActions.SET_ROWS_PER_PAGE({ id, rowsPerPage }));
59         },
60
61         onLoadMore: (page: number) => {
62             dispatch(dataExplorerActions.SET_PAGE({ id, page }));
63         },
64
65         onRowClick,
66
67         onRowDoubleClick,
68
69         onContextMenu,
70     });
71 };
72
73 export const DataExplorer = connect(mapStateToProps, mapDispatchToProps())(DataExplorerComponent);
74