lbry-desktop/src/renderer/component/fileActions/view.jsx

53 lines
1.4 KiB
React
Raw Normal View History

2018-03-26 23:32:43 +02:00
// @flow
import React from 'react';
2018-03-26 23:32:43 +02:00
import Button from 'component/button';
import FileDownloadLink from 'component/fileDownloadLink';
import * as modals from 'constants/modal_types';
2018-03-26 23:32:43 +02:00
import classnames from 'classnames';
import * as icons from 'constants/icons';
2018-03-26 23:32:43 +02:00
type FileInfo = {
claim_id: string,
};
type Props = {
uri: string,
openModal: (string, any) => void,
claimIsMine: boolean,
fileInfo: FileInfo,
vertical?: boolean, // should the buttons be stacked vertically?
};
class FileActions extends React.PureComponent<Props> {
render() {
2018-03-26 23:32:43 +02:00
const { fileInfo, uri, openModal, claimIsMine, vertical } = this.props;
2018-03-26 23:32:43 +02:00
const claimId = fileInfo ? fileInfo.claim_id : '';
const showDelete = fileInfo && Object.keys(fileInfo).length > 0;
return (
2018-03-26 23:32:43 +02:00
<section className={classnames('card__actions', { 'card__actions--vertical': vertical })}>
2017-09-08 05:15:05 +02:00
<FileDownloadLink uri={uri} />
2017-11-24 15:31:05 +01:00
{showDelete && (
2018-03-26 23:32:43 +02:00
<Button
className="btn--file-actions"
icon={icons.TRASH}
description={__('Delete')}
2017-09-17 20:26:55 +02:00
onClick={() => openModal(modals.CONFIRM_FILE_REMOVE, { uri })}
2017-11-24 15:31:05 +01:00
/>
)}
{!claimIsMine && (
2018-03-26 23:32:43 +02:00
<Button
className="btn--file-actions"
icon={icons.REPORT}
href={`https://lbry.io/dmca?claim_id=${claimId}`}
2018-03-26 23:32:43 +02:00
description={__('Report content')}
2017-11-24 15:31:05 +01:00
/>
)}
2017-05-15 05:50:59 +02:00
</section>
);
}
}
2017-06-06 06:21:55 +02:00
export default FileActions;