Clear transaction state on tab changes (#1852)
This commit is contained in:
parent
9817f9576f
commit
9bdeab2307
|
@ -3,7 +3,7 @@ import { DataFieldFactory } from 'components/DataFieldFactory';
|
||||||
import { SendButtonFactory } from 'components/SendButtonFactory';
|
import { SendButtonFactory } from 'components/SendButtonFactory';
|
||||||
import WalletDecrypt, { DISABLE_WALLETS } from 'components/WalletDecrypt';
|
import WalletDecrypt, { DISABLE_WALLETS } from 'components/WalletDecrypt';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { setToField, TSetToField } from 'actions/transaction';
|
import { resetTransactionRequested, TResetTransactionRequested } from 'actions/transaction';
|
||||||
import { resetWallet, TResetWallet } from 'actions/wallet';
|
import { resetWallet, TResetWallet } from 'actions/wallet';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { FullWalletOnly } from 'components/renderCbs';
|
import { FullWalletOnly } from 'components/renderCbs';
|
||||||
|
@ -13,11 +13,15 @@ import { ConfirmationModal } from 'components/ConfirmationModal';
|
||||||
import { TextArea } from 'components/ui';
|
import { TextArea } from 'components/ui';
|
||||||
|
|
||||||
interface DispatchProps {
|
interface DispatchProps {
|
||||||
setToField: TSetToField;
|
|
||||||
resetWallet: TResetWallet;
|
resetWallet: TResetWallet;
|
||||||
|
resetTransactionRequested: TResetTransactionRequested;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeployClass extends Component<DispatchProps> {
|
class DeployClass extends Component<DispatchProps> {
|
||||||
|
public componentDidMount() {
|
||||||
|
this.props.resetTransactionRequested();
|
||||||
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const makeContent = () => (
|
const makeContent = () => (
|
||||||
<main className="Deploy Tab-content-pane" role="main">
|
<main className="Deploy Tab-content-pane" role="main">
|
||||||
|
@ -93,6 +97,6 @@ class DeployClass extends Component<DispatchProps> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Deploy = connect(null, {
|
export const Deploy = connect(null, {
|
||||||
setToField,
|
resetWallet,
|
||||||
resetWallet
|
resetTransactionRequested
|
||||||
})(DeployClass);
|
})(DeployClass);
|
||||||
|
|
|
@ -8,7 +8,16 @@ import { GenerateTransaction } from 'components/GenerateTransaction';
|
||||||
import { AppState } from 'reducers';
|
import { AppState } from 'reducers';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { Fields } from './components';
|
import { Fields } from './components';
|
||||||
import { setDataField, TSetDataField } from 'actions/transaction';
|
import {
|
||||||
|
setDataField,
|
||||||
|
resetTransactionRequested,
|
||||||
|
TSetDataField,
|
||||||
|
TResetTransactionRequested,
|
||||||
|
TSetAsContractInteraction,
|
||||||
|
TSetAsViewAndSend,
|
||||||
|
setAsContractInteraction,
|
||||||
|
setAsViewAndSend
|
||||||
|
} from 'actions/transaction';
|
||||||
import { Data } from 'libs/units';
|
import { Data } from 'libs/units';
|
||||||
import { Input, Dropdown } from 'components/ui';
|
import { Input, Dropdown } from 'components/ui';
|
||||||
import { INode } from 'libs/nodes';
|
import { INode } from 'libs/nodes';
|
||||||
|
@ -23,6 +32,9 @@ interface StateProps {
|
||||||
interface DispatchProps {
|
interface DispatchProps {
|
||||||
showNotification: TShowNotification;
|
showNotification: TShowNotification;
|
||||||
setDataField: TSetDataField;
|
setDataField: TSetDataField;
|
||||||
|
resetTransactionRequested: TResetTransactionRequested;
|
||||||
|
setAsContractInteraction: TSetAsContractInteraction;
|
||||||
|
setAsViewAndSend: TSetAsViewAndSend;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OwnProps {
|
interface OwnProps {
|
||||||
|
@ -64,6 +76,15 @@ class InteractExplorerClass extends Component<Props, State> {
|
||||||
outputs: {}
|
outputs: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public componentDidMount() {
|
||||||
|
this.props.setAsContractInteraction();
|
||||||
|
this.props.resetTransactionRequested();
|
||||||
|
}
|
||||||
|
|
||||||
|
public componentWillUnmount() {
|
||||||
|
this.props.setAsViewAndSend();
|
||||||
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const { inputs, outputs, selectedFunction } = this.state;
|
const { inputs, outputs, selectedFunction } = this.state;
|
||||||
const contractFunctionsOptions = this.contractOptions();
|
const contractFunctionsOptions = this.contractOptions();
|
||||||
|
@ -296,5 +317,11 @@ export const InteractExplorer = connect(
|
||||||
to: getTo(state),
|
to: getTo(state),
|
||||||
dataExists: getDataExists(state)
|
dataExists: getDataExists(state)
|
||||||
}),
|
}),
|
||||||
{ showNotification, setDataField }
|
{
|
||||||
|
showNotification,
|
||||||
|
setDataField,
|
||||||
|
resetTransactionRequested,
|
||||||
|
setAsContractInteraction,
|
||||||
|
setAsViewAndSend
|
||||||
|
}
|
||||||
)(InteractExplorerClass);
|
)(InteractExplorerClass);
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
import translate from 'translations';
|
import translate from 'translations';
|
||||||
import { Interact } from './components/Interact';
|
import { Interact } from './components/Interact';
|
||||||
import { Deploy } from './components/Deploy';
|
import { Deploy } from './components/Deploy';
|
||||||
import {
|
|
||||||
setAsContractInteraction,
|
|
||||||
TSetAsContractInteraction,
|
|
||||||
setAsViewAndSend,
|
|
||||||
TSetAsViewAndSend
|
|
||||||
} from 'actions/transaction';
|
|
||||||
|
|
||||||
import TabSection from 'containers/TabSection';
|
import TabSection from 'containers/TabSection';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
@ -15,11 +8,6 @@ import { Switch, Route, Redirect, RouteComponentProps } from 'react-router';
|
||||||
import SubTabs from 'components/SubTabs';
|
import SubTabs from 'components/SubTabs';
|
||||||
import { RouteNotFound } from 'components/RouteNotFound';
|
import { RouteNotFound } from 'components/RouteNotFound';
|
||||||
|
|
||||||
interface DispatchProps {
|
|
||||||
setAsContractInteraction: TSetAsContractInteraction;
|
|
||||||
setAsViewAndSend: TSetAsViewAndSend;
|
|
||||||
}
|
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{
|
{
|
||||||
path: 'interact',
|
path: 'interact',
|
||||||
|
@ -31,14 +19,7 @@ const tabs = [
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
class Contracts extends Component<DispatchProps & RouteComponentProps<{}>> {
|
class Contracts extends Component<RouteComponentProps<{}>> {
|
||||||
public componentDidMount() {
|
|
||||||
this.props.setAsContractInteraction();
|
|
||||||
}
|
|
||||||
public componentWillUnmount() {
|
|
||||||
this.props.setAsViewAndSend();
|
|
||||||
}
|
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const { match, location, history } = this.props;
|
const { match, location, history } = this.props;
|
||||||
const currentPath = match.url;
|
const currentPath = match.url;
|
||||||
|
@ -65,4 +46,4 @@ class Contracts extends Component<DispatchProps & RouteComponentProps<{}>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(null, { setAsContractInteraction, setAsViewAndSend })(Contracts);
|
export default connect(null, {})(Contracts);
|
||||||
|
|
Loading…
Reference in New Issue