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

66 lines
2 KiB
React
Raw Normal View History

2018-03-26 23:32:43 +02:00
// @flow
import * as MODALS from 'constants/modal_types';
import * as ICONS from 'constants/icons';
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-06-20 05:55:25 +02:00
import Tooltip from 'component/common/tooltip';
2019-06-05 04:26:57 +02:00
import { requestFullscreen, fullscreenElement } from 'util/full-screen';
2018-03-26 23:32:43 +02:00
type FileInfo = {
claim_id: string,
};
type Props = {
uri: string,
claimId: string,
openModal: (id: string, { uri: string }) => void,
2018-03-26 23:32:43 +02:00
claimIsMine: boolean,
fileInfo: FileInfo,
2019-06-05 04:26:57 +02:00
viewerContainer: React.Ref,
2019-05-26 08:18:47 +02:00
showFullscreen: boolean,
2018-03-26 23:32:43 +02:00
};
class FileActions extends React.PureComponent<Props> {
maximizeViewer = () => {
2019-06-05 04:26:57 +02:00
const { viewerContainer } = this.props;
const isFullscreen = fullscreenElement();
// Request fullscreen if viewer is ready
// And if there is no fullscreen element active
if (!isFullscreen && viewerContainer && viewerContainer.current !== null) {
requestFullscreen(viewerContainer.current);
}
};
2019-05-26 08:18:47 +02:00
render() {
2019-05-26 08:18:47 +02:00
const { fileInfo, uri, openModal, claimIsMine, claimId, showFullscreen } = this.props;
2019-01-22 21:36:28 +01:00
const showDelete = claimIsMine || (fileInfo && Object.keys(fileInfo).length > 0);
return (
2018-06-20 05:55:25 +02:00
<React.Fragment>
2019-05-26 08:18:47 +02:00
{showFullscreen && (
<Tooltip onComponent body={__('Full screen (f)')}>
<Button button="alt" description={__('Fullscreen')} icon={ICONS.FULLSCREEN} onClick={this.maximizeViewer} />
2019-05-26 08:18:47 +02:00
</Tooltip>
)}
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"
2019-01-22 21:36:28 +01:00
icon={ICONS.DELETE}
2018-06-20 05:55:25 +02:00
description={__('Delete')}
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 && (
2018-06-20 05:55:25 +02:00
<Tooltip onComponent body={__('Report content')}>
2019-03-20 22:43:00 +01:00
<Button icon={ICONS.REPORT} href={`https://lbry.com/dmca?claim_id=${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-06-06 06:21:55 +02:00
export default FileActions;