lbry-desktop/src/renderer/component/fileDetails/view.jsx
Sean Yesmunt ad90c1f96e
Redesign fixes (#2164)
* fix: share modal not opening

* fix: add more spacing above snackbar link

* fix: properly close thumbnail error modal

* fix: better align media property icons

* fix: tx filter alignment and prevent hiding filter if no current tx's

* fix: publish markdown on dark mode

* fix: add max-width on container for large screens

* fix: channel pagination aligmnent and spacing

* fix: modal spacing and flow errors

* fix: home page scrolling (now with mouse scrolling)

* fix: hover color in dark mode for outline buttons

* fix: improve file page spacing/layout

* cleanup

* fix: wrap file actions on smaller screens

* fix: comment button spacing
2019-01-07 18:29:40 -05:00

133 lines
3.5 KiB
JavaScript

// @flow
import type { Claim, Metadata } from 'types/claim';
import type { FileInfo } from 'types/file_info';
import type { Node } from 'react';
import React, { Fragment, PureComponent } from 'react';
import { Lbryio } from 'lbryinc';
import MarkdownPreview from 'component/common/markdown-preview';
import Button from 'component/button';
import path from 'path';
import Expandable from 'component/expandable';
type Props = {
claim: Claim,
fileInfo: FileInfo,
metadata: Metadata,
openFolder: string => void,
contentType: string,
clickCommentButton: () => void,
showSnackBar: Node => void,
hasClickedComment: boolean,
user: ?any,
};
class FileDetails extends PureComponent<Props> {
constructor() {
super();
(this: any).handleCommentClick = this.handleCommentClick.bind(this);
}
handleCommentClick() {
const { clickCommentButton, showSnackBar } = this.props;
clickCommentButton();
Lbryio.call('user_tag', 'edit', { add: 'comments-waitlist' });
showSnackBar(
<span>
{__('Thanks! Comments are coming soon')}
<sup>TM</sup>
</span>
);
}
render() {
const {
claim,
contentType,
fileInfo,
metadata,
openFolder,
hasClickedComment,
user,
} = this.props;
if (!claim || !metadata) {
return (
<div className="card__content">
<span className="empty">{__('Empty claim or metadata info.')}</span>
</div>
);
}
const { description, language, license } = metadata;
const mediaType = contentType || 'unknown';
const downloadPath = fileInfo ? path.normalize(fileInfo.download_path) : null;
return (
<Fragment>
<Expandable>
{description && (
<Fragment>
<div className="media__info-title">About</div>
<div className="media__info-text">
<MarkdownPreview content={description} promptLinks />
</div>
</Fragment>
)}
<div className="media__info-title">Info</div>
<div className="media__info-text">
<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>
)}
</div>
</Expandable>
<div className="media__info-title">Comments</div>
<div className="card__actions--center">
<Button
data-id="add-comment"
disabled={hasClickedComment}
button="primary"
label={__('Want to comment?')}
onClick={this.handleCommentClick}
/>
</div>
<br />
{hasClickedComment && (
<p className="media__info-text media__info-text--center">
{user
? __('Your support has been added. You will be notified when comments are available.')
: __('Your support has been added. Comments are coming soon.')}
</p>
)}
</Fragment>
);
}
}
export default FileDetails;