mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-02 14:15:06 +01:00
badebe017f
* Add UnitInput component * Add CurrencyInput component * Add UserPreferencedCurrencyInput component * Add UserPreferencedCurrencyDisplay component * Add updatePreferences action * Add styles for CurrencyInput, CurrencyDisplay, and UnitInput * Update SettingsTab page with Primary Currency toggle * Refactor currency displays and inputs to use UserPreferenced displays and inputs * Add TokenInput component * Add UserPreferencedTokenInput component * Use TokenInput in the send screen * Fix unit tests * Fix e2e and integration tests * Remove send/CurrencyDisplay component * Replace diamond unicode character with Eth logo. Fix typos
111 lines
2.9 KiB
JavaScript
111 lines
2.9 KiB
JavaScript
import React, { Component } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import classnames from 'classnames'
|
|
import { Tabs, Tab } from '../../tabs'
|
|
import { ConfirmPageContainerSummary, ConfirmPageContainerWarning } from './'
|
|
import ErrorMessage from '../../error-message'
|
|
|
|
export default class ConfirmPageContainerContent extends Component {
|
|
static propTypes = {
|
|
action: PropTypes.string,
|
|
dataComponent: PropTypes.node,
|
|
detailsComponent: PropTypes.node,
|
|
errorKey: PropTypes.string,
|
|
errorMessage: PropTypes.string,
|
|
hideSubtitle: PropTypes.bool,
|
|
identiconAddress: PropTypes.string,
|
|
nonce: PropTypes.string,
|
|
assetImage: PropTypes.string,
|
|
subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
subtitleComponent: PropTypes.node,
|
|
summaryComponent: PropTypes.node,
|
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
titleComponent: PropTypes.node,
|
|
warning: PropTypes.string,
|
|
}
|
|
|
|
renderContent () {
|
|
const { detailsComponent, dataComponent } = this.props
|
|
|
|
if (detailsComponent && dataComponent) {
|
|
return this.renderTabs()
|
|
} else {
|
|
return detailsComponent || dataComponent
|
|
}
|
|
}
|
|
|
|
renderTabs () {
|
|
const { detailsComponent, dataComponent } = this.props
|
|
|
|
return (
|
|
<Tabs>
|
|
<Tab name="Details">
|
|
{ detailsComponent }
|
|
</Tab>
|
|
<Tab name="Data">
|
|
{ dataComponent }
|
|
</Tab>
|
|
</Tabs>
|
|
)
|
|
}
|
|
|
|
render () {
|
|
const {
|
|
action,
|
|
errorKey,
|
|
errorMessage,
|
|
title,
|
|
titleComponent,
|
|
subtitle,
|
|
subtitleComponent,
|
|
hideSubtitle,
|
|
identiconAddress,
|
|
nonce,
|
|
assetImage,
|
|
summaryComponent,
|
|
detailsComponent,
|
|
dataComponent,
|
|
warning,
|
|
} = this.props
|
|
|
|
return (
|
|
<div className="confirm-page-container-content">
|
|
{
|
|
warning && (
|
|
<ConfirmPageContainerWarning warning={warning} />
|
|
)
|
|
}
|
|
{
|
|
summaryComponent || (
|
|
<ConfirmPageContainerSummary
|
|
className={classnames({
|
|
'confirm-page-container-summary--border': !detailsComponent || !dataComponent,
|
|
})}
|
|
action={action}
|
|
title={title}
|
|
titleComponent={titleComponent}
|
|
subtitle={subtitle}
|
|
subtitleComponent={subtitleComponent}
|
|
hideSubtitle={hideSubtitle}
|
|
identiconAddress={identiconAddress}
|
|
nonce={nonce}
|
|
assetImage={assetImage}
|
|
/>
|
|
)
|
|
}
|
|
{ this.renderContent() }
|
|
{
|
|
(errorKey || errorMessage) && (
|
|
<div className="confirm-page-container-content__error-container">
|
|
<ErrorMessage
|
|
errorMessage={errorMessage}
|
|
errorKey={errorKey}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
</div>
|
|
)
|
|
}
|
|
}
|