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

Redesign approve screen #7271

Merged
merged 11 commits into from
Nov 5, 2019
Merged

Redesign approve screen #7271

merged 11 commits into from
Nov 5, 2019

Conversation

danjm
Copy link
Contributor

@danjm danjm commented Oct 10, 2019

Fixes #7165

This PR implements a redesign of the approve screen

Demo video here: https://streamable.com/5xnt7

@metamaskbot
Copy link
Collaborator

Builds ready [9ceec92]

<div className="edit-approval-permission">
<div className="edit-approval-permission__header">
<div className="edit-approval-permission__title">
Edit Permission
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be a localized message, along with the other text in this component

Spend limit permission
</div>
<div className="edit-approval-permission__edit-section__description">
Allow Uniswap to withdraw and spend up to the following amount:
Copy link
Member

Choose a reason for hiding this comment

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

The "Uniswap" here should be replaced with the name for whichever site is requesting approval.
The same goes for the "Spend limit requested by Uniswap" message below

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

I encountered this PropType warning upon opening the Approve screen:

Warning: Failed prop type: Invalid prop `decimals` of type `string` supplied to `ConfirmApprove`, expected `number`.
    in ConfirmApprove (created by TokenTrackerWrappedComponent)
    in TokenTrackerWrappedComponent (created by Connect(TokenTrackerWrappedComponent))
    in Connect(TokenTrackerWrappedComponent) (created by Route)
    in Route (created by withRouter(Connect(TokenTrackerWrappedComponent)))
    in withRouter(Connect(TokenTrackerWrappedComponent)) (created by Route)
    in Route (created by ConfirmTransaction)
    in Switch (created by ConfirmTransaction)
    in ConfirmTransaction (created by Connect(ConfirmTransaction))
    in Connect(ConfirmTransaction) (created by Route)
    in Route (created by withRouter(Connect(ConfirmTransaction)))
    in withRouter(Connect(ConfirmTransaction)) (created by Route)
    in Route (created by Authenticated)
    in Authenticated (created by Connect(Authenticated))
    in Connect(Authenticated) (created by Routes)
    in Switch (created by Routes)
    in div (created by Routes)
    in div (created by Routes)
    in Routes (created by Connect(Routes))
    in Connect(Routes) (created by Route)
    in Route (created by withRouter(Connect(Routes)))
    in withRouter(Connect(Routes)) (created by Index)
    in I18nProvider (created by Connect(I18nProvider))
    in Connect(I18nProvider) (created by Route)
    in Route (created by withRouter(Connect(I18nProvider)))
    in withRouter(Connect(I18nProvider)) (created by Index)
    in MetaMetricsProvider (created by Connect(MetaMetricsProvider))
    in Connect(MetaMetricsProvider) (created by Route)
    in Route (created by withRouter(Connect(MetaMetricsProvider)))
    in withRouter(Connect(MetaMetricsProvider)) (created by Index)
    in Router (created by HashRouter)
    in HashRouter (created by Index)
    in Provider (created by Index)
    in Index

I also noticed that the popup itself had a few UI issues:
approve

  • Why is there a vertical scrollbar? It looks like a horizontal scrollbar appears upon opening the transaction details
  • The account is missing from the top-left
  • It seems like there should be more whitespace above and below the network (it looks a bit cramped). Maybe this would be fixed indirectly after adding the account though.

})}>
{
tokenAmount < tokenBalance
? -'Proposed Approval Limit'
Copy link
Member

Choose a reason for hiding this comment

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

is that - intended? I think this'd come out as NaN

<div className="edit-approval-permission__edit-section__option">
<div
className="edit-approval-permission__edit-section__radio-button"
onClick={() => this.setState({ selectedOption: 'unlimited' })}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: 'unlimited' and 'custom' should probably be enums. It seems like a good place to use an enum anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll upgrade this from a nitpick to an issue: there are a lot of 'unlimited' and 'custom' scattered throughout this component, we should move those into constants at a minimum

Copy link
Contributor

Choose a reason for hiding this comment

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

We could also maybe even put this.state.selectedOption === 'custom' and this.state.selectedOption === 'unlimited' into state so that a lot of those instances could be read from state, e.g.

<div className={classnames({
  'edit-approval-permission__edit-section__radio-button-outline': !this.state.selectedOptionIsUnlimited,
  'edit-approval-permission__edit-section__radio-button-outline--selected': this.state.selectedOptionIsUnlimited
})} />

submitType="primary"
contentClass="edit-approval-permission-modal-content"
containerClass="edit-approval-permission-modal-container"
submitDisabled={ this.state.customSpendLimit === this.props.customTokenAmount }
Copy link
Member

Choose a reason for hiding this comment

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

This prevents saving Unlimited if the custom amount selected is equal to the custom token amount.

e.g.

  1. Set a custom spend limit of 5, then save it
  2. Edit permissions again
  3. Set a custom limit of 5
  4. Select 'Unlimited'

Save is then disabled, when it should be enabled.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, the onSubmit handler doesn't seem to allow setting 'Unlimited' anyway 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

This is indeed curious


const mapDispatchToProps = dispatch => {
return {
resetAccount: () => dispatch(resetAccount()),
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing you forgot to update this part

Copy link
Member

Choose a reason for hiding this comment

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

This still looks wrong - resetAcocunt isn't sued in the EditApprovalPermission component

<div className="edit-approval-permission__edit-section__option">
<div
className="edit-approval-permission__edit-section__radio-button"
onClick={() => this.setState({ selectedOption: 'unlimited' })}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll upgrade this from a nitpick to an issue: there are a lot of 'unlimited' and 'custom' scattered throughout this component, we should move those into constants at a minimum

<div className="edit-approval-permission__edit-section__option">
<div
className="edit-approval-permission__edit-section__radio-button"
onClick={() => this.setState({ selectedOption: 'unlimited' })}
Copy link
Contributor

Choose a reason for hiding this comment

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

We could also maybe even put this.state.selectedOption === 'custom' and this.state.selectedOption === 'unlimited' into state so that a lot of those instances could be read from state, e.g.

<div className={classnames({
  'edit-approval-permission__edit-section__radio-button-outline': !this.state.selectedOptionIsUnlimited,
  'edit-approval-permission__edit-section__radio-button-outline--selected': this.state.selectedOptionIsUnlimited
})} />

submitType="primary"
contentClass="edit-approval-permission-modal-content"
containerClass="edit-approval-permission-modal-container"
submitDisabled={ this.state.customSpendLimit === this.props.customTokenAmount }
Copy link
Contributor

Choose a reason for hiding this comment

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

This is indeed curious

return (
<div className="confirm-approve-content__transaction-details-content">
<div className="confirm-approve-content__small-text">
A fee is associated with this request. Learn why
Copy link
Contributor

Choose a reason for hiding this comment

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

The text in this component should also be localizable

@danjm
Copy link
Contributor Author

danjm commented Nov 4, 2019

@Gudahtt @whymarrh all issues have been addressed:

792bacd Ensure first param passed to calcTokenValue in confirm-approve.util is the correct type
1dde6ff Ensure decimals prop passted to confirm-approve.component is correct type
bb5eeee Fix height of confirm-approval popup
f12010f Allow setting of approval amount to unlimited in edit-approval-permission
edceee2 Set option to custom on input change in edit-approval-permission
c886c68 Use state prop bool for unlimited vs custom check in edit-approval-permission
db0f9eb Show account in header of approve screen
3e0e22b Add translations to approve screen components

@danjm
Copy link
Contributor Author

danjm commented Nov 4, 2019

Video of editing permission amount: https://streamable.com/m6sdt

@metamaskbot
Copy link
Collaborator

Builds ready [1d35558]

@metamaskbot
Copy link
Collaborator

Builds ready [5de79be]

Copy link
Contributor

@whymarrh whymarrh left a comment

Choose a reason for hiding this comment

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

Seems legit

@danjm danjm merged commit 2673eef into develop Nov 5, 2019
@whymarrh whymarrh deleted the new-approve-screens branch November 6, 2019 13:47
Gudahtt added a commit that referenced this pull request Nov 19, 2019
The units for the amounts shown on the approve screen in the
transaction fee section were missing. It appears that they were present
in an early version of the approve screen (#7271) but they got lost
somewhere along the way.
Gudahtt added a commit that referenced this pull request Nov 19, 2019
The units for the amounts shown on the approve screen in the
transaction fee section were missing. It appears that they were present
in an early version of the approve screen (#7271) but they got lost
somewhere along the way.
Gudahtt added a commit that referenced this pull request Nov 19, 2019
The units for the amounts shown on the approve screen in the
transaction fee section were missing. It appears that they were present
in an early version of the approve screen (#7271) but they got lost
somewhere along the way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Approve screen
4 participants