a2c32bea875e32524be04532dd90957e6da06675
[arvados-workbench2.git] / src / views-components / context-menu / actions / file-viewer-action.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from "react";
6 import { ListItemIcon, ListItemText, ListItem } from "@material-ui/core";
7 import { OpenIcon } from "~/components/icon/icon";
8 import { sanitizeToken } from "./helpers";
9
10 export const FileViewerAction = (props: { href?: any, download?: any, onClick?: () => void, kind?: string, currentCollectionUuid?: string; }) => {
11     const fileProps = props.download ? { download: props.download } : {};
12
13     return props.href
14         ? <a
15             style={{ textDecoration: 'none' }}
16             href={sanitizeToken(props.href)}
17             target="_blank"
18             onClick={props.onClick}
19             {...fileProps}>
20             <ListItem button>
21                     <ListItemIcon>
22                         <OpenIcon />
23                     </ListItemIcon>
24                 <ListItemText>
25                     Open in new tab
26                 </ListItemText>
27             </ListItem>
28         </a>
29         : null;
30 };