Add new underscore-privates rule to @0xproject/tslint-config and fix lint errors
This commit is contained in:
committed by
Leonid Logvinov
parent
972e1675f6
commit
cb11aec84d
@@ -47,7 +47,7 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
|
||||
public static defaultProps: Partial<AssetPickerProps> = {
|
||||
tokenVisibility: TokenVisibility.ALL,
|
||||
};
|
||||
private dialogConfigsByAssetView: {[assetView: string]: DialogConfigs};
|
||||
private _dialogConfigsByAssetView: {[assetView: string]: DialogConfigs};
|
||||
constructor(props: AssetPickerProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
@@ -56,7 +56,7 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
|
||||
chosenTrackTokenAddress: undefined,
|
||||
isAddingTokenToTracked: false,
|
||||
};
|
||||
this.dialogConfigsByAssetView = {
|
||||
this._dialogConfigsByAssetView = {
|
||||
[AssetViews.ASSET_PICKER]: {
|
||||
title: 'Select token',
|
||||
isModal: false,
|
||||
@@ -74,19 +74,19 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
|
||||
<FlatButton
|
||||
key="noTracking"
|
||||
label="No"
|
||||
onTouchTap={this.onTrackConfirmationRespondedAsync.bind(this, false)}
|
||||
onTouchTap={this._onTrackConfirmationRespondedAsync.bind(this, false)}
|
||||
/>,
|
||||
<FlatButton
|
||||
key="yesTrack"
|
||||
label="Yes"
|
||||
onTouchTap={this.onTrackConfirmationRespondedAsync.bind(this, true)}
|
||||
onTouchTap={this._onTrackConfirmationRespondedAsync.bind(this, true)}
|
||||
/>,
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
public render() {
|
||||
const dialogConfigs: DialogConfigs = this.dialogConfigsByAssetView[this.state.assetView];
|
||||
const dialogConfigs: DialogConfigs = this._dialogConfigsByAssetView[this.state.assetView];
|
||||
return (
|
||||
<Dialog
|
||||
title={dialogConfigs.title}
|
||||
@@ -94,25 +94,25 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
|
||||
modal={dialogConfigs.isModal}
|
||||
open={this.props.isOpen}
|
||||
actions={dialogConfigs.actions}
|
||||
onRequestClose={this.onCloseDialog.bind(this)}
|
||||
onRequestClose={this._onCloseDialog.bind(this)}
|
||||
>
|
||||
{this.state.assetView === AssetViews.ASSET_PICKER &&
|
||||
this.renderAssetPicker()
|
||||
this._renderAssetPicker()
|
||||
}
|
||||
{this.state.assetView === AssetViews.NEW_TOKEN_FORM &&
|
||||
<NewTokenForm
|
||||
blockchain={this.props.blockchain}
|
||||
onNewTokenSubmitted={this.onNewTokenSubmitted.bind(this)}
|
||||
onNewTokenSubmitted={this._onNewTokenSubmitted.bind(this)}
|
||||
tokenByAddress={this.props.tokenByAddress}
|
||||
/>
|
||||
}
|
||||
{this.state.assetView === AssetViews.CONFIRM_TRACK_TOKEN &&
|
||||
this.renderConfirmTrackToken()
|
||||
this._renderConfirmTrackToken()
|
||||
}
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
private renderConfirmTrackToken() {
|
||||
private _renderConfirmTrackToken() {
|
||||
const token = this.props.tokenByAddress[this.state.chosenTrackTokenAddress];
|
||||
return (
|
||||
<TrackTokenConfirmation
|
||||
@@ -123,17 +123,17 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
|
||||
/>
|
||||
);
|
||||
}
|
||||
private renderAssetPicker() {
|
||||
private _renderAssetPicker() {
|
||||
return (
|
||||
<div
|
||||
className="clearfix flex flex-wrap"
|
||||
style={{overflowY: 'auto', maxWidth: 720, maxHeight: 356, marginBottom: 10}}
|
||||
>
|
||||
{this.renderGridTiles()}
|
||||
{this._renderGridTiles()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
private renderGridTiles() {
|
||||
private _renderGridTiles() {
|
||||
let isHovered;
|
||||
let tileStyles;
|
||||
const gridTiles = _.map(this.props.tokenByAddress, (token: Token, address: string) => {
|
||||
@@ -151,9 +151,9 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
|
||||
key={address}
|
||||
style={{width: TILE_DIMENSION, height: TILE_DIMENSION, ...tileStyles}}
|
||||
className="p2 mx-auto"
|
||||
onClick={this.onChooseToken.bind(this, address)}
|
||||
onMouseEnter={this.onToggleHover.bind(this, address, true)}
|
||||
onMouseLeave={this.onToggleHover.bind(this, address, false)}
|
||||
onClick={this._onChooseToken.bind(this, address)}
|
||||
onMouseEnter={this._onToggleHover.bind(this, address, true)}
|
||||
onMouseLeave={this._onToggleHover.bind(this, address, false)}
|
||||
>
|
||||
<div className="p1 center">
|
||||
<TokenIcon token={token} diameter={TOKEN_ICON_DIMENSION} />
|
||||
@@ -174,9 +174,9 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
|
||||
key={otherTokenKey}
|
||||
style={{width: TILE_DIMENSION, height: TILE_DIMENSION, ...tileStyles}}
|
||||
className="p2 mx-auto"
|
||||
onClick={this.onCustomAssetChosen.bind(this)}
|
||||
onMouseEnter={this.onToggleHover.bind(this, otherTokenKey, true)}
|
||||
onMouseLeave={this.onToggleHover.bind(this, otherTokenKey, false)}
|
||||
onClick={this._onCustomAssetChosen.bind(this)}
|
||||
onMouseEnter={this._onToggleHover.bind(this, otherTokenKey, true)}
|
||||
onMouseLeave={this._onToggleHover.bind(this, otherTokenKey, false)}
|
||||
>
|
||||
<div className="p1 center">
|
||||
<i
|
||||
@@ -190,19 +190,19 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
|
||||
}
|
||||
return gridTiles;
|
||||
}
|
||||
private onToggleHover(address: string, isHovered: boolean) {
|
||||
private _onToggleHover(address: string, isHovered: boolean) {
|
||||
const hoveredAddress = isHovered ? address : undefined;
|
||||
this.setState({
|
||||
hoveredAddress,
|
||||
});
|
||||
}
|
||||
private onCloseDialog() {
|
||||
private _onCloseDialog() {
|
||||
this.setState({
|
||||
assetView: AssetViews.ASSET_PICKER,
|
||||
});
|
||||
this.props.onTokenChosen(this.props.currentTokenAddress);
|
||||
}
|
||||
private onChooseToken(tokenAddress: string) {
|
||||
private _onChooseToken(tokenAddress: string) {
|
||||
const token = this.props.tokenByAddress[tokenAddress];
|
||||
if (token.isTracked) {
|
||||
this.props.onTokenChosen(tokenAddress);
|
||||
@@ -213,12 +213,12 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
|
||||
});
|
||||
}
|
||||
}
|
||||
private onCustomAssetChosen() {
|
||||
private _onCustomAssetChosen() {
|
||||
this.setState({
|
||||
assetView: AssetViews.NEW_TOKEN_FORM,
|
||||
});
|
||||
}
|
||||
private onNewTokenSubmitted(newToken: Token, newTokenState: TokenState) {
|
||||
private _onNewTokenSubmitted(newToken: Token, newTokenState: TokenState) {
|
||||
this.props.dispatcher.updateTokenStateByAddress({
|
||||
[newToken.address]: newTokenState,
|
||||
});
|
||||
@@ -229,14 +229,14 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
|
||||
});
|
||||
this.props.onTokenChosen(newToken.address);
|
||||
}
|
||||
private async onTrackConfirmationRespondedAsync(didUserAcceptTracking: boolean) {
|
||||
private async _onTrackConfirmationRespondedAsync(didUserAcceptTracking: boolean) {
|
||||
if (!didUserAcceptTracking) {
|
||||
this.setState({
|
||||
isAddingTokenToTracked: false,
|
||||
assetView: AssetViews.ASSET_PICKER,
|
||||
chosenTrackTokenAddress: undefined,
|
||||
});
|
||||
this.onCloseDialog();
|
||||
this._onCloseDialog();
|
||||
return;
|
||||
}
|
||||
this.setState({
|
||||
|
Reference in New Issue
Block a user