//
// SPDX-License-Identifier: AGPL-3.0
-import * as React from "react";
-import { ListItemText, ListItem, ListItemIcon } from "@material-ui/core";
-import { RootState } from '~/store/store';
-import { getNodeValue } from '~/models/tree';
-import { CollectionDirectory, CollectionFile, CollectionFileType } from '~/models/collection-file';
-import { FileViewerList, FileViewer } from '~/models/file-viewers-config';
-import { getFileViewers } from '~/store/file-viewers/file-viewers-selectors';
+import React from "react";
+import { ListItemText, ListItem, ListItemIcon, Icon } from "@material-ui/core";
+import { RootState } from 'store/store';
+import { getNodeValue } from 'models/tree';
+import { CollectionDirectory, CollectionFile, CollectionFileType } from 'models/collection-file';
+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';
+import { OpenIcon } from 'components/icon/icon';
interface FileViewerActionProps {
fileUrl: string;
({ 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>
- <OpenIcon />
- </ListItemIcon>
- <ListItemText>
- {viewer.name}
- </ListItemText>
- </ListItem>
- </a>
+ <ListItemIcon>
+ {
+ viewer.iconUrl
+ ? <Icon>
+ <img src={viewer.iconUrl} />
+ </Icon>
+ : <OpenIcon />
+ }
+ </ListItemIcon>
+ <ListItemText>
+ {viewer.name}
+ </ListItemText>
+ </ListItem>
)}
</>);