1f6979d0c78e5296cb5b436873e9846683afe183
[arvados-workbench2.git] / src / views-components / context-menu / actions / download-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, Button, ListItem } from "@material-ui/core";
7 import { DownloadIcon } from "../../../components/icon/icon";
8
9 export const DownloadAction = (props: { href?: string, download?: string, onClick?: () => void }) => {
10     const targetProps = props.download ? {} : { target: '_blank' };
11     const downloadProps = props.download ? { download: props.download } : {};
12     return props.href
13         ? <a
14             style={{ textDecoration: 'none' }}
15             href={props.href}
16             onClick={props.onClick}
17             {...targetProps}
18             {...downloadProps}>
19             <ListItem button>
20                 <ListItemIcon>
21                     <DownloadIcon />
22                 </ListItemIcon>
23                 <ListItemText>
24                     Download
25             </ListItemText>
26             </ListItem>
27         </a >
28         : null;
29 };