From e8c5ba5536f445b99e221ff4828e4d03eec62a1d Mon Sep 17 00:00:00 2001 From: hackrush Date: Fri, 25 Aug 2017 23:33:33 +0530 Subject: [PATCH] Tipping UI is rendered in FilePage --- ui/js/component/fileActions/view.jsx | 26 +++----- ui/js/component/tipLink/view.jsx | 92 ++++++++++------------------ ui/js/page/filePage/view.jsx | 38 +++++++++++- 3 files changed, 74 insertions(+), 82 deletions(-) diff --git a/ui/js/component/fileActions/view.jsx b/ui/js/component/fileActions/view.jsx index 1b0c2670a..cd5700e86 100644 --- a/ui/js/component/fileActions/view.jsx +++ b/ui/js/component/fileActions/view.jsx @@ -1,7 +1,6 @@ import React from "react"; import { Icon, BusyMessage } from "component/common"; import FilePrice from "component/filePrice"; -import TipLink from "component/tipLink"; import { Modal } from "component/modal"; import Link from "component/link"; import { ToolTip } from "component/tooltip"; @@ -14,7 +13,6 @@ class FileActions extends React.PureComponent { super(props); this.state = { forceShowActions: false, - showTipBox: false, }; } @@ -59,16 +57,8 @@ class FileActions extends React.PureComponent { this.props.loadVideo(this.props.uri); } - handleTipShow() { - this.setState({ - showTipBox: true, - }); - } - - handleTipHide() { - this.setState({ - showTipBox: false, - }); + handleSupportButtonClicked() { + this.props.onTipShow(); } render() { @@ -90,8 +80,6 @@ class FileActions extends React.PureComponent { claimInfo, } = this.props; - const { showTipBox } = this.state; - const metadata = fileInfo ? fileInfo.metadata : null, openInFolderMessage = platform.startsWith("Mac") ? __("Open in Finder") @@ -183,11 +171,11 @@ class FileActions extends React.PureComponent { return (
{showTipBox ? "" : content} - {showMenu && !showTipBox ? diff --git a/ui/js/component/tipLink/view.jsx b/ui/js/component/tipLink/view.jsx index 432e24004..4fbd111c3 100644 --- a/ui/js/component/tipLink/view.jsx +++ b/ui/js/component/tipLink/view.jsx @@ -1,28 +1,20 @@ import React from "react"; import Link from "component/link"; -import FormFieldPrice from "component/formFieldPrice"; +import { FormRow } from "component/form"; class TipLink extends React.PureComponent { constructor(props) { super(props); this.state = { - feeAmount: "1.00", - currency: "LBC", + tipAmount: "1.00", }; } - handleSupportButtonClicked() { - this.resetDefaults(); - this.props.onTipShow(); - } - handleSendButtonClicked() { let claim_id = this.props.claim_id; - let amount = this.state.feeAmount; - + let amount = this.state.tipAmount; this.props.sendSupport(amount, claim_id); - this.props.onTipHide(); } @@ -30,61 +22,41 @@ class TipLink extends React.PureComponent { this.props.onTipHide(); } - handleSupportPriceChange(newValue) { + handleSupportPriceChange(event) { this.setState({ - feeAmount: newValue.amount, - feeCurrency: newValue.currency, - }); - } - - resetDefaults() { - this.setState({ - feeAmount: "1.00", - currency: "LBC", + tipAmount: event.target.value, }); } render() { - const { showTipBox } = this.props; - const { feeAmount, currency } = this.state; - - let tipLink = ( - - ); - - let tipBox = ( - - this.handleSupportPriceChange(value)} - defaultValue={{ amount: feeAmount, currency: currency }} - /> - - -
- {__("This sends the entered amount of LBCs to the publisher.")} -
-
- ); - return ( -
- {showTipBox ? tipBox : tipLink} +
+
+

{__("Support Claim")}

+
+
+ this.handleSupportPriceChange(event)} + /> +
+
+ + +
); } diff --git a/ui/js/page/filePage/view.jsx b/ui/js/page/filePage/view.jsx index 3ca23aadc..d3c633015 100644 --- a/ui/js/page/filePage/view.jsx +++ b/ui/js/page/filePage/view.jsx @@ -3,6 +3,7 @@ import ReactMarkdown from "react-markdown"; import lbry from "lbry.js"; import lbryuri from "lbryuri.js"; import Video from "component/video"; +import TipLink from "component/tipLink"; import { Thumbnail } from "component/common"; import FilePrice from "component/filePrice"; import FileActions from "component/fileActions"; @@ -33,6 +34,13 @@ const FormatItem = props => { }; class FilePage extends React.PureComponent { + constructor(props) { + super(props); + this.state = { + showTipBox: false, + }; + } + componentDidMount() { this.fetchFileInfo(this.props); this.fetchCostInfo(this.props); @@ -54,6 +62,18 @@ class FilePage extends React.PureComponent { } } + handleTipShow() { + this.setState({ + showTipBox: true, + }); + } + + handleTipHide() { + this.setState({ + showTipBox: false, + }); + } + render() { const { claim, @@ -64,6 +84,8 @@ class FilePage extends React.PureComponent { rewardedContentClaimIds, } = this.props; + const { showTipBox } = this.state; + if (!claim || !metadata) { return ( {__("Empty claim or metadata info.")} @@ -111,7 +133,7 @@ class FilePage extends React.PureComponent { {!fileInfo || fileInfo.written_bytes <= 0 ? - {isRewardContent && {" "} } + {isRewardContent && {" "}} : null}

{title}

@@ -126,7 +148,10 @@ class FilePage extends React.PureComponent { : uriIndicator}
- +
@@ -137,11 +162,18 @@ class FilePage extends React.PureComponent { />
- {metadata + {metadata && !showTipBox ?
: ""} + {showTipBox + ? + : ""}