mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-31 17:31:27 +00:00
add unlock button nex to expandable credits button
This commit is contained in:
parent
aeeaaf6605
commit
2716d9441c
3 changed files with 28 additions and 5 deletions
|
@ -4,16 +4,21 @@ import {
|
||||||
makeSelectMetadataForUri,
|
makeSelectMetadataForUri,
|
||||||
makeSelectTagsForUri,
|
makeSelectTagsForUri,
|
||||||
makeSelectPendingAmountByUri,
|
makeSelectPendingAmountByUri,
|
||||||
|
makeSelectClaimIsMine,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
|
import { doOpenModal } from 'redux/actions/app';
|
||||||
import { selectUser } from 'redux/selectors/user';
|
import { selectUser } from 'redux/selectors/user';
|
||||||
import FileDescription from './view';
|
import FileDescription from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||||
metadata: makeSelectMetadataForUri(props.uri)(state),
|
metadata: makeSelectMetadataForUri(props.uri)(state),
|
||||||
user: selectUser(state),
|
user: selectUser(state),
|
||||||
tags: makeSelectTagsForUri(props.uri)(state),
|
tags: makeSelectTagsForUri(props.uri)(state),
|
||||||
pendingAmount: makeSelectPendingAmountByUri(props.uri)(state),
|
pendingAmount: makeSelectPendingAmountByUri(props.uri)(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, null)(FileDescription);
|
export default connect(select, {
|
||||||
|
doOpenModal,
|
||||||
|
})(FileDescription);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
import * as ICONS from 'constants/icons';
|
||||||
|
import * as MODALS from 'constants/modal_types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { formatCredits } from 'lbry-redux';
|
import { formatCredits } from 'lbry-redux';
|
||||||
|
@ -16,14 +18,17 @@ type Props = {
|
||||||
user: ?any,
|
user: ?any,
|
||||||
tags: any,
|
tags: any,
|
||||||
pendingAmount: number,
|
pendingAmount: number,
|
||||||
|
doOpenModal: (id: string, {}) => void,
|
||||||
|
claimIsMine: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
function FileDescription(props: Props) {
|
function FileDescription(props: Props) {
|
||||||
const { uri, claim, metadata, tags, pendingAmount } = props;
|
const { uri, claim, metadata, tags, pendingAmount, doOpenModal, claimIsMine } = props;
|
||||||
const [expanded, setExpanded] = React.useState(false);
|
const [expanded, setExpanded] = React.useState(false);
|
||||||
const [showCreditDetails, setShowCreditDetails] = React.useState(false);
|
const [showCreditDetails, setShowCreditDetails] = React.useState(false);
|
||||||
const amount = parseFloat(claim.amount) + parseFloat(pendingAmount || claim.meta.support_amount);
|
const amount = parseFloat(claim.amount) + parseFloat(pendingAmount || claim.meta.support_amount);
|
||||||
const formattedAmount = formatCredits(amount, 2, true);
|
const formattedAmount = formatCredits(amount, 2, true);
|
||||||
|
const hasSupport = claim && claim.meta && claim.meta.support_amount && Number(claim.meta.support_amount) > 0;
|
||||||
|
|
||||||
if (!claim || !metadata) {
|
if (!claim || !metadata) {
|
||||||
return <span className="empty">{__('Empty claim or metadata info.')}</span>;
|
return <span className="empty">{__('Empty claim or metadata info.')}</span>;
|
||||||
|
@ -54,9 +59,21 @@ function FileDescription(props: Props) {
|
||||||
<Button button="link" label={__('More')} onClick={() => setExpanded(!expanded)} />
|
<Button button="link" label={__('More')} onClick={() => setExpanded(!expanded)} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Button button="link" onClick={() => setShowCreditDetails(!showCreditDetails)}>
|
<div className="section__actions--no-margin">
|
||||||
<LbcSymbol postfix={showCreditDetails ? __('Hide') : formattedAmount} />
|
{claimIsMine && hasSupport && (
|
||||||
</Button>
|
<Button
|
||||||
|
button="link"
|
||||||
|
className="expandable__button"
|
||||||
|
icon={ICONS.UNLOCK}
|
||||||
|
onClick={() => {
|
||||||
|
doOpenModal(MODALS.LIQUIDATE_SUPPORTS, { uri });
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Button button="link" onClick={() => setShowCreditDetails(!showCreditDetails)}>
|
||||||
|
<LbcSymbol postfix={showCreditDetails ? __('Hide') : formattedAmount} />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{showCreditDetails && (
|
{showCreditDetails && (
|
||||||
|
|
|
@ -249,6 +249,7 @@ input-submit {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
margin-bottom: var(--spacing-m);
|
||||||
|
|
||||||
> * {
|
> * {
|
||||||
width: 33%;
|
width: 33%;
|
||||||
|
|
Loading…
Add table
Reference in a new issue