Merge pull request #810 from 0xProject/feature/wesbite/remove-add-balance
Remove increase balance link from balance_bounded_input component
This commit is contained in:
@@ -103,7 +103,6 @@ export class EthWethConversionDialog extends React.Component<
|
||||
shouldCheckAllowance={false}
|
||||
onChange={this._onValueChange.bind(this)}
|
||||
amount={this.state.value}
|
||||
onVisitBalancesPageClick={this.props.onCancelled}
|
||||
/>
|
||||
) : (
|
||||
<EthAmountInput
|
||||
@@ -112,7 +111,6 @@ export class EthWethConversionDialog extends React.Component<
|
||||
onChange={this._onValueChange.bind(this)}
|
||||
shouldCheckBalance={true}
|
||||
shouldShowIncompleteErrs={this.state.shouldShowIncompleteErrs}
|
||||
onVisitBalancesPageClick={this.props.onCancelled}
|
||||
/>
|
||||
)}
|
||||
<div className="pt1" style={{ fontSize: 12 }}>
|
||||
|
||||
@@ -80,7 +80,6 @@ export class SendDialog extends React.Component<SendDialogProps, SendDialogState
|
||||
shouldCheckAllowance={false}
|
||||
onChange={this._onValueChange.bind(this)}
|
||||
amount={this.state.value}
|
||||
onVisitBalancesPageClick={this.props.onCancelled}
|
||||
lastForceTokenStateRefetch={this.props.lastForceTokenStateRefetch}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -3,9 +3,8 @@ import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
import TextField from 'material-ui/TextField';
|
||||
import * as React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { RequiredLabel } from 'ts/components/ui/required_label';
|
||||
import { ValidatedBigNumberCallback, WebsitePaths } from 'ts/types';
|
||||
import { ValidatedBigNumberCallback } from 'ts/types';
|
||||
import { utils } from 'ts/utils/utils';
|
||||
|
||||
interface BalanceBoundedInputProps {
|
||||
@@ -18,8 +17,6 @@ interface BalanceBoundedInputProps {
|
||||
shouldShowIncompleteErrs?: boolean;
|
||||
shouldCheckBalance: boolean;
|
||||
validate?: (amount: BigNumber) => React.ReactNode;
|
||||
onVisitBalancesPageClick?: () => void;
|
||||
shouldHideVisitBalancesLink?: boolean;
|
||||
isDisabled?: boolean;
|
||||
shouldShowErrs?: boolean;
|
||||
shouldShowUnderline?: boolean;
|
||||
@@ -35,7 +32,6 @@ interface BalanceBoundedInputState {
|
||||
export class BalanceBoundedInput extends React.Component<BalanceBoundedInputProps, BalanceBoundedInputState> {
|
||||
public static defaultProps: Partial<BalanceBoundedInputProps> = {
|
||||
shouldShowIncompleteErrs: false,
|
||||
shouldHideVisitBalancesLink: false,
|
||||
isDisabled: false,
|
||||
shouldShowErrs: true,
|
||||
hintText: 'amount',
|
||||
@@ -124,38 +120,11 @@ export class BalanceBoundedInput extends React.Component<BalanceBoundedInputProp
|
||||
return 'Cannot be zero';
|
||||
}
|
||||
if (this.props.shouldCheckBalance && amount.gt(balance)) {
|
||||
return <span>Insufficient balance. {this._renderIncreaseBalanceLink()}</span>;
|
||||
return <span>Insufficient balance.</span>;
|
||||
}
|
||||
const errMsg = _.isUndefined(this.props.validate) ? undefined : this.props.validate(amount);
|
||||
return errMsg;
|
||||
}
|
||||
private _renderIncreaseBalanceLink(): React.ReactNode {
|
||||
if (this.props.shouldHideVisitBalancesLink) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const increaseBalanceText = 'Increase balance';
|
||||
const linkStyle = {
|
||||
cursor: 'pointer',
|
||||
color: colors.darkestGrey,
|
||||
textDecoration: 'underline',
|
||||
display: 'inline',
|
||||
};
|
||||
if (_.isUndefined(this.props.onVisitBalancesPageClick)) {
|
||||
return (
|
||||
<Link to={`${WebsitePaths.Portal}/balances`} style={linkStyle}>
|
||||
{increaseBalanceText}
|
||||
</Link>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div onClick={this.props.onVisitBalancesPageClick} style={linkStyle}>
|
||||
{increaseBalanceText}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private _setAmountState(amount: string, balance: BigNumber, callback: () => void = _.noop): void {
|
||||
const errorMsg = this._validate(amount, balance);
|
||||
this.props.onErrorMsgChange(errorMsg);
|
||||
|
||||
@@ -14,9 +14,7 @@ interface EthAmountInputProps {
|
||||
onChange: ValidatedBigNumberCallback;
|
||||
onErrorMsgChange?: (errorMsg: React.ReactNode) => void;
|
||||
shouldShowIncompleteErrs: boolean;
|
||||
onVisitBalancesPageClick?: () => void;
|
||||
shouldCheckBalance: boolean;
|
||||
shouldHideVisitBalancesLink?: boolean;
|
||||
shouldShowErrs?: boolean;
|
||||
shouldShowUnderline?: boolean;
|
||||
style?: React.CSSProperties;
|
||||
@@ -46,8 +44,6 @@ export class EthAmountInput extends React.Component<EthAmountInputProps, EthAmou
|
||||
onErrorMsgChange={this.props.onErrorMsgChange}
|
||||
shouldCheckBalance={this.props.shouldCheckBalance}
|
||||
shouldShowIncompleteErrs={this.props.shouldShowIncompleteErrs}
|
||||
onVisitBalancesPageClick={this.props.onVisitBalancesPageClick}
|
||||
shouldHideVisitBalancesLink={this.props.shouldHideVisitBalancesLink}
|
||||
hintText={this.props.hintText}
|
||||
shouldShowErrs={this.props.shouldShowErrs}
|
||||
shouldShowUnderline={this.props.shouldShowUnderline}
|
||||
|
||||
@@ -21,7 +21,6 @@ interface TokenAmountInputProps {
|
||||
shouldCheckAllowance: boolean;
|
||||
onChange: ValidatedBigNumberCallback;
|
||||
onErrorMsgChange?: (errorMsg: React.ReactNode) => void;
|
||||
onVisitBalancesPageClick?: () => void;
|
||||
lastForceTokenStateRefetch: number;
|
||||
shouldShowErrs?: boolean;
|
||||
shouldShowUnderline?: boolean;
|
||||
@@ -88,7 +87,6 @@ export class TokenAmountInput extends React.Component<TokenAmountInputProps, Tok
|
||||
validate={this._validate.bind(this)}
|
||||
shouldCheckBalance={this.props.shouldCheckBalance}
|
||||
shouldShowIncompleteErrs={this.props.shouldShowIncompleteErrs}
|
||||
onVisitBalancesPageClick={this.props.onVisitBalancesPageClick}
|
||||
isDisabled={!this.state.isBalanceAndAllowanceLoaded}
|
||||
hintText={this.props.hintText}
|
||||
shouldShowErrs={this.props.shouldShowErrs}
|
||||
|
||||
Reference in New Issue
Block a user