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, DataColumns, } from "components/data-table/data-column";
12 import { TCheckedList } from "components/data-table/data-table";
13 import { DataTableFilters } from "components/data-table-filters/data-table-filters";
14 import { toggleMSToolbar, setCheckedListOnStore } from "store/multiselect/multiselect-actions";
15 import { setSelectedResourceUuid, setIsSelectedResourceInDataExplorer } from "store/selected-resource/selected-resource-actions";
16 import { usesDetailsCard } from "components/multiselect-toolbar/MultiselectToolbar";
17 import { loadDetailsPanel } from "store/details-panel/details-panel-action";
21 onRowClick: (item: any) => void;
22 onContextMenu?: (event: React.MouseEvent<HTMLElement>, item: any, isAdmin?: boolean) => void;
23 onRowDoubleClick: (item: any) => void;
24 extractKey?: (item: any) => React.Key;
28 const mapStateToProps = ({ progressIndicator, dataExplorer, router, multiselect, selectedResource, properties, searchBar, detailsPanel}: RootState, { id }: Props) => {
29 const working = progressIndicator.includes(id);
30 const dataExplorerState = getDataExplorer(dataExplorer, id);
31 const currentRoute = router.location ? router.location.pathname : "";
32 const isMSToolbarVisible = multiselect.isVisible;
36 currentRouteUuid: properties.currentRouteUuid,
38 selectedResourceUuid: selectedResource.selectedResourceUuid,
39 isSelectedResourceInDataExplorer: selectedResource.isSelectedResourceInDataExplorer,
40 checkedList: multiselect.checkedList,
42 searchBarValue: searchBar.searchValue,
43 detailsPanelResourceUuid: detailsPanel.resourceUuid,
44 isDetailsPanelOpen: detailsPanel.isOpened,
48 const mapDispatchToProps = () => {
49 return (dispatch: Dispatch, { id, onRowClick, onRowDoubleClick, onContextMenu }: Props) => ({
50 onSetColumns: (columns: DataColumns<any, any>) => {
51 dispatch(dataExplorerActions.SET_COLUMNS({ id, columns }));
54 onSearch: (searchValue: string) => {
55 dispatch(dataExplorerActions.SET_EXPLORER_SEARCH_VALUE({ id, searchValue }));
58 onColumnToggle: (column: DataColumn<any, any>) => {
59 dispatch(dataExplorerActions.TOGGLE_COLUMN({ id, columnName: column.name }));
62 onSortToggle: (column: DataColumn<any, any>) => {
63 dispatch(dataExplorerActions.TOGGLE_SORT({ id, columnName: column.name }));
66 onFiltersChange: (filters: DataTableFilters, column: DataColumn<any, any>) => {
67 dispatch(dataExplorerActions.SET_FILTERS({ id, columnName: column.name, filters }));
70 onPageChange: (page: number) => {
71 dispatch(dataExplorerActions.SET_PAGE({ id, page }));
74 onChangeRowsPerPage: (rowsPerPage: number) => {
75 dispatch(dataExplorerActions.SET_ROWS_PER_PAGE({ id, rowsPerPage }));
78 onLoadMore: (page: number) => {
79 dispatch(dataExplorerActions.SET_PAGE({ id, page }));
82 toggleMSToolbar: (isVisible: boolean) => {
83 dispatch<any>(toggleMSToolbar(isVisible));
86 setCheckedListOnStore: (checkedList: TCheckedList) => {
87 dispatch<any>(setCheckedListOnStore(checkedList));
90 setSelectedUuid: (uuid: string | null) => {
91 dispatch<any>(setSelectedResourceUuid(uuid));
94 loadDetailsPanel: (uuid: string) => {
95 dispatch<any>(loadDetailsPanel(uuid || ''));
98 setIsSelectedResourceInDataExplorer: (isIn: boolean) => {
99 dispatch<any>(setIsSelectedResourceInDataExplorer(isIn));
112 export const DataExplorer = connect(mapStateToProps, mapDispatchToProps)(DataExplorerComponent);