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-07-02 20:23:38 +02:00
|
|
|
import * as modals from "constants/modal_types";
|
2017-01-13 03:03:34 +01:00
|
|
|
|
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();
|
2017-07-28 01:34:42 +02:00
|
|
|
}
|
|
|
|
|
2017-04-29 19:02:25 +02:00
|
|
|
render() {
|
2017-09-15 15:56:32 +02:00
|
|
|
const { fileInfo, uri, openModal, claimIsMine, editClaim } = this.props;
|
2017-04-29 19:02:25 +02:00
|
|
|
|
2017-08-26 05:32:21 +02:00
|
|
|
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
|
|
|
showMenu = fileInfo && Object.keys(fileInfo).length > 0,
|
|
|
|
title = metadata ? metadata.title : uri;
|
2017-04-29 19:02:25 +02:00
|
|
|
|
2017-01-13 03:03:34 +01:00
|
|
|
return (
|
2017-09-15 15:56:32 +02:00
|
|
|
<section className="card__actions">
|
|
|
|
{claimIsMine &&
|
|
|
|
<Link
|
|
|
|
button="text"
|
|
|
|
icon="icon-edit"
|
|
|
|
label={__("Edit")}
|
|
|
|
onClick={() => editClaim({ name, channel })}
|
|
|
|
/>}
|
2017-09-08 05:15:05 +02:00
|
|
|
<FileDownloadLink uri={uri} />
|
2017-08-25 20:03:33 +02:00
|
|
|
<Link
|
|
|
|
button="text"
|
|
|
|
icon="icon-gift"
|
2017-09-15 15:56:32 +02:00
|
|
|
label={__("Support")}
|
2017-08-25 20:03:33 +02:00
|
|
|
onClick={this.handleSupportButtonClicked.bind(this)}
|
2017-07-28 01:34:42 +02:00
|
|
|
/>
|
2017-09-15 15:56:32 +02:00
|
|
|
<Link
|
|
|
|
button="text"
|
|
|
|
icon="icon-trash"
|
|
|
|
label={__("Remove")}
|
|
|
|
className="card__action--right"
|
|
|
|
onClick={() => openModal(modals.CONFIRM_FILE_REMOVE, { uri })}
|
|
|
|
/>
|
2017-05-15 05:50:59 +02:00
|
|
|
</section>
|
2017-01-13 03:03:34 +01:00
|
|
|
);
|
|
|
|
}
|
2017-04-29 19:02:25 +02:00
|
|
|
}
|
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export default FileActions;
|