Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Fixes brave/brave-browser#4773 - adds BAT token by default to accounts
Browse files Browse the repository at this point in the history
Adds file override task via gulp
  • Loading branch information
ryanml committed Jun 12, 2019
1 parent acc9e1e commit 7badd8d
Show file tree
Hide file tree
Showing 12 changed files with 6,507 additions and 0 deletions.
737 changes: 737 additions & 0 deletions brave/app/scripts/controllers/preferences.js

Large diffs are not rendered by default.

1,801 changes: 1,801 additions & 0 deletions brave/app/scripts/metamask-controller.js

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions brave/ui/app/components/app/dropdowns/components/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')

inherits(Menu, Component)
function Menu () { Component.call(this) }

Menu.prototype.render = function () {
const { className = '', children, isShowing } = this.props
return isShowing
? h('div', { className: `menu ${className}` }, children)
: h('noscript')
}

inherits(Item, Component)
function Item () { Component.call(this) }

Item.prototype.render = function () {
const {
icon,
children,
text,
className = '',
onClick,
isShowing
} = this.props

if (isShowing === false) {
return h('noscript')
}

const itemClassName = `menu__item ${className} ${onClick ? 'menu__item--clickable' : ''}`
const iconComponent = icon ? h('div.menu__item__icon', [icon]) : null
const textComponent = text ? h('div.menu__item__text', text) : null

return children
? h('div', { className: itemClassName, onClick }, children)
: h('div.menu__item', { className: itemClassName, onClick }, [ iconComponent, textComponent ]
.filter(d => Boolean(d))
)
}

inherits(Divider, Component)
function Divider () { Component.call(this) }

Divider.prototype.render = function () {
return h('div.menu__divider')
}

inherits(CloseArea, Component)
function CloseArea () { Component.call(this) }

CloseArea.prototype.render = function () {
return h('div.menu__close-area', { onClick: this.props.onClick })
}

module.exports = { Menu, Item, Divider, CloseArea }
69 changes: 69 additions & 0 deletions brave/ui/app/components/app/dropdowns/token-menu-dropdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const Component = require('react').Component
const PropTypes = require('prop-types')
const h = require('react-hyperscript')
const inherits = require('util').inherits
const connect = require('react-redux').connect
const actions = require('../../../store/actions')
const genAccountLink = require('etherscan-link').createAccountLink
const { Menu, Item, CloseArea } = require('./components/menu')

TokenMenuDropdown.contextTypes = {
t: PropTypes.func,
}

module.exports = connect(mapStateToProps, mapDispatchToProps)(TokenMenuDropdown)

function mapStateToProps (state) {
return {
network: state.metamask.network,
}
}

function mapDispatchToProps (dispatch) {
return {
showHideTokenConfirmationModal: (token) => {
dispatch(actions.showModal({ name: 'HIDE_TOKEN_CONFIRMATION', token }))
},
}
}


inherits(TokenMenuDropdown, Component)
function TokenMenuDropdown () {
Component.call(this)

this.onClose = this.onClose.bind(this)
}

TokenMenuDropdown.prototype.onClose = function (e) {
e.stopPropagation()
this.props.onClose()
}

TokenMenuDropdown.prototype.render = function () {
const { showHideTokenConfirmationModal } = this.props

return h(Menu, { className: 'token-menu-dropdown', isShowing: true }, [
h(CloseArea, {
onClick: this.onClose,
}),
h(Item, {
onClick: (e) => {
e.stopPropagation()
showHideTokenConfirmationModal(this.props.token)
this.props.onClose()
},
isShowing: (this.props.token.symbol !== 'BAT'),
text: this.context.t('hideToken'),
}),
h(Item, {
onClick: (e) => {
e.stopPropagation()
const url = genAccountLink(this.props.token.address, this.props.network)
global.platform.openWindow({ url })
this.props.onClose()
},
text: this.context.t('viewOnEtherscan'),
}),
])
}

0 comments on commit 7badd8d

Please sign in to comment.