refs #14348 Merge branch 'origin/14348-cluster-search'
[arvados-workbench2.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 { SearchResultsPanelActionProps } from './search-results-panel-view';
9 import { openContextMenu, resourceKindToContextMenuKind } from '~/store/context-menu/context-menu-actions';
10 import { ResourceKind } from '~/models/resource';
11 import { loadDetailsPanel } from '~/store/details-panel/details-panel-action';
12 import { SearchResultsPanelView } from '~/views/search-results-panel/search-results-panel-view';
13
14 const mapDispatchToProps = (dispatch: Dispatch): SearchResultsPanelActionProps => ({
15     onContextMenu: (event, resourceUuid) => {
16         const kind = resourceKindToContextMenuKind(resourceUuid);
17         if (kind) {
18             dispatch<any>(openContextMenu(event, {
19                 name: '',
20                 uuid: resourceUuid,
21                 ownerUuid: '',
22                 kind: ResourceKind.NONE,
23                 menuKind: kind
24             }));
25         }
26         dispatch<any>(loadDetailsPanel(resourceUuid));
27     },
28     onDialogOpen: (ownerUuid: string) => { return; },
29     onItemClick: (resourceUuid: string) => {
30         dispatch<any>(loadDetailsPanel(resourceUuid));
31     },
32     onItemDoubleClick: uuid => {
33         dispatch<any>(navigateTo(uuid));
34     }
35 });
36
37 export const SearchResultsPanel = connect(null, mapDispatchToProps)(SearchResultsPanelView);