17018: Fixes the bug adding checks for readonly context menu type.
[arvados-workbench2.git] / src / views-components / context-menu / actions / collection-file-viewer-action.tsx
index f75da23869666e248fe1f04d91cd0e500f0e1a21..dfc9d14acd7e5552e5daa23e9256b04ab819f764 100644 (file)
@@ -11,7 +11,9 @@ import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
 const mapStateToProps = (state: RootState) => {
     const { resource } = state.contextMenu;
     const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
 const mapStateToProps = (state: RootState) => {
     const { resource } = state.contextMenu;
     const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
-    if (resource && resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM) {
+    if (resource && (
+        resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM ||
+        resource.menuKind === ContextMenuKind.READONLY_COLLECTION_FILES_ITEM)) {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
             return {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
             return {
@@ -20,10 +22,8 @@ const mapStateToProps = (state: RootState) => {
                 currentCollectionUuid
             };
         }
                 currentCollectionUuid
             };
         }
-    } else {
-        return;
     }
     }
-    return;
+    return {};
 };
 
 export const CollectionFileViewerAction = connect(mapStateToProps)(FileViewerAction);
 };
 
 export const CollectionFileViewerAction = connect(mapStateToProps)(FileViewerAction);