19311: changed search component to a functional style
[arvados.git] / src / views / link-panel / link-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 { RootState } from 'store/store';
8 import {
9     openContextMenu,
10     resourceUuidToContextMenuKind
11 } from 'store/context-menu/context-menu-actions';
12 import {
13     LinkPanelRoot,
14     LinkPanelRootActionProps,
15     LinkPanelRootDataProps
16 } from 'views/link-panel/link-panel-root';
17 import { ResourceKind } from 'models/resource';
18
19 const mapStateToProps = (state: RootState): LinkPanelRootDataProps => {
20     return {
21         resources: state.resources
22     };
23 };
24
25 const mapDispatchToProps = (dispatch: Dispatch): LinkPanelRootActionProps => ({
26     onContextMenu: (event, resourceUuid) => {
27         const kind = dispatch<any>(resourceUuidToContextMenuKind(resourceUuid));
28         if (kind) {
29             dispatch<any>(openContextMenu(event, {
30                 name: '',
31                 uuid: resourceUuid,
32                 ownerUuid: '',
33                 kind: ResourceKind.LINK,
34                 menuKind: kind
35             }));
36         }
37     },
38     onItemClick: (resourceUuid: string) => { return; },
39     onItemDoubleClick: uuid => { return; }
40 });
41
42 export const LinkPanel = connect(mapStateToProps, mapDispatchToProps)(LinkPanelRoot);