17782: Fixes almost all tests (4 left) mostly by fixing namespace-type imports.
[arvados-workbench2.git] / src / views-components / context-menu / actions / collection-copy-to-clipboard-action.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 { getNodeValue } from "models/tree";
8 import { ContextMenuKind } from 'views-components/context-menu/context-menu';
9 import { CopyToClipboardAction } from "./copy-to-clipboard-action";
10
11 const mapStateToProps = (state: RootState) => {
12     const { resource } = state.contextMenu;
13     const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
14     const { keepWebServiceUrl } = state.auth.config;
15     if (resource && [
16         ContextMenuKind.COLLECTION_FILE_ITEM,
17         ContextMenuKind.READONLY_COLLECTION_FILE_ITEM,
18         ContextMenuKind.COLLECTION_DIRECTORY_ITEM,
19         ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM ].indexOf(resource.menuKind as ContextMenuKind) > -1) {
20         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
21         if (file) {
22             return {
23                 href: file.url.replace(keepWebServiceUrl, ''),
24                 kind: 'file',
25                 currentCollectionUuid
26             };
27         }
28     }
29     return {};
30 };
31
32 export const CollectionCopyToClipboardAction = connect(mapStateToProps)(CopyToClipboardAction);