diff --git a/ui/component/fileDescription/index.js b/ui/component/fileDescription/index.js index 43afce05b..ce3b53a00 100644 --- a/ui/component/fileDescription/index.js +++ b/ui/component/fileDescription/index.js @@ -1,5 +1,10 @@ import { connect } from 'react-redux'; -import { makeSelectClaimForUri, makeSelectMetadataForUri, makeSelectTagsForUri } from 'lbry-redux'; +import { + makeSelectClaimForUri, + makeSelectMetadataForUri, + makeSelectTagsForUri, + makeSelectPendingAmountByUri, +} from 'lbry-redux'; import { selectUser } from 'redux/selectors/user'; import FileDescription from './view'; @@ -8,6 +13,7 @@ const select = (state, props) => ({ metadata: makeSelectMetadataForUri(props.uri)(state), user: selectUser(state), tags: makeSelectTagsForUri(props.uri)(state), + pendingAmount: makeSelectPendingAmountByUri(props.uri)(state), }); export default connect(select, null)(FileDescription); diff --git a/ui/component/fileDescription/view.jsx b/ui/component/fileDescription/view.jsx index 7bbd53fe8..f4d64a95b 100644 --- a/ui/component/fileDescription/view.jsx +++ b/ui/component/fileDescription/view.jsx @@ -1,9 +1,13 @@ // @flow import React from 'react'; import classnames from 'classnames'; +import { formatCredits } from 'lbry-redux'; import MarkdownPreview from 'component/common/markdown-preview'; import ClaimTags from 'component/claimTags'; import Button from 'component/button'; +import LbcSymbol from 'component/common/lbc-symbol'; +import FileDetails from 'component/fileDetails'; +import FileValues from 'component/fileValues'; type Props = { uri: string, @@ -11,23 +15,15 @@ type Props = { metadata: StreamMetadata, user: ?any, tags: any, + pendingAmount: number, }; function FileDescription(props: Props) { - const { uri, claim, metadata, tags } = props; + const { uri, claim, metadata, tags, pendingAmount } = props; const [expanded, setExpanded] = React.useState(false); - const [hasOverflow, setHasOverflow] = React.useState(false); - const [hasCalculatedOverflow, setHasCalculatedOverflow] = React.useState(false); - const descriptionRef = React.useRef(); - - React.useEffect(() => { - if (descriptionRef && descriptionRef.current) { - const element = descriptionRef.current; - const isOverflowing = element.scrollHeight > element.clientHeight; - setHasOverflow(isOverflowing); - setHasCalculatedOverflow(true); - } - }, [descriptionRef]); + const [showCreditDetails, setShowCreditDetails] = React.useState(false); + const amount = parseFloat(claim.amount) + parseFloat(pendingAmount || claim.meta.support_amount); + const formattedAmount = formatCredits(amount, 2, true); if (!claim || !metadata) { return {__('Empty claim or metadata info.')}; @@ -40,23 +36,32 @@ function FileDescription(props: Props) { return (
+
- {hasCalculatedOverflow && hasOverflow && ( -
- {expanded ? ( - +
+ + {showCreditDetails && ( +
+
)}
diff --git a/ui/component/fileDetails/view.jsx b/ui/component/fileDetails/view.jsx index 79765fa16..92a269a65 100644 --- a/ui/component/fileDetails/view.jsx +++ b/ui/component/fileDetails/view.jsx @@ -1,8 +1,7 @@ // @flow -import React, { Fragment, PureComponent } from 'react'; +import React, { PureComponent } from 'react'; import Button from 'component/button'; import path from 'path'; -import Card from 'component/common/card'; import { formatBytes } from 'util/format-bytes'; type Props = { @@ -39,67 +38,58 @@ class FileDetails extends PureComponent { } return ( - - - - - {__('Content Type')} - {mediaType} - - {fileSize && ( - - {__('File Size')} - {fileSize} - - )} + + + + + + + {fileSize && ( + + + + + )} - - - - + + + + - - - - + + + + - {languages && ( - - - - - )} - - - - - {downloadPath && ( - - - - - )} - -
{__('Content Type')}{mediaType}
{__('File Size')}{fileSize}
{__('URL')}{claim.canonical_url}
{__('URL')}{claim.canonical_url}
{__('Claim ID')}{claim.claim_id}
{__('Claim ID')}{claim.claim_id}
{__('Languages')}{languages.join(' ')}
{__('License')}{license}
{__('Downloaded to')} - {/* {downloadPath.replace(/(.{10})/g, '$1\u200b')} */} -
- } - /> -
+ {languages && ( + + {__('Languages')} + {languages.join(' ')} + + )} + + {__('License')} + {license} + + {downloadPath && ( + + {__('Downloaded to')} + +