mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix send warning dialog (#9321)
This change moves warning message from `add-recipient` component to `send-content`. Currently whenever provided address is a valid eth address `send-content` is rendered instead of `add-recipient` this is why warnings never popped up.
This commit is contained in:
parent
79d477009e
commit
cd86d00cb7
@ -19,7 +19,6 @@ export default class AddRecipient extends Component {
|
|||||||
updateSendTo: PropTypes.func,
|
updateSendTo: PropTypes.func,
|
||||||
ensResolution: PropTypes.string,
|
ensResolution: PropTypes.string,
|
||||||
toError: PropTypes.string,
|
toError: PropTypes.string,
|
||||||
toWarning: PropTypes.string,
|
|
||||||
ensResolutionError: PropTypes.string,
|
ensResolutionError: PropTypes.string,
|
||||||
addressBookEntryName: PropTypes.string,
|
addressBookEntryName: PropTypes.string,
|
||||||
contacts: PropTypes.array,
|
contacts: PropTypes.array,
|
||||||
@ -194,7 +193,7 @@ export default class AddRecipient extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderDialogs () {
|
renderDialogs () {
|
||||||
const { toError, toWarning, ensResolutionError, ensResolution } = this.props
|
const { toError, ensResolutionError, ensResolution } = this.props
|
||||||
const { t } = this.context
|
const { t } = this.context
|
||||||
const contacts = this.searchForContacts()
|
const contacts = this.searchForContacts()
|
||||||
const recents = this.searchForRecents()
|
const recents = this.searchForRecents()
|
||||||
@ -225,17 +224,6 @@ export default class AddRecipient extends Component {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toWarning) {
|
|
||||||
return (
|
|
||||||
<Dialog
|
|
||||||
type="warning"
|
|
||||||
className="send__error-dialog"
|
|
||||||
>
|
|
||||||
{t(toWarning)}
|
|
||||||
</Dialog>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,20 +159,6 @@ describe('AddRecipient Component', function () {
|
|||||||
assert.equal(dialog.length, 1)
|
assert.equal(dialog.length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render warning', function () {
|
|
||||||
wrapper.setProps({
|
|
||||||
addressBook: [],
|
|
||||||
query: 'yo',
|
|
||||||
toWarning: 'watchout',
|
|
||||||
})
|
|
||||||
|
|
||||||
const dialog = wrapper.find(Dialog)
|
|
||||||
|
|
||||||
assert.equal(dialog.props().type, 'warning')
|
|
||||||
assert.equal(dialog.props().children, 'watchout_t')
|
|
||||||
assert.equal(dialog.length, 1)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should not render error when ens resolved', function () {
|
it('should not render error when ens resolved', function () {
|
||||||
wrapper.setProps({
|
wrapper.setProps({
|
||||||
addressBook: [],
|
addressBook: [],
|
||||||
|
@ -19,14 +19,17 @@ export default class SendContent extends Component {
|
|||||||
showHexData: PropTypes.bool,
|
showHexData: PropTypes.bool,
|
||||||
contact: PropTypes.object,
|
contact: PropTypes.object,
|
||||||
isOwnedAccount: PropTypes.bool,
|
isOwnedAccount: PropTypes.bool,
|
||||||
|
warning: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
updateGas = (updateData) => this.props.updateGas(updateData)
|
updateGas = (updateData) => this.props.updateGas(updateData)
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
const { warning } = this.props
|
||||||
return (
|
return (
|
||||||
<PageContainerContent>
|
<PageContainerContent>
|
||||||
<div className="send-v2__form">
|
<div className="send-v2__form">
|
||||||
|
{ warning && this.renderWarning() }
|
||||||
{ this.maybeRenderAddContact() }
|
{ this.maybeRenderAddContact() }
|
||||||
<SendAssetRow />
|
<SendAssetRow />
|
||||||
<SendAmountRow updateGas={this.updateGas} />
|
<SendAmountRow updateGas={this.updateGas} />
|
||||||
@ -61,4 +64,18 @@ export default class SendContent extends Component {
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderWarning () {
|
||||||
|
const { t } = this.context
|
||||||
|
const { warning } = this.props
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
type="warning"
|
||||||
|
className="send__error-dialog"
|
||||||
|
>
|
||||||
|
{t(warning)}
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,4 +83,16 @@ describe('SendContent Component', function () {
|
|||||||
assert(PageContainerContentChild.childAt(1).is(SendAssetRow))
|
assert(PageContainerContentChild.childAt(1).is(SendAssetRow))
|
||||||
assert(PageContainerContentChild.childAt(1).find('send-v2__asset-dropdown__single-asset'), true)
|
assert(PageContainerContentChild.childAt(1).find('send-v2__asset-dropdown__single-asset'), true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should render warning', function () {
|
||||||
|
wrapper.setProps({
|
||||||
|
warning: 'watchout',
|
||||||
|
})
|
||||||
|
|
||||||
|
const dialog = wrapper.find(Dialog).at(0)
|
||||||
|
|
||||||
|
assert.equal(dialog.props().type, 'warning')
|
||||||
|
assert.equal(dialog.props().children, 'watchout_t')
|
||||||
|
assert.equal(dialog.length, 1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -324,26 +324,26 @@ export default class SendTransactionScreen extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderAddRecipient () {
|
renderAddRecipient () {
|
||||||
const { toError, toWarning } = this.state
|
const { toError } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AddRecipient
|
<AddRecipient
|
||||||
updateGas={({ to, amount, data } = {}) => this.updateGas({ to, amount, data })}
|
updateGas={({ to, amount, data } = {}) => this.updateGas({ to, amount, data })}
|
||||||
query={this.state.query}
|
query={this.state.query}
|
||||||
toError={toError}
|
toError={toError}
|
||||||
toWarning={toWarning}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSendContent () {
|
renderSendContent () {
|
||||||
const { history, showHexData } = this.props
|
const { history, showHexData } = this.props
|
||||||
|
const { toWarning } = this.state
|
||||||
|
|
||||||
return [
|
return [
|
||||||
<SendContent
|
<SendContent
|
||||||
key="send-content"
|
key="send-content"
|
||||||
updateGas={({ to, amount, data } = {}) => this.updateGas({ to, amount, data })}
|
updateGas={({ to, amount, data } = {}) => this.updateGas({ to, amount, data })}
|
||||||
showHexData={showHexData}
|
showHexData={showHexData}
|
||||||
|
warning={toWarning}
|
||||||
/>,
|
/>,
|
||||||
<SendFooter key="send-footer" history={history} />,
|
<SendFooter key="send-footer" history={history} />,
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user