2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2017-12-21 22:08:54 +01:00
|
|
|
import React from 'react';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
2017-12-21 22:08:54 +01:00
|
|
|
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';
|
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,
|
|
|
|
openModal: (string, any) => void,
|
|
|
|
claimIsMine: boolean,
|
|
|
|
fileInfo: FileInfo,
|
|
|
|
vertical?: boolean, // should the buttons be stacked vertically?
|
|
|
|
};
|
|
|
|
|
|
|
|
class FileActions extends React.PureComponent<Props> {
|
2017-04-29 19:02:25 +02:00
|
|
|
render() {
|
2018-03-26 23:32:43 +02:00
|
|
|
const { fileInfo, uri, openModal, claimIsMine, vertical } = this.props;
|
2017-04-29 19:02:25 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
const claimId = fileInfo ? fileInfo.claim_id : '';
|
|
|
|
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-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}
|
2017-10-10 03:27:35 +02:00
|
|
|
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-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;
|