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

52 lines
1.3 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 { MODALS } from 'lbry-redux';
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,
2018-04-19 18:51:18 +02:00
openModal: ({ id: string }, { uri: string }) => void,
2018-03-26 23:32:43 +02:00
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-11-24 15:31:05 +01:00
{showDelete && (
2018-03-26 23:32:43 +02:00
<Button
2018-05-21 22:30:00 +02:00
button="alt"
2018-03-26 23:32:43 +02:00
icon={icons.TRASH}
iconColor="red"
2018-05-21 22:30:00 +02:00
label={__('Delete')}
onClick={() => openModal({ id: MODALS.CONFIRM_FILE_REMOVE }, { uri })}
2017-11-24 15:31:05 +01:00
/>
)}
{!claimIsMine && (
2018-03-26 23:32:43 +02:00
<Button
2018-05-21 22:30:00 +02:00
button="alt"
2018-03-26 23:32:43 +02:00
icon={icons.REPORT}
href={`https://lbry.io/dmca?claim_id=${claimId}`}
2018-05-21 22:30:00 +02:00
label={__('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;