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

Add token selection to the send screen #6445

Merged
merged 19 commits into from
Apr 17, 2019
Merged

Conversation

chikeichan
Copy link
Contributor

token

A couple UX adjustments i've made @cjeria @bdresser

  • Title of the screen will either be "Send Ether" or "Send Tokens", depending on the asset selection
  • Changing asset actually changes token selected on main screen as well.

@whymarrh
Copy link
Contributor

@chikeichan can we get this rebased on the latest develop?

this.setState({
isShowingDropdown: false,
}, () => {
this.context.metricsEvent({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danjm Added a metric event - can you verify that I have used the right category and things?

Note: I am tracking whether or not the user selected a Token or Ether, instead of tracking the exact token address. Erring on the side of privacy.

Copy link
Contributor

Choose a reason for hiding this comment

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

@chikeichan this is correct

In addition, when we first add a custom variable, we need to map it to a specific id in metamask-extension/ui/app/helpers/utils/metametrics.util.js

However there are some limitations on how we do that and before we add anymore custom variables I want to reorganize the code and provide clear inline documentation.

Your code can stay in this PR. But let's not do the additional changes to the metrics util in this PR. I will do them as part of #6453 which I've added to next sprint. I have made a not that references your comment/code.

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

Looks good overall. Left a few comments. The one about selecting between multiple tokens while editing is the only really important one.

selectedTokenAddress: action.value,
})
const newSend = extend(metamaskState.send)

if (metamaskState.send.editingTransactionId && !action.value) {
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 meant to handle the specific case of when we are editing a transaction and ETH is selected, correct?

I see in send-asset-row.component that we pass an empty string when ETH is selected. Perhaps instead of just !action.value, we could explicitly check action.value === ''. That way the reader of the code here knows that the value passed to the action was intentionally an empty string, and not just defaulting to undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed it to this.setSelectedToken() to invoke with no params, keeping it consistent with how it is call everywhere else in the app.

selectedTokenAddress: action.value,
})
const newSend = extend(metamaskState.send)

if (metamaskState.send.editingTransactionId && !action.value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about the case when a user has ETH + two or more tokens in the dropdown. Do we need to modify unapprovedTxs in state if, while editing a token transaction, a user switches it to a different token?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part is handled in ui/app/pages/send/send.component.js:L169. Would love a manual test from you to see if it works. I tested it with multiple tokens locally many times.

const selectedTokenAddress = selectedToken && selectedToken.address

if (selectedTokenAddress && prevTokenAddress !== selectedTokenAddress) {
updateSendTokenBalance({
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 use this.updateSendToken() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch! Updated

@@ -209,6 +225,7 @@ export default class SendTransactionScreen extends PersistentForm {
updateGas={(updateData) => this.updateGas(updateData)}
scanQrCode={_ => this.props.scanQrCode()}
showHexData={showHexData}
editingTransactionId={editingTransactionId}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to pass editingTransactionId here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch!


export default class SendContent extends Component {

static propTypes = {
updateGas: PropTypes.func,
scanQrCode: PropTypes.func,
showHexData: PropTypes.bool,
editingTransactionId: 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.

I don't think we need to include editingTransactionId in prop types here

@cjeria
Copy link
Contributor

cjeria commented Apr 15, 2019

@chikeichan I notice that the spacing between each form element is inconsistent. As per the design system, we have spacing variables defined starting with 0, 4px, 8px, 16px, 24px. and so on. I'm aware that we'll want this to display nicely in the extension viewport as well, so I'd suggest we go with an 8px spacing between form elements (form rows). Adding token selection will push down the transaction fee form element (not ideal) and will end up looking like this, but I think reducing the spacing (to 8px) will help here.

@cjeria
Copy link
Contributor

cjeria commented Apr 15, 2019

Two other thoughts:

  • We might want to consider opening a full screen tab when sending to remedy the lack of realestate in the extension viewport.
  • When we update the send flow with the address book, we'll get more realestate for the asset row.

@chikeichan
Copy link
Contributor Author

Going to address @cjeria comment regarding padding tomorrow.

For the comment on changing send screen, I think that's too big of a UX change, and it would affect send flow initiated from a Dapp.

@danjm
Copy link
Contributor

danjm commented Apr 16, 2019

@chikeichan I believe the suggestion about the send screen is to just open the extension in a browser tab when the user goes to the send screen. This is done, for example, in the onImport method of metamask-extension/ui/app/pages/unlock-page/unlock-page.container.js

@chikeichan
Copy link
Contributor Author

hmm.... I'm still not a big fan of introducing this change to the users. I think opening a new tab is a drastic UX change that we don't know if it's good or bad. Also, if it changes again in the near future when Address Book is shipped, we would be resetting users expectation when it comes to "what happen when I click on send" too many times within a short period of time.

A few suggestions, with a couple wild ones:

  • Perhaps we can adjust the size of the "Send" header? Now that there is an asset dropdown, the header text Send Ether/Send Token might not need to be as prominent.
  • Perhaps we can even put the Asset Dropdown INSIDE the header?
  • Or maybe we can use a modal for now, and change it to a dropdown when Address Book is launched.

@cjeria - what do you think 😃 ?

@bdresser
Copy link
Contributor

can we reduce the top & bottom padding of the Transaction Fee buttons? They're unnecessarily tall and I've always wondered why

from this (height 74px i think)
Screen Shot 2019-04-17 at 10 12 02 AM

to this (height 56 px)
Screen Shot 2019-04-17 at 10 12 54 AM

@danjm
Copy link
Contributor

danjm commented Apr 17, 2019

@cjeria @bdresser Adjusted the spacing between send form rows and reduced the height of the gas buttons

Screenshot from 2019-04-17 14-56-03

danjm
danjm previously approved these changes Apr 17, 2019
@cjeria
Copy link
Contributor

cjeria commented Apr 17, 2019

Nice catch @bdresser! Approved!

@bdresser
Copy link
Contributor

bdresser commented Apr 17, 2019

wait @danjm

  • where'd the top bar go? i think it's important to let people switch networks on this screen, I do it all the time nvm i see this is a screenshot from the full page view
  • looks like your ETH exchange rate isn't showing up -- make sure you leave extra vertical height in the gas buttons because they include a fiat conversion too

@danjm
Copy link
Contributor

danjm commented Apr 17, 2019

fixed @bdresser

Screenshot from 2019-04-17 16-01-58
Screenshot from 2019-04-17 16-01-48
Screenshot from 2019-04-17 16-01-12
Screenshot from 2019-04-17 16-01-06

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

Let's hold off on merging... I am seeing something weird while QAing on testnet

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.

5 participants