17018: Fixes the bug adding checks for readonly context menu type.
[arvados-workbench2.git] / src / views-components / context-menu / actions / file-viewer-actions.tsx
index bedc59059451dbf46f896c864ed8ad877083a39a..961e182860c77d9db5542bec33f31ee28e0d6bbc 100644 (file)
@@ -10,6 +10,7 @@ import { CollectionDirectory, CollectionFile, CollectionFileType } from '~/model
 import { FileViewerList, FileViewer } from '~/models/file-viewers-config';
 import { getFileViewers } from '~/store/file-viewers/file-viewers-selectors';
 import { connect } from 'react-redux';
+import { OpenIcon } from '~/components/icon/icon';
 
 interface FileViewerActionProps {
     fileUrl: string;
@@ -55,20 +56,26 @@ export const FileViewerActions = connect(mapStateToProps)(
     ({ fileUrl, viewers, onClick }: FileViewerActionProps & { onClick: () => void }) =>
         <>
             {viewers.map(viewer =>
-                <a
+                <ListItem
+                    button
+                    component='a'
                     key={viewer.name}
                     style={{ textDecoration: 'none' }}
                     href={fillViewerUrl(fileUrl, viewer)}
                     onClick={onClick}
                     target='_blank'>
-                    <ListItem button>
-                        <ListItemIcon>
-                            <Icon />
-                        </ListItemIcon>
-                        <ListItemText>
-                            {viewer.name}
-                        </ListItemText>
-                    </ListItem>
-                </a>
+                    <ListItemIcon>
+                        {
+                            viewer.iconUrl
+                                ? <Icon>
+                                    <img src={viewer.iconUrl} />
+                                </Icon>
+                                : <OpenIcon />
+                        }
+                    </ListItemIcon>
+                    <ListItemText>
+                        {viewer.name}
+                    </ListItemText>
+                </ListItem>
             )}
         </>);