lbry-desktop/ui/js/component/fileActions/view.jsx

71 lines
2 KiB
React
Raw Normal View History

2017-06-06 23:19:12 +02:00
import React from "react";
import Link from "component/link";
2017-09-08 05:15:05 +02:00
import FileDownloadLink from "component/fileDownloadLink";
2017-06-06 23:19:12 +02:00
import { DropDownMenu, DropDownMenuItem } from "component/menu";
2017-07-02 20:23:38 +02:00
import * as modals from "constants/modal_types";
2017-06-08 06:42:19 +02:00
class FileActions extends React.PureComponent {
2017-08-25 20:03:33 +02:00
handleSupportButtonClicked() {
this.props.onTipShow();
}
render() {
const {
fileInfo,
platform,
uri,
openInFolder,
openModal,
claimIsMine,
2017-09-05 05:03:28 +02:00
editClaim,
2017-06-06 23:19:12 +02:00
} = this.props;
const name = fileInfo ? fileInfo.name : null;
const channel = fileInfo ? fileInfo.channel_name : null;
2017-07-02 20:23:38 +02:00
const metadata = fileInfo ? fileInfo.metadata : null,
2017-06-06 23:19:12 +02:00
openInFolderMessage = platform.startsWith("Mac")
? __("Open in Finder")
: __("Open in Folder"),
showMenu = fileInfo && Object.keys(fileInfo).length > 0,
title = metadata ? metadata.title : uri;
return (
2017-05-15 05:50:59 +02:00
<section className="file-actions">
2017-09-08 05:15:05 +02:00
<FileDownloadLink uri={uri} />
2017-08-25 20:03:33 +02:00
<Link
label={__("Support")}
button="text"
icon="icon-gift"
onClick={this.handleSupportButtonClicked.bind(this)}
/>
2017-08-25 20:41:31 +02:00
{showMenu
2017-08-26 05:21:26 +02:00
? <div className="button-set-item">
<DropDownMenu>
<DropDownMenuItem
key={0}
onClick={() => openInFolder(fileInfo)}
label={openInFolderMessage}
/>
2017-08-26 04:09:56 +02:00
{claimIsMine &&
2017-09-07 15:38:44 +02:00
<DropDownMenuItem
key={1}
onClick={() => editClaim({ name, channel })}
label={__("Edit claim")}
/>}
2017-08-26 04:09:56 +02:00
<DropDownMenuItem
2017-09-07 15:38:44 +02:00
key={2}
2017-09-08 05:15:05 +02:00
onClick={() => openModal(modals.CONFIRM_FILE_REMOVE, { uri })}
2017-08-26 05:21:26 +02:00
label={__("Remove...")}
/>
</DropDownMenu>
</div>
2017-06-06 23:19:12 +02:00
: ""}
2017-09-07 23:18:33 +02:00
2017-05-15 05:50:59 +02:00
</section>
);
}
}
2017-06-06 06:21:55 +02:00
export default FileActions;