From 7595458caa4b401423e9eda893233bf584a32556 Mon Sep 17 00:00:00 2001 From: jessop Date: Thu, 12 Mar 2020 20:56:02 -0400 Subject: [PATCH] make user type channel name to abandon channel --- static/app-strings.json | 6 ++- ui/constants/transaction_types.js | 1 + ui/modal/modalRevokeClaim/view.jsx | 72 ++++++++++++++++-------------- 3 files changed, 45 insertions(+), 34 deletions(-) diff --git a/static/app-strings.json b/static/app-strings.json index 283069342..8b626981f 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -1041,5 +1041,9 @@ "view all claims": "view all claims", "Top claims at lbry://%name%": "Top claims at lbry://%name%", "Last Updated": "Last Updated", - "Total Publishes": "Total Publishes" + "Total Publishes": "Total Publishes", + "Almost there": "Almost there", + "Are you sure you want to delete this channel?": "Are you sure you want to delete this channel?", + "Are you sure? Type %name% to confirm that you wish to delete the channel.": "Are you sure? Type %name% to confirm that you wish to delete the channel.", + "You're about to permanently delete a channel. Content published under this channel will be orphaned and their signing channel invalid. Content sync programs using this channel will fail.": "You're about to permanently delete a channel. Content published under this channel will be orphaned and their signing channel invalid. Content sync programs using this channel will fail." } diff --git a/ui/constants/transaction_types.js b/ui/constants/transaction_types.js index 8da75f1e7..5043473d6 100644 --- a/ui/constants/transaction_types.js +++ b/ui/constants/transaction_types.js @@ -1,2 +1,3 @@ export const TIP = 'tip'; export const SUPPORT = 'support'; +export const CHANNEL = 'channel'; diff --git a/ui/modal/modalRevokeClaim/view.jsx b/ui/modal/modalRevokeClaim/view.jsx index 7d0ba1698..190094491 100644 --- a/ui/modal/modalRevokeClaim/view.jsx +++ b/ui/modal/modalRevokeClaim/view.jsx @@ -1,6 +1,7 @@ // @flow -import React from 'react'; +import React, { useState } from 'react'; import { Modal } from 'modal/modal'; +import { FormField } from 'component/common/form'; import * as txnTypes from 'constants/transaction_types'; type Props = { @@ -11,14 +12,12 @@ type Props = { transactionItems: Array, }; -class ModalRevokeClaim extends React.PureComponent { - constructor() { - super(); +export default function ModalRevokeClaim(props: Props) { + const { transactionItems, txid, nout, closeModal } = props; + const { type, claim_name: name } = transactionItems.find(claim => claim.txid === txid && claim.nout === nout) || {}; + const [channelName, setChannelName] = useState(''); - (this: any).revokeClaim = this.revokeClaim.bind(this); - } - - getButtonLabel(type: string) { + function getButtonLabel(type: string) { if (type === txnTypes.TIP) { return 'Confirm Tip Unlock'; } else if (type === txnTypes.SUPPORT) { @@ -27,7 +26,7 @@ class ModalRevokeClaim extends React.PureComponent { return 'Confirm Claim Revoke'; } - getMsgBody(type: string) { + function getMsgBody(type: string, name: string) { if (type === txnTypes.TIP) { return ( @@ -50,7 +49,20 @@ class ModalRevokeClaim extends React.PureComponent {

); + } else if (type === txnTypes.CHANNEL) { + return ( + +

+ {__( + "You're about to permanently delete a channel. Content published under this channel will be orphaned and their signing channel invalid. Content sync programs using this channel will fail." + )} +

+

{__('Are you sure? Type %name% to confirm that you wish to delete the channel.', { name })}

+ setChannelName(e.target.value)} /> +
+ ); } + return (

{__('Are you sure want to revoke this claim?')}

@@ -64,31 +76,25 @@ class ModalRevokeClaim extends React.PureComponent { ); } - revokeClaim() { - const { txid, nout } = this.props; + function revokeClaim() { + const { txid, nout } = props; - this.props.closeModal(); - this.props.abandonClaim(txid, nout); + props.closeModal(); + props.abandonClaim(txid, nout); } - render() { - const { transactionItems, txid, nout, closeModal } = this.props; - const { type } = transactionItems.find(claim => claim.txid === txid && claim.nout === nout) || {}; - - return ( - -
{this.getMsgBody(type)}
-
- ); - } + return ( + +
{getMsgBody(type, name)}
+
+ ); } - -export default ModalRevokeClaim;