lbry-desktop/ui/modal/modalRevokeClaim/view.jsx

95 lines
2.8 KiB
React
Raw Normal View History

2018-09-26 19:48:07 +02:00
// @flow
import React from 'react';
import { Modal } from 'modal/modal';
import * as txnTypes from 'constants/transaction_types';
2017-10-27 21:42:54 +02:00
2018-09-26 19:48:07 +02:00
type Props = {
closeModal: () => void,
abandonClaim: (string, number) => void,
txid: string,
nout: number,
transactionItems: Array<Transaction>,
2018-09-26 19:48:07 +02:00
};
2017-10-27 21:42:54 +02:00
2018-09-26 19:48:07 +02:00
class ModalRevokeClaim extends React.PureComponent<Props> {
constructor() {
super();
2017-10-30 17:25:56 +01:00
2018-09-26 19:48:07 +02:00
(this: any).revokeClaim = this.revokeClaim.bind(this);
2017-11-01 21:23:30 +01:00
}
getButtonLabel(type: string) {
2018-09-26 19:48:07 +02:00
if (type === txnTypes.TIP) {
return 'Confirm Tip Unlock';
} else if (type === txnTypes.SUPPORT) {
return 'Confirm Support Revoke';
2017-11-01 21:23:30 +01:00
}
return 'Confirm Claim Revoke';
2017-11-01 21:23:30 +01:00
}
getMsgBody(type: string) {
2018-09-26 19:48:07 +02:00
if (type === txnTypes.TIP) {
2017-11-01 21:23:30 +01:00
return (
2018-09-26 19:48:07 +02:00
<React.Fragment>
<p>{__('Are you sure you want to unlock these credits?')}</p>
2017-11-01 21:23:30 +01:00
<p>
{__(
2018-09-26 19:48:07 +02:00
'These credits are permanently yours and can be unlocked at any time. Unlocking them allows you to spend them, but can hurt the performance of your content in lookups and search results. It is recommended you leave tips locked until you need or want to spend them.'
2017-11-01 21:23:30 +01:00
)}
</p>
2018-09-26 19:48:07 +02:00
</React.Fragment>
2017-11-01 21:23:30 +01:00
);
} else if (type === txnTypes.SUPPORT) {
return (
<React.Fragment>
<p>{__('Are you sure you want to remove this support?')}</p>
<p>
{__(
"These credits are permanently yours and can be removed at any time. Removing this support will reduce the claim's discoverability and return the LBC to your spendable balance."
)}
</p>
</React.Fragment>
);
}
return (
2018-09-26 19:48:07 +02:00
<React.Fragment>
<p>{__('Are you sure want to revoke this claim?')}</p>
<p>
{__(
2018-09-26 19:48:07 +02:00
'This will prevent others from resolving and accessing the content you published. It will return the LBC to your spendable balance, less a small transaction fee.'
)}
</p>
2019-12-28 20:39:08 +01:00
<p className="help error-text"> {__('FINAL WARNING: This action is permanent and cannot be undone.')}</p>
2018-09-26 19:48:07 +02:00
</React.Fragment>
);
2017-10-27 21:42:54 +02:00
}
2018-09-26 19:48:07 +02:00
revokeClaim() {
const { txid, nout } = this.props;
this.props.closeModal();
this.props.abandonClaim(txid, nout);
}
2017-10-27 21:42:54 +02:00
render() {
2017-11-01 21:23:30 +01:00
const { transactionItems, txid, nout, closeModal } = this.props;
2019-05-07 23:38:29 +02:00
const { type } = transactionItems.find(claim => claim.txid === txid && claim.nout === nout) || {};
2017-10-27 21:42:54 +02:00
return (
<Modal
isOpen
title={this.getButtonLabel(type)}
contentLabel={this.getButtonLabel(type)}
2017-10-27 21:42:54 +02:00
type="confirm"
2017-11-01 21:23:30 +01:00
confirmButtonLabel={this.getButtonLabel(type)}
2018-09-26 19:48:07 +02:00
onConfirmed={this.revokeClaim}
2017-10-27 21:42:54 +02:00
onAborted={closeModal}
>
2019-07-21 23:31:22 +02:00
<section>{this.getMsgBody(type)}</section>
2017-10-27 21:42:54 +02:00
</Modal>
);
}
}
export default ModalRevokeClaim;