@@ -8,6 +8,7 @@ import classNames from 'classnames';
88import { Link } from 'react-polymorph/lib/components/Link' ;
99import { LinkSkin } from 'react-polymorph/lib/skins/simple/LinkSkin' ;
1010import CancelTransactionButton from './CancelTransactionButton' ;
11+ import { TransactionMetadataView } from './metadata/TransactionMetadataView' ;
1112import styles from './Transaction.scss' ;
1213import TransactionTypeIcon from './TransactionTypeIcon' ;
1314import adaSymbol from '../../../assets/images/ada-symbol.inline.svg' ;
@@ -46,6 +47,22 @@ const messages = defineMessages({
4647 defaultMessage : '!!!Transaction ID' ,
4748 description : 'Transaction ID.' ,
4849 } ,
50+ metadataLabel : {
51+ id : 'wallet.transaction.metadataLabel' ,
52+ defaultMessage : '!!!Transaction metadata' ,
53+ description : 'Transaction metadata label' ,
54+ } ,
55+ metadataDisclaimer : {
56+ id : 'wallet.transaction.metadataDisclaimer' ,
57+ defaultMessage :
58+ '!!!Transaction metadata is not moderated and may contain inappropriate content.' ,
59+ description : 'Transaction metadata disclaimer' ,
60+ } ,
61+ metadataConfirmationLabel : {
62+ id : 'wallet.transaction.metadataConfirmationLabel' ,
63+ defaultMessage : '!!!Show unmoderated content' ,
64+ description : 'Transaction metadata confirmation toggle' ,
65+ } ,
4966 conversionRate : {
5067 id : 'wallet.transaction.conversion.rate' ,
5168 defaultMessage : '!!!Conversion rate' ,
@@ -171,9 +188,11 @@ type Props = {
171188 isExpanded : boolean ,
172189 isRestoreActive : boolean ,
173190 isLastInList : boolean ,
191+ isShowingMetadata : boolean ,
174192 formattedWalletAmount : Function ,
175193 onDetailsToggled : ?Function ,
176194 onOpenExternalLink : Function ,
195+ onShowMetadata : ( ) => void ,
177196 getUrlByType : Function ,
178197 currentTimeFormat : string ,
179198 walletId : string ,
@@ -182,6 +201,7 @@ type Props = {
182201
183202type State = {
184203 showConfirmationDialog : boolean ,
204+ showUnmoderatedMetadata : boolean ,
185205} ;
186206
187207export default class Transaction extends Component < Props , State > {
@@ -191,8 +211,20 @@ export default class Transaction extends Component<Props, State> {
191211
192212 state = {
193213 showConfirmationDialog : false ,
214+ showUnmoderatedMetadata : false ,
194215 } ;
195216
217+ componentDidUpdate ( prevProps : Props , prevState : State ) {
218+ // Tell parent components that meta data was toggled
219+ if (
220+ ! prevState . showUnmoderatedMetadata &&
221+ this . state . showUnmoderatedMetadata &&
222+ this . props . onShowMetadata
223+ ) {
224+ this . props . onShowMetadata ( ) ;
225+ }
226+ }
227+
196228 toggleDetails ( ) {
197229 const { onDetailsToggled } = this . props ;
198230 if ( onDetailsToggled ) onDetailsToggled ( ) ;
@@ -310,6 +342,7 @@ export default class Transaction extends Component<Props, State> {
310342 const {
311343 data,
312344 isLastInList,
345+ isShowingMetadata,
313346 state,
314347 formattedWalletAmount,
315348 onOpenExternalLink,
@@ -532,6 +565,35 @@ export default class Transaction extends Component<Props, State> {
532565 />
533566 </ div >
534567 { this . renderCancelPendingTxnContent ( ) }
568+
569+ { data . metadata != null && (
570+ < div className = { styles . metadata } >
571+ < h2 > { intl . formatMessage ( messages . metadataLabel ) } </ h2 >
572+ { data . metadata &&
573+ ( this . state . showUnmoderatedMetadata ||
574+ isShowingMetadata ) ? (
575+ < TransactionMetadataView data = { data . metadata } />
576+ ) : (
577+ < >
578+ < p className = { styles . metadataDisclaimer } >
579+ { intl . formatMessage ( messages . metadataDisclaimer ) }
580+ </ p >
581+ < Link
582+ isUnderlined = { false }
583+ hasIconAfter = { false }
584+ underlineOnHover
585+ label = { intl . formatMessage (
586+ messages . metadataConfirmationLabel
587+ ) }
588+ onClick = { ( e ) => {
589+ e . preventDefault ( ) ;
590+ this . setState ( { showUnmoderatedMetadata : true } ) ;
591+ } }
592+ />
593+ </ >
594+ ) }
595+ </ div >
596+ ) }
535597 </ div >
536598 </ div >
537599 < SVGInline svg = { arrow } className = { arrowStyles } />
0 commit comments