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 cdc0c8294ca01f75e06ab59335633a1cab0ae304..dfc9d14acd7e5552e5daa23e9256b04ab819f764 100644 (file)
@@ -11,19 +11,19 @@ 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 : '';
-    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 {
-                href: file.url,
+                href: file.url.replace(state.auth.config.keepWebServiceUrl, state.auth.config.keepWebInlineServiceUrl),
                 kind: 'file',
                 currentCollectionUuid
             };
         }
-    } else {
-        return ;
     }
-    return ;
+    return {};
 };
 
 export const CollectionFileViewerAction = connect(mapStateToProps)(FileViewerAction);