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