2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2018-11-07 23:44:38 +01:00
|
|
|
import type { Claim, Metadata } from 'types/claim';
|
|
|
|
import type { FileInfo } from 'types/file_info';
|
2018-11-14 18:20:31 +01:00
|
|
|
import type { Node } from 'react';
|
2018-11-07 23:44:38 +01:00
|
|
|
import React, { Fragment, PureComponent } from 'react';
|
|
|
|
import { Lbryio } from 'lbryinc';
|
2018-06-10 23:57:46 +02:00
|
|
|
import MarkdownPreview from 'component/common/markdown-preview';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
|
|
|
import path from 'path';
|
2018-11-07 23:44:38 +01:00
|
|
|
import Expandable from 'component/expandable';
|
2017-09-17 22:33:52 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type Props = {
|
2018-05-07 06:50:55 +02:00
|
|
|
claim: Claim,
|
2018-11-07 23:44:38 +01:00
|
|
|
fileInfo: FileInfo,
|
|
|
|
metadata: Metadata,
|
2018-03-26 23:32:43 +02:00
|
|
|
openFolder: string => void,
|
|
|
|
contentType: string,
|
2018-11-07 23:44:38 +01:00
|
|
|
clickCommentButton: () => void,
|
2018-11-14 18:20:31 +01:00
|
|
|
showSnackBar: Node => void,
|
2018-11-07 23:44:38 +01:00
|
|
|
hasClickedComment: boolean,
|
|
|
|
user: ?any,
|
2018-03-26 23:32:43 +02:00
|
|
|
};
|
2017-09-20 14:47:08 +02:00
|
|
|
|
2018-11-07 23:44:38 +01:00
|
|
|
class FileDetails extends PureComponent<Props> {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
(this: any).handleCommentClick = this.handleCommentClick.bind(this);
|
|
|
|
}
|
2017-09-17 22:33:52 +02:00
|
|
|
|
2018-11-07 23:44:38 +01:00
|
|
|
handleCommentClick() {
|
|
|
|
const { clickCommentButton, showSnackBar } = this.props;
|
|
|
|
|
|
|
|
clickCommentButton();
|
|
|
|
Lbryio.call('user_tag', 'edit', { add: 'comments-waitlist' });
|
2018-11-14 18:20:31 +01:00
|
|
|
showSnackBar(
|
|
|
|
<span>
|
|
|
|
{__('Thanks! Comments are coming soon')}
|
|
|
|
<sup>TM</sup>
|
|
|
|
</span>
|
|
|
|
);
|
2018-03-26 23:32:43 +02:00
|
|
|
}
|
2017-09-17 22:33:52 +02:00
|
|
|
|
2018-11-07 23:44:38 +01:00
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
claim,
|
|
|
|
contentType,
|
|
|
|
fileInfo,
|
|
|
|
metadata,
|
|
|
|
openFolder,
|
|
|
|
hasClickedComment,
|
|
|
|
user,
|
|
|
|
} = this.props;
|
2018-04-25 21:31:58 +02:00
|
|
|
|
2018-11-07 23:44:38 +01:00
|
|
|
if (!claim || !metadata) {
|
|
|
|
return (
|
|
|
|
<div className="card__content">
|
|
|
|
<span className="empty">{__('Empty claim or metadata info.')}</span>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const { description, language, license } = metadata;
|
2017-09-17 22:33:52 +02:00
|
|
|
|
2018-11-07 23:44:38 +01:00
|
|
|
const mediaType = contentType || 'unknown';
|
|
|
|
const downloadPath = fileInfo ? path.normalize(fileInfo.download_path) : null;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<Expandable>
|
|
|
|
{description && (
|
|
|
|
<Fragment>
|
2018-12-19 06:44:53 +01:00
|
|
|
<div className="media__info-title">About</div>
|
|
|
|
<div className="media__info-text">
|
2018-11-07 23:44:38 +01:00
|
|
|
<MarkdownPreview content={description} promptLinks />
|
|
|
|
</div>
|
|
|
|
</Fragment>
|
|
|
|
)}
|
2018-12-19 06:44:53 +01:00
|
|
|
<div className="media__info-title">Info</div>
|
|
|
|
<div className="media__info-text">
|
2018-11-07 23:44:38 +01:00
|
|
|
<div>
|
|
|
|
{__('Content-Type')}
|
|
|
|
{': '}
|
|
|
|
{mediaType}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{__('Language')}
|
|
|
|
{': '}
|
|
|
|
{language}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{__('License')}
|
|
|
|
{': '}
|
|
|
|
{license}
|
|
|
|
</div>
|
|
|
|
{downloadPath && (
|
|
|
|
<div>
|
|
|
|
{__('Downloaded to')}
|
|
|
|
{': '}
|
|
|
|
<Button
|
|
|
|
button="link"
|
|
|
|
onClick={() => openFolder(downloadPath)}
|
|
|
|
label={downloadPath}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
2018-03-26 23:32:43 +02:00
|
|
|
</div>
|
2018-11-07 23:44:38 +01:00
|
|
|
</Expandable>
|
2018-12-19 06:44:53 +01:00
|
|
|
|
|
|
|
<div className="media__info-title">Comments</div>
|
|
|
|
|
|
|
|
<div className="card__actions">
|
|
|
|
<Button
|
|
|
|
data-id="add-comment"
|
|
|
|
disabled={hasClickedComment}
|
|
|
|
button="primary"
|
|
|
|
label={__('Want to comment?')}
|
|
|
|
onClick={this.handleCommentClick}
|
|
|
|
/>
|
2018-11-07 23:44:38 +01:00
|
|
|
</div>
|
2018-12-19 06:44:53 +01:00
|
|
|
<br />
|
|
|
|
{hasClickedComment && (
|
|
|
|
<p className="main--for-content">
|
|
|
|
{user
|
|
|
|
? __('Your support has been added. You will be notified when comments are available.')
|
|
|
|
: __('Your support has been added. Comments are coming soon.')}
|
|
|
|
</p>
|
|
|
|
)}
|
2018-11-07 23:44:38 +01:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2017-09-17 22:33:52 +02:00
|
|
|
|
|
|
|
export default FileDetails;
|