Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review spending cap screen #15919

Merged
merged 14 commits into from
Oct 5, 2022
Merged

Review spending cap screen #15919

merged 14 commits into from
Oct 5, 2022

Conversation

filipsekulic
Copy link
Contributor

@filipsekulic filipsekulic commented Sep 21, 2022

Explanation

Created a new screen - 'Review Spending Cap' screen.

More Information

Screenshots/Screencaps

Before

Before.mov

After

After.mov

Manual Testing Steps

BEFORE TESTING - in your .metamaskrc file, set TOKEN_ALLOWANCE_IMPROVEMENTS=1 and then start the app

  1. Open the Test Dapp: https://metamask.github.io/test-dapp/
  2. Under the section Send Tokens click on CREATE TOKEN
  3. Wait for the token to be created and then, under the same section, click on APPROVE TOKENS or APPROVE TOKENS WITHOUT GAS in order to see the newly created screen

To see how the screen looks like when the enhanced gas fee is enabled, go to Settings (Experimental tab) and enable it (Enable enhanced gas fee UI toggle).

@filipsekulic filipsekulic self-assigned this Sep 21, 2022
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@filipsekulic filipsekulic force-pushed the review-spending-cap-screen branch from ebfdfa5 to 087a947 Compare September 21, 2022 11:36
@metamaskbot
Copy link
Collaborator

Builds ready [e49ab08]
Page Load Metrics (1437 ± 89 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint881579260416200
domContentLoaded11691823142219192
load11691855143718689
domInteractive11691823142219192

highlights:

storybook

@filipsekulic filipsekulic force-pushed the review-spending-cap-screen branch from 9fd172f to df35fa8 Compare September 23, 2022 11:05
@metamaskbot
Copy link
Collaborator

Builds ready [d90bade]
Page Load Metrics (2179 ± 77 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint941887197388186
domContentLoaded18412458216016077
load18412458217916177
domInteractive18412458216016077

highlights:

storybook

@metamaskbot
Copy link
Collaborator

Builds ready [4d8ce74]
Page Load Metrics (2650 ± 191 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint983130456887426
domContentLoaded207931782641407195
load210031962650398191
domInteractive207931782641407195

highlights:

storybook

@mirjanaKukic
Copy link
Contributor

Verified by QA

@metamaskbot
Copy link
Collaborator

Builds ready [d588c5e]
Page Load Metrics (2540 ± 110 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint91152119178
domContentLoaded221529552519224107
load221529822540230110
domInteractive221529552519224107

highlights:

storybook

@filipsekulic filipsekulic force-pushed the review-spending-cap-screen branch from 3582ed4 to 6c593ba Compare September 28, 2022 08:09
@filipsekulic filipsekulic marked this pull request as ready for review September 28, 2022 09:06
@filipsekulic filipsekulic requested a review from a team as a code owner September 28, 2022 09:06
@metamaskbot
Copy link
Collaborator

Builds ready [6c593ba]
Page Load Metrics (2481 ± 209 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint882141323115
domContentLoaded186435532460434208
load193735532481435209
domInteractive186435532460434208

highlights:

storybook

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice work!! Great use of UI components and clean CSS. I'm just dealing with a minor bug and and issue with the full screen view

Minor: Copy to clipboard state seems to be shared between the components here

copytoclipboard.mov

When I approve tokens my MetaMask opens in full screen and when I use the open in explorer it does open but it doesn't change window. Not sure how one might fix this is there a way to change windows?

explorer.not.swapping.on.full.screen.mov

Maybe a way we can set the href instead of opening it with javascript and using the attr target="_blank"? Not sure how to do this just spit balling...

Screen Shot 2022-09-28 at 9 10 23 AM

ui/pages/token-allowance/token-allowance.js Outdated Show resolved Hide resolved
Comment on lines +29 to +38
export default function ContractDetailsModal({
onClose,
tokenName,
tokenAddress,
toAddress,
chainId,
rpcPrefs,
origin,
siteImage,
}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add these props to the args in storybook so it doesn't break? Seems to be working nicely on develop See github pages storybook

Screen Shot 2022-09-28 at 8 54 25 AM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really need to add storybook checks to the CI 😅 I have a ticket will try get to it this week 🙏

</Box>
);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we could get a story for this component? I know it's going to take a lot of mock data but if it's not too much overhead I think it could add a lot of value!

@filipsekulic filipsekulic force-pushed the review-spending-cap-screen branch from d276b10 to 6ce3438 Compare September 29, 2022 16:07
@filipsekulic
Copy link
Contributor Author

filipsekulic commented Sep 29, 2022

Hey @georgewrmarshall! Good catch! 🙌
I fixed everything you mentioned except two things that I suppose were there before.
I am not sure why on your computer it opens up the app in the full-screen view. You can check the attached video and see that on my computer it works fine. Also, I would like to mention that one of my colleagues has the same issue as you in different scenarios. He firstly saw this issue before this PR was created.
Regarding the opening link in a new tab from the full-screen view, you can also check it from the attached video. There you can see that this issue is existing and was there before. I suppose it can be fixed somehow by changing the Button component that is being used throughout the app.

Screen.Recording.2022-09-29.at.18.02.50.mov

@metamaskbot
Copy link
Collaborator

Builds ready [6ce3438]
Page Load Metrics (2359 ± 128 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint912410252498239
domContentLoaded193229102352260125
load193229262359267128
domInteractive193229102352260125

highlights:

storybook

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work!

@metamaskbot
Copy link
Collaborator

Builds ready [984fdfb]
Page Load Metrics (2225 ± 71 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint86139104146
domContentLoaded19412524219614067
load20042643222514971
domInteractive19412524219614067

highlights:

storybook

Comment on lines 39 to 47
&__card,
&__card--no-border {
display: flex;
flex-flow: column;
border-bottom: 1px solid var(--color-border-default);
position: relative;
padding-inline-start: 24px;
padding-inline-end: 24px;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these styles can be achieved with props on the box component. Please remove any styles that can be expressed as props to avoid duplicating styles in our styelsheet. @georgewrmarshall we should probably create an issue for adding padding/margin inline-start and linline-end support to box.

Copy link
Contributor

@georgewrmarshall georgewrmarshall Oct 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice spotting. Roger that! I will create an issue *edit #16077

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here: db22c9f

Comment on lines 325 to 331
const renderFullDetails = () => {
return (
<Box
display={DISPLAY.FLEX}
flexDirection={FLEX_DIRECTION.COLUMN}
alignItems={ALIGN_ITEMS.CENTER}
className="token-allowance-container__full-tx-content"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't create functions that render more of the tree inside of functional components. Either render it inline in the component or extract it to a new component. When you reach for this it is a good sign that you need to break down your component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here: db22c9f

Comment on lines 146 to 162
const renderApproveContentCard = ({
showHeader = true,
symbol,
title,
showEdit,
showAdvanceGasFeeOptions = false,
onEditClick,
content,
footer,
noBorder,
}) => {
return (
<Box
className={classnames({
'token-allowance-container__card': !noBorder,
'token-allowance-container__card--no-border': noBorder,
})}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions that render things are all their own react components that you are creating inside of a react component. We do not want this pattern to exist in the code base. Extract these things to their own files / components even if they will not be reused. In this case it is used at least twice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here: db22c9f

Copy link
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have stories for approve content card now, but not a blocker.

@filipsekulic
Copy link
Contributor Author

It would be nice to have stories for approve content card now, but not a blocker.

I'll then add the missing storybook in the following PR where this token allowance improvements feature will be fully completed.

@metamaskbot
Copy link
Collaborator

Builds ready [7382be0]
Page Load Metrics (2210 ± 72 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint89138105136
domContentLoaded18992507219714168
load18992594221015172
domInteractive18992507219714168

highlights:

storybook

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @brad-decker now that the ApproveContentCard is a separate component it would be nice to get a story for it. But I see you have addressed that comment so not a blocker. Nice work 👍

Comment on lines +220 to +240
showHeader: PropTypes.bool,
symbol: PropTypes.node,
title: PropTypes.string,
showEdit: PropTypes.bool,
showAdvanceGasFeeOptions: PropTypes.bool,
onEditClick: PropTypes.func,
footer: PropTypes.node,
noBorder: PropTypes.bool,
supportsEIP1559V2: PropTypes.bool,
renderTransactionDetailsContent: PropTypes.bool,
renderDataContent: PropTypes.bool,
isMultiLayerFeeNetwork: PropTypes.bool,
ethTransactionTotal: PropTypes.string,
nativeCurrency: PropTypes.string,
fullTxData: PropTypes.object,
hexTransactionTotal: PropTypes.string,
fiatTransactionTotal: PropTypes.string,
currentCurrency: PropTypes.string,
isSetApproveForAll: PropTypes.bool,
isApprovalOrRejection: PropTypes.bool,
data: PropTypes.string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PropType descriptions would be nice here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna squash and merge, @filipsekulic please add those prop type descriptions in the same pr you mentioned above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed 👍

@brad-decker brad-decker merged commit a993509 into develop Oct 5, 2022
@brad-decker brad-decker deleted the review-spending-cap-screen branch October 5, 2022 19:48
@github-actions github-actions bot locked and limited conversation to collaborators Oct 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create "Review/Revoke Spending Cap" screen
5 participants