2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2018-10-29 18:23:53 +01:00
|
|
|
import * as MODALS from 'constants/modal_types';
|
|
|
|
import * as ICONS from 'constants/icons';
|
2019-06-28 09:27:55 +02:00
|
|
|
import React from 'react';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
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 Props = {
|
|
|
|
uri: string,
|
2018-05-31 04:01:19 +02:00
|
|
|
claimId: string,
|
2018-10-29 18:23:53 +01:00
|
|
|
openModal: (id: string, { uri: string }) => void,
|
2018-03-26 23:32:43 +02:00
|
|
|
claimIsMine: boolean,
|
2019-08-06 05:25:33 +02:00
|
|
|
fileInfo: FileListItem,
|
2018-03-26 23:32:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class FileActions extends React.PureComponent<Props> {
|
2017-04-29 19:02:25 +02:00
|
|
|
render() {
|
2019-08-02 23:03:26 +02:00
|
|
|
const { fileInfo, uri, openModal, claimIsMine, claimId } = this.props;
|
2019-08-15 01:34:14 +02:00
|
|
|
const showDelete = claimIsMine || (fileInfo && (fileInfo.written_bytes > 0 || fileInfo.blobs_completed > 0));
|
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 && (
|
2019-06-28 09:27:55 +02:00
|
|
|
<Tooltip label={__('Remove from your library')}>
|
2018-06-20 05:55:25 +02:00
|
|
|
<Button
|
2019-11-22 22:13:00 +01:00
|
|
|
button="alt"
|
2019-01-22 21:36:28 +01:00
|
|
|
icon={ICONS.DELETE}
|
2018-06-20 05:55:25 +02:00
|
|
|
description={__('Delete')}
|
2018-10-29 18:23:53 +01:00
|
|
|
onClick={() => openModal(MODALS.CONFIRM_FILE_REMOVE, { uri })}
|
2018-06-20 05:55:25 +02:00
|
|
|
/>
|
|
|
|
</Tooltip>
|
2017-11-24 15:31:05 +01:00
|
|
|
)}
|
|
|
|
{!claimIsMine && (
|
2019-06-28 09:27:55 +02:00
|
|
|
<Tooltip label={__('Report content')}>
|
2019-11-22 22:13:00 +01:00
|
|
|
<Button button="alt" icon={ICONS.REPORT} href={`https://lbry.com/dmca/${claimId}`} />
|
2018-06-20 05:55:25 +02:00
|
|
|
</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;
|