From a017a1bae088b5c32ad4a2196af064ec398ee9eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Oliv=C3=A9?= Date: Tue, 16 May 2023 17:44:08 +0200 Subject: [PATCH] [MMI] Added note to trader code fencing (#18051) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added note to trader code fencing * Started adding code fences in signature-request * Finished code fencing * Improving code * adds check and runs prettier * Fixed storybook and code fences bundle * Added missing dependency * updates fences * fewer lines * undo previously merged PR * ran lavamoat auto * adds test * prettier --------- Co-authored-by: António Regadas Co-authored-by: Antonio Regadas Co-authored-by: Brad Decker --- app/_locales/en/messages.json | 9 +++ ...onfirm-page-container-content.component.js | 38 ++++++++++++ .../confirm-page-container.component.js | 9 +++ .../__snapshots__/note-to-trader.test.js.snap | 58 +++++++++++-------- .../note-to-trader/note-to-trader.js | 54 ++++++++--------- .../confirm-transaction-base.component.js | 50 +++++++++++++++- .../confirm-transaction-base.container.js | 24 ++++++++ .../confirm-transaction-base.test.js | 28 +++++++++ 8 files changed, 218 insertions(+), 52 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 7de080a2d..aaea04cff 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -2519,6 +2519,12 @@ "notEnoughGas": { "message": "Not enough gas" }, + "note": { + "message": "Note" + }, + "notePlaceholder": { + "message": "The approver will see this note when approving the transaction at the custodian." + }, "notifications": { "message": "Notifications" }, @@ -4675,6 +4681,9 @@ "transactionHistoryTotalGasFee": { "message": "Total gas fee" }, + "transactionNote": { + "message": "Transaction note" + }, "transactionResubmitted": { "message": "Transaction resubmitted with estimated gas fee increased to $1 at $2" }, diff --git a/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-content.component.js b/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-content.component.js index 4a2480646..45772fe82 100644 --- a/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-content.component.js +++ b/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-content.component.js @@ -18,6 +18,9 @@ import { ConfirmPageContainerSummary, ConfirmPageContainerWarning } from '.'; export default class ConfirmPageContainerContent extends Component { static contextTypes = { t: PropTypes.func.isRequired, + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + trackEvent: PropTypes.func, + ///: END:ONLY_INCLUDE_IN }; static propTypes = { @@ -55,6 +58,9 @@ export default class ConfirmPageContainerContent extends Component { transactionType: PropTypes.string, isBuyableChain: PropTypes.bool, txData: PropTypes.object, + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + noteComponent: PropTypes.node, + ///: END:ONLY_INCLUDE_IN metaMetricsId: PropTypes.string, }; @@ -69,6 +75,14 @@ export default class ConfirmPageContainerContent extends Component { } ///: END:ONLY_INCLUDE_IN + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + const { noteComponent } = this.props; + + if (noteComponent) { + return this.renderTabs(); + } + ///: END:ONLY_INCLUDE_IN + if (detailsComponent && dataComponent) { return this.renderTabs(); } @@ -91,6 +105,9 @@ export default class ConfirmPageContainerContent extends Component { ///: BEGIN:ONLY_INCLUDE_IN(snaps) insightComponent, ///: END:ONLY_INCLUDE_IN + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + noteComponent, + ///: END:ONLY_INCLUDE_IN } = this.props; return ( @@ -102,6 +119,25 @@ export default class ConfirmPageContainerContent extends Component { > {detailsComponent} + { + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + noteComponent && ( + { + this.context.trackEvent({ + category: 'Note to trader', + event: 'Clicked on Notes tab on a transaction window', + }); + }} + > + {noteComponent} + + ) + ///: END:ONLY_INCLUDE_IN + } {dataComponent && ( {t('buyAsset', [nativeCurrency])} , + ///: END:ONLY_INCLUDE_IN ])} ) : ( diff --git a/ui/components/app/confirm-page-container/confirm-page-container.component.js b/ui/components/app/confirm-page-container/confirm-page-container.component.js index b4fb0e5d1..345ceb9e8 100644 --- a/ui/components/app/confirm-page-container/confirm-page-container.component.js +++ b/ui/components/app/confirm-page-container/confirm-page-container.component.js @@ -99,6 +99,9 @@ const ConfirmPageContainer = (props) => { txData, assetStandard, isApprovalOrRejection, + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + noteComponent, + ///: END:ONLY_INCLUDE_IN } = props; const t = useI18nContext(); @@ -238,6 +241,9 @@ const ConfirmPageContainer = (props) => { transactionType={currentTransaction.type} isBuyableChain={isBuyableChain} txData={txData} + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + noteComponent={noteComponent} + ///: END:ONLY_INCLUDE_IN /> )} {shouldDisplayWarning && errorKey === INSUFFICIENT_FUNDS_ERROR_KEY && ( @@ -398,6 +404,9 @@ ConfirmPageContainer.propTypes = { supportsEIP1559: PropTypes.bool, nativeCurrency: PropTypes.string, isApprovalOrRejection: PropTypes.bool, + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + noteComponent: PropTypes.node, + ///: END:ONLY_INCLUDE_IN }; export default ConfirmPageContainer; diff --git a/ui/components/institutional/note-to-trader/__snapshots__/note-to-trader.test.js.snap b/ui/components/institutional/note-to-trader/__snapshots__/note-to-trader.test.js.snap index 73e3cc2dd..86cb4de6e 100644 --- a/ui/components/institutional/note-to-trader/__snapshots__/note-to-trader.test.js.snap +++ b/ui/components/institutional/note-to-trader/__snapshots__/note-to-trader.test.js.snap @@ -3,33 +3,41 @@ exports[`NoteToTrader should render the Note to trader component 1`] = `
- -

- 9 - / - 280 -

-
-
- +
+ +

+ 9 + / + 280 +

+
+
+ +
+
`; diff --git a/ui/components/institutional/note-to-trader/note-to-trader.js b/ui/components/institutional/note-to-trader/note-to-trader.js index 5d8ba4c92..459ef49de 100644 --- a/ui/components/institutional/note-to-trader/note-to-trader.js +++ b/ui/components/institutional/note-to-trader/note-to-trader.js @@ -12,33 +12,35 @@ const NoteToTrader = (props) => { const { placeholder, maxLength, onChange, noteText, labelText } = props; return ( - <> - - - - {noteText.length}/{maxLength} - + + + + + + {noteText.length}/{maxLength} + + + +