21128: fixed unwanted rowselects on other operational clicks Arvados-DCO-1.1-Signed...
[arvados.git] / src / views / search-results-panel / search-results-panel.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Dispatch } from "redux";
6 import { connect } from "react-redux";
7 import { navigateTo } from 'store/navigation/navigation-action';
8 import { openSearchResultsContextMenu } from 'store/context-menu/context-menu-actions';
9 import { loadDetailsPanel } from 'store/details-panel/details-panel-action';
10 import { SearchResultsPanelView } from 'views/search-results-panel/search-results-panel-view';
11 import { RootState } from 'store/store';
12 import { SearchBarAdvancedFormData } from 'models/search-bar';
13 import { User } from "models/user";
14 import { Config } from 'common/config';
15 import { Session } from "models/session";
16 import { toggleOne } from "store/multiselect/multiselect-actions";
17
18 export interface SearchResultsPanelDataProps {
19     data: SearchBarAdvancedFormData;
20     user: User;
21     sessions: Session[];
22     remoteHostsConfig: { [key: string]: Config };
23     localCluster: string;
24 }
25
26 export interface SearchResultsPanelActionProps {
27     onItemClick: (item: string) => void;
28     onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string) => void;
29     onDialogOpen: (ownerUuid: string) => void;
30     onItemDoubleClick: (item: string) => void;
31 }
32
33 export type SearchResultsPanelProps = SearchResultsPanelDataProps & SearchResultsPanelActionProps;
34
35 const mapStateToProps = (rootState: RootState) => {
36     return {
37         user: rootState.auth.user,
38         sessions: rootState.auth.sessions,
39         remoteHostsConfig: rootState.auth.remoteHostsConfig,
40         localCluster: rootState.auth.localCluster,
41     };
42 };
43
44 const mapDispatchToProps = (dispatch: Dispatch): SearchResultsPanelActionProps => ({
45     onContextMenu: (event, resourceUuid) => {
46         dispatch<any>(openSearchResultsContextMenu(event, resourceUuid));
47     },
48     onDialogOpen: (ownerUuid: string) => { return; },
49     onItemClick: (resourceUuid: string) => {
50         dispatch<any>(toggleOne(resourceUuid))
51         dispatch<any>(loadDetailsPanel(resourceUuid));
52     },
53     onItemDoubleClick: uuid => {
54         dispatch<any>(navigateTo(uuid));
55     }
56 });
57
58 export const SearchResultsPanel = connect(mapStateToProps, mapDispatchToProps)(SearchResultsPanelView);