Merge pull request #5223 from whymarrh/tx-error-tooltips

Show transaction error message tooltips for statuses
feature/default_network_editable
Frankie 6 years ago committed by GitHub
commit a43e71693f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/scripts/controllers/transactions/tx-state-manager.js
  2. 2
      ui/app/components/selected-account/selected-account.component.js
  3. 87
      ui/app/components/tooltip-v2.js
  4. 5
      ui/app/components/transaction-list-item/transaction-list-item.component.js
  5. 10
      ui/app/components/transaction-status/transaction-status.component.js
  6. 2
      ui/app/components/wallet-view.js

@ -353,6 +353,7 @@ class TransactionStateManager extends EventEmitter {
const txMeta = this.getTx(txId) const txMeta = this.getTx(txId)
txMeta.err = { txMeta.err = {
message: err.toString(), message: err.toString(),
rpc: err.value,
stack: err.stack, stack: err.stack,
} }
this.updateTx(txMeta) this.updateTx(txMeta)

@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import copyToClipboard from 'copy-to-clipboard' import copyToClipboard from 'copy-to-clipboard'
import { addressSlicer } from '../../util' import { addressSlicer } from '../../util'
const Tooltip = require('../tooltip-v2.js') const Tooltip = require('../tooltip-v2.js').default
class SelectedAccount extends Component { class SelectedAccount extends Component {
state = { state = {

@ -1,33 +1,66 @@
const Component = require('react').Component import PropTypes from 'prop-types'
const h = require('react-hyperscript') import React, {PureComponent} from 'react'
const inherits = require('util').inherits import {Tooltip as ReactTippy} from 'react-tippy'
const ReactTippy = require('react-tippy').Tooltip
module.exports = Tooltip export default class Tooltip extends PureComponent {
static defaultProps = {
inherits(Tooltip, Component) arrow: true,
function Tooltip () { children: null,
Component.call(this) containerClassName: '',
} hideOnClick: false,
onHidden: null,
position: 'left',
size: 'small',
title: null,
trigger: 'mouseenter',
wrapperClassName: '',
}
Tooltip.prototype.render = function () { static propTypes = {
const props = this.props arrow: PropTypes.bool,
const { position, title, children, wrapperClassName, containerClassName, onHidden } = props children: PropTypes.node,
containerClassName: PropTypes.string,
onHidden: PropTypes.func,
position: PropTypes.oneOf([
'top',
'right',
'bottom',
'left',
]),
size: PropTypes.oneOf([
'small', 'regular', 'big',
]),
title: PropTypes.string,
trigger: PropTypes.any,
wrapperClassName: PropTypes.string,
}
return h('div', { render () {
className: wrapperClassName, const {arrow, children, containerClassName, position, size, title, trigger, onHidden, wrapperClassName } = this.props
}, [
h(ReactTippy, { if (!title) {
title, return (
position: position || 'left', <div className={wrapperClassName}>
trigger: 'mouseenter', {children}
hideOnClick: false, </div>
size: 'small', )
arrow: true, }
className: containerClassName,
onHidden,
}, children),
]) return (
<div className={wrapperClassName}>
<ReactTippy
className={containerClassName}
title={title}
position={position}
trigger={trigger}
hideOnClick={false}
size={size}
arrow={arrow}
onHidden={onHidden}
>
{children}
</ReactTippy>
</div>
)
}
} }

@ -131,6 +131,11 @@ export default class TransactionListItem extends PureComponent {
<TransactionStatus <TransactionStatus
className="transaction-list-item__status" className="transaction-list-item__status"
statusKey={transaction.status} statusKey={transaction.status}
title={(
(transaction.err && transaction.err.rpc)
? transaction.err.rpc.message
: transaction.err && transaction.err.message
)}
/> />
{ this.renderPrimaryCurrency() } { this.renderPrimaryCurrency() }
{ this.renderSecondaryCurrency() } { this.renderSecondaryCurrency() }

@ -1,6 +1,7 @@
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import classnames from 'classnames' import classnames from 'classnames'
import Tooltip from '../tooltip-v2'
import { import {
UNAPPROVED_STATUS, UNAPPROVED_STATUS,
REJECTED_STATUS, REJECTED_STATUS,
@ -29,6 +30,10 @@ const statusToTextHash = {
} }
export default class TransactionStatus extends PureComponent { export default class TransactionStatus extends PureComponent {
static defaultProps = {
title: null,
}
static contextTypes = { static contextTypes = {
t: PropTypes.func, t: PropTypes.func,
} }
@ -36,15 +41,18 @@ export default class TransactionStatus extends PureComponent {
static propTypes = { static propTypes = {
statusKey: PropTypes.string, statusKey: PropTypes.string,
className: PropTypes.string, className: PropTypes.string,
title: PropTypes.string,
} }
render () { render () {
const { className, statusKey } = this.props const { className, statusKey, title } = this.props
const statusText = this.context.t(statusToTextHash[statusKey] || statusKey) const statusText = this.context.t(statusToTextHash[statusKey] || statusKey)
return ( return (
<div className={classnames('transaction-status', className, statusToClassNameHash[statusKey])}> <div className={classnames('transaction-status', className, statusToClassNameHash[statusKey])}>
<Tooltip position="top" title={title}>
{ statusText } { statusText }
</Tooltip>
</div> </div>
) )
} }

@ -9,7 +9,7 @@ const classnames = require('classnames')
const { checksumAddress } = require('../util') const { checksumAddress } = require('../util')
const Identicon = require('./identicon') const Identicon = require('./identicon')
// const AccountDropdowns = require('./dropdowns/index.js').AccountDropdowns // const AccountDropdowns = require('./dropdowns/index.js').AccountDropdowns
const Tooltip = require('./tooltip-v2.js') const Tooltip = require('./tooltip-v2.js').default
const copyToClipboard = require('copy-to-clipboard') const copyToClipboard = require('copy-to-clipboard')
const actions = require('../actions') const actions = require('../actions')
const BalanceComponent = require('./balance-component') const BalanceComponent = require('./balance-component')

Loading…
Cancel
Save