2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2018-06-20 05:55:25 +02:00
|
|
|
import * as React from 'react';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
2018-10-29 18:25:22 +01:00
|
|
|
import { MODALS } from 'lbry-redux';
|
|
|
|
import * as icons from 'constants/icons';
|
2018-06-20 05:55:25 +02:00
|
|
|
import Tooltip from 'component/common/tooltip';
|
2017-01-13 03:03:34 +01:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type FileInfo = {
|
|
|
|
claim_id: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
uri: string,
|
2018-05-31 04:01:19 +02:00
|
|
|
claimId: string,
|
2018-10-29 18:25:22 +01:00
|
|
|
openModal: ({ id: string }, { uri: string }) => void,
|
2018-03-26 23:32:43 +02:00
|
|
|
claimIsMine: boolean,
|
|
|
|
fileInfo: FileInfo,
|
|
|
|
};
|
|
|
|
|
|
|
|
class FileActions extends React.PureComponent<Props> {
|
2017-04-29 19:02:25 +02:00
|
|
|
render() {
|
2018-06-20 05:55:25 +02:00
|
|
|
const { fileInfo, uri, openModal, claimIsMine, claimId } = this.props;
|
2018-03-26 23:32:43 +02:00
|
|
|
const showDelete = fileInfo && Object.keys(fileInfo).length > 0;
|
2017-04-29 19:02:25 +02:00
|
|
|
|
2017-01-13 03:03:34 +01:00
|
|
|
return (
|
2018-06-20 05:55:25 +02:00
|
|
|
<React.Fragment>
|
2017-11-24 15:31:05 +01:00
|
|
|
{showDelete && (
|
2018-06-20 05:55:25 +02:00
|
|
|
<Tooltip onComponent body={__('Delete this file')}>
|
|
|
|
<Button
|
|
|
|
button="alt"
|
2018-10-29 18:25:22 +01:00
|
|
|
icon={icons.TRASH}
|
2018-06-20 05:55:25 +02:00
|
|
|
description={__('Delete')}
|
2018-10-29 18:25:22 +01:00
|
|
|
onClick={() => openModal({ id: MODALS.CONFIRM_FILE_REMOVE }, { uri })}
|
2018-06-20 05:55:25 +02:00
|
|
|
/>
|
|
|
|
</Tooltip>
|
2017-11-24 15:31:05 +01:00
|
|
|
)}
|
|
|
|
{!claimIsMine && (
|
2018-06-20 05:55:25 +02:00
|
|
|
<Tooltip onComponent body={__('Report content')}>
|
|
|
|
<Button
|
|
|
|
button="alt"
|
2018-10-29 18:25:22 +01:00
|
|
|
icon={icons.REPORT}
|
2018-06-20 05:55:25 +02:00
|
|
|
href={`https://lbry.io/dmca?claim_id=${claimId}`}
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
2017-11-24 15:31:05 +01:00
|
|
|
)}
|
2018-06-20 05:55:25 +02:00
|
|
|
</React.Fragment>
|
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;
|