-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2095 from lbryio/comments
Comments support button
- Loading branch information
Showing
16 changed files
with
261 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { connect } from 'react-redux'; | ||
import Expandable from './view'; | ||
|
||
export default connect( | ||
null, | ||
null | ||
)(Expandable); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// @flow | ||
import React, { PureComponent, Node } from 'react'; | ||
import classnames from 'classnames'; | ||
import Button from 'component/button'; | ||
|
||
// Note: | ||
// When we use this in other parts of the app, we will probably need to | ||
// add props for collapsed height | ||
|
||
type Props = { | ||
children: Node | Array<Node>, | ||
}; | ||
|
||
type State = { | ||
expanded: boolean, | ||
}; | ||
|
||
export default class Expandable extends PureComponent<Props, State> { | ||
constructor() { | ||
super(); | ||
|
||
this.state = { | ||
expanded: false, | ||
}; | ||
|
||
(this: any).handleClick = this.handleClick.bind(this); | ||
} | ||
|
||
handleClick() { | ||
this.setState({ | ||
expanded: !this.state.expanded, | ||
}); | ||
} | ||
|
||
render() { | ||
const { children } = this.props; | ||
const { expanded } = this.state; | ||
|
||
return ( | ||
<div className="expandable"> | ||
<div | ||
className={classnames({ | ||
'expandable--open': expanded, | ||
'expandable--closed': !expanded, | ||
})} | ||
> | ||
{children} | ||
</div> | ||
<Button | ||
button="link" | ||
label={expanded ? __('Less') : __('More')} | ||
onClick={this.handleClick} | ||
/> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,128 @@ | ||
// @flow | ||
import * as React from 'react'; | ||
import type { Claim, Metadata } from 'types/claim'; | ||
import type { FileInfo } from 'types/file_info'; | ||
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 type { Claim } from 'types/claim'; | ||
import Expandable from 'component/expandable'; | ||
|
||
type Props = { | ||
claim: Claim, | ||
fileInfo: { | ||
download_path: string, | ||
}, | ||
metadata: { | ||
description: string, | ||
language: string, | ||
license: string, | ||
}, | ||
fileInfo: FileInfo, | ||
metadata: Metadata, | ||
openFolder: string => void, | ||
contentType: string, | ||
clickCommentButton: () => void, | ||
showSnackBar: string => void, | ||
hasClickedComment: boolean, | ||
user: ?any, | ||
}; | ||
|
||
const FileDetails = (props: Props) => { | ||
const { claim, contentType, fileInfo, metadata, openFolder } = props; | ||
class FileDetails extends PureComponent<Props> { | ||
constructor() { | ||
super(); | ||
(this: any).handleCommentClick = this.handleCommentClick.bind(this); | ||
} | ||
|
||
if (!claim || !metadata) { | ||
return ( | ||
<div className="card__content"> | ||
<span className="empty">{__('Empty claim or metadata info.')}</span> | ||
</div> | ||
); | ||
handleCommentClick() { | ||
const { clickCommentButton, showSnackBar } = this.props; | ||
|
||
clickCommentButton(); | ||
Lbryio.call('user_tag', 'edit', { add: 'comments-waitlist' }); | ||
showSnackBar(__('Thanks! Comments are coming soon(ish).')); | ||
} | ||
|
||
const { description, language, license } = metadata; | ||
render() { | ||
const { | ||
claim, | ||
contentType, | ||
fileInfo, | ||
metadata, | ||
openFolder, | ||
hasClickedComment, | ||
user, | ||
} = this.props; | ||
|
||
const mediaType = contentType || 'unknown'; | ||
const downloadPath = fileInfo ? path.normalize(fileInfo.download_path) : null; | ||
if (!claim || !metadata) { | ||
return ( | ||
<div className="card__content"> | ||
<span className="empty">{__('Empty claim or metadata info.')}</span> | ||
</div> | ||
); | ||
} | ||
|
||
const { description, language, license } = metadata; | ||
|
||
return ( | ||
<React.Fragment> | ||
{description && ( | ||
<React.Fragment> | ||
<div className="card__subtext-title">About</div> | ||
const mediaType = contentType || 'unknown'; | ||
const downloadPath = fileInfo ? path.normalize(fileInfo.download_path) : null; | ||
|
||
return ( | ||
<Fragment> | ||
<Expandable> | ||
{description && ( | ||
<Fragment> | ||
<div className="card__subtext-title">About</div> | ||
<div className="card__subtext"> | ||
<MarkdownPreview content={description} promptLinks /> | ||
</div> | ||
</Fragment> | ||
)} | ||
<div className="card__subtext-title">Info</div> | ||
<div className="card__subtext"> | ||
<MarkdownPreview content={description} promptLinks={true} /> | ||
<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> | ||
</React.Fragment> | ||
)} | ||
<div className="card__subtext-title">Info</div> | ||
<div className="card__subtext"> | ||
<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} /> | ||
</Expandable> | ||
<div className="card__content"> | ||
<div className="card__subtext-title">Comments</div> | ||
<div className="card__actions card__actions--center"> | ||
<Button | ||
data-id="add-comment" | ||
disabled={hasClickedComment} | ||
button="primary" | ||
label={__('Want to comment?')} | ||
onClick={this.handleCommentClick} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
</React.Fragment> | ||
); | ||
}; | ||
{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> | ||
)} | ||
</div> | ||
</Fragment> | ||
); | ||
} | ||
} | ||
|
||
export default FileDetails; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.