mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-27 04:46:10 +01:00
143a5c4a53
* If a transaction would revert/fail, 1. hide the gas estimate info. 2. Disable the confirm button. 3. All user to enable the confirm button anyways. 4. Do not show the default Transaction error message Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Always return a value for hasSimulationError Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Use primary button of action message Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove hasSimulationError from getErrorKey Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move confirm anyways logic to base component. Change message Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Disable edit if there's simulation error Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * hide confirm anyways button once clicked. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move Actionable Primary Action to flex-end Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix unit tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix nested ternary lint issues Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * add !confirmAnyways to conditions to show GasDetails. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * ConfirmAnyways should be read from state Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Rename tryAnywayOption Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove await tick Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint issue fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes after rebase Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * description should show that it's content being tested. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * If a transaction would revert/fail, 1. hide the gas estimate info. 2. Disable the confirm button. 3. All user to enable the confirm button anyways. 4. Do not show the default Transaction error message Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Always return a value for hasSimulationError Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Use primary button of action message Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove hasSimulationError from getErrorKey Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move confirm anyways logic to base component. Change message Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Disable edit if there's simulation error Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * hide confirm anyways button once clicked. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move Actionable Primary Action to flex-end Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix unit tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix nested ternary lint issues Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * add !confirmAnyways to conditions to show GasDetails. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * ConfirmAnyways should be read from state Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Rename tryAnywayOption Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove await tick Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint issue fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes after rebase Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * description should show that it's content being tested. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move simulation fails message inline with gas details component (#12705) * Move simulation fails message inline with gas details component * Remove old unit tests Co-authored-by: Dan Miller <danjm.com@gmail.com> * lint fix * use an XOR operation. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * The changes in this file are no longer needed because we hide the edit button now Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Co-authored-by: Dan Miller <danjm.com@gmail.com>
161 lines
4.6 KiB
JavaScript
161 lines
4.6 KiB
JavaScript
import React, { Component } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import classnames from 'classnames';
|
|
import { Tabs, Tab } from '../../../ui/tabs';
|
|
import ErrorMessage from '../../../ui/error-message';
|
|
import ActionableMessage from '../../../ui/actionable-message/actionable-message';
|
|
import { PageContainerFooter } from '../../../ui/page-container';
|
|
import { ConfirmPageContainerSummary, ConfirmPageContainerWarning } from '.';
|
|
|
|
export default class ConfirmPageContainerContent extends Component {
|
|
static contextTypes = {
|
|
t: PropTypes.func.isRequired,
|
|
};
|
|
|
|
static propTypes = {
|
|
action: PropTypes.string,
|
|
dataComponent: PropTypes.node,
|
|
detailsComponent: PropTypes.node,
|
|
errorKey: PropTypes.string,
|
|
errorMessage: PropTypes.string,
|
|
hasSimulationError: PropTypes.bool,
|
|
hideSubtitle: PropTypes.bool,
|
|
identiconAddress: PropTypes.string,
|
|
nonce: PropTypes.string,
|
|
subtitleComponent: PropTypes.node,
|
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
titleComponent: PropTypes.node,
|
|
warning: PropTypes.string,
|
|
origin: PropTypes.string.isRequired,
|
|
ethGasPriceWarning: PropTypes.string,
|
|
// Footer
|
|
onCancelAll: PropTypes.func,
|
|
onCancel: PropTypes.func,
|
|
cancelText: PropTypes.string,
|
|
onSubmit: PropTypes.func,
|
|
onConfirmAnyways: PropTypes.func,
|
|
submitText: PropTypes.string,
|
|
disabled: PropTypes.bool,
|
|
hideConfirmAnyways: PropTypes.bool,
|
|
unapprovedTxCount: PropTypes.number,
|
|
rejectNText: PropTypes.string,
|
|
hideTitle: PropTypes.boolean,
|
|
};
|
|
|
|
renderContent() {
|
|
const { detailsComponent, dataComponent } = this.props;
|
|
|
|
if (detailsComponent && dataComponent) {
|
|
return this.renderTabs();
|
|
}
|
|
return detailsComponent || dataComponent;
|
|
}
|
|
|
|
renderTabs() {
|
|
const { t } = this.context;
|
|
const { detailsComponent, dataComponent } = this.props;
|
|
|
|
return (
|
|
<Tabs>
|
|
<Tab
|
|
className="confirm-page-container-content__tab"
|
|
name={t('details')}
|
|
>
|
|
{detailsComponent}
|
|
</Tab>
|
|
<Tab className="confirm-page-container-content__tab" name={t('data')}>
|
|
{dataComponent}
|
|
</Tab>
|
|
</Tabs>
|
|
);
|
|
}
|
|
|
|
render() {
|
|
const {
|
|
action,
|
|
errorKey,
|
|
errorMessage,
|
|
hasSimulationError,
|
|
title,
|
|
titleComponent,
|
|
subtitleComponent,
|
|
hideSubtitle,
|
|
identiconAddress,
|
|
nonce,
|
|
detailsComponent,
|
|
dataComponent,
|
|
warning,
|
|
onCancelAll,
|
|
onCancel,
|
|
cancelText,
|
|
onSubmit,
|
|
submitText,
|
|
disabled,
|
|
unapprovedTxCount,
|
|
rejectNText,
|
|
origin,
|
|
ethGasPriceWarning,
|
|
hideTitle,
|
|
onConfirmAnyways,
|
|
hideConfirmAnyways,
|
|
} = this.props;
|
|
|
|
const primaryAction = hideConfirmAnyways
|
|
? null
|
|
: {
|
|
label: this.context.t('tryAnywayOption'),
|
|
onClick: onConfirmAnyways,
|
|
};
|
|
|
|
return (
|
|
<div className="confirm-page-container-content">
|
|
{warning ? <ConfirmPageContainerWarning warning={warning} /> : null}
|
|
{ethGasPriceWarning && (
|
|
<ConfirmPageContainerWarning warning={ethGasPriceWarning} />
|
|
)}
|
|
{hasSimulationError && (
|
|
<div className="confirm-page-container-content__error-container">
|
|
<ActionableMessage
|
|
type="danger"
|
|
primaryAction={primaryAction}
|
|
message={this.context.t('simulationErrorMessage')}
|
|
/>
|
|
</div>
|
|
)}
|
|
<ConfirmPageContainerSummary
|
|
className={classnames({
|
|
'confirm-page-container-summary--border':
|
|
!detailsComponent || !dataComponent,
|
|
})}
|
|
action={action}
|
|
title={title}
|
|
titleComponent={titleComponent}
|
|
subtitleComponent={subtitleComponent}
|
|
hideSubtitle={hideSubtitle}
|
|
identiconAddress={identiconAddress}
|
|
nonce={nonce}
|
|
origin={origin}
|
|
hideTitle={hideTitle}
|
|
/>
|
|
{this.renderContent()}
|
|
{(errorKey || errorMessage) && !hasSimulationError && (
|
|
<div className="confirm-page-container-content__error-container">
|
|
<ErrorMessage errorMessage={errorMessage} errorKey={errorKey} />
|
|
</div>
|
|
)}
|
|
<PageContainerFooter
|
|
onCancel={onCancel}
|
|
cancelText={cancelText}
|
|
onSubmit={onSubmit}
|
|
submitText={submitText}
|
|
disabled={disabled}
|
|
>
|
|
{unapprovedTxCount > 1 ? (
|
|
<a onClick={onCancelAll}>{rejectNText}</a>
|
|
) : null}
|
|
</PageContainerFooter>
|
|
</div>
|
|
);
|
|
}
|
|
}
|