William O'Beirne b638b746de Custom Nodes - Final Touches (#501)
* Add warning about matching nodes, only allow one url:port combination of nodes.

* Fix up alert styling.

* Custom network form.

* Add custom network to redux store. Setup infrastructure for removal and display.

* Persist custom networks to LS, show them in display.

* Force chain id, make typing happy.

* Display custom networks in network dropdown.

* Fix form validation, purge unused custom networks.
2017-12-01 10:09:51 -06:00

121 lines
3.1 KiB
TypeScript

import React, { Component } from 'react';
import { connect } from 'react-redux';
import {
changeGasPrice as dChangeGasPrice,
changeLanguage as dChangeLanguage,
changeNodeIntent as dChangeNodeIntent,
addCustomNode as dAddCustomNode,
removeCustomNode as dRemoveCustomNode,
addCustomNetwork as dAddCustomNetwork,
TChangeGasPrice,
TChangeLanguage,
TChangeNodeIntent,
TAddCustomNode,
TRemoveCustomNode,
TAddCustomNetwork
} from 'actions/config';
import { AlphaAgreement, Footer, Header } from 'components';
import { AppState } from 'reducers';
import Notifications from './Notifications';
interface ReduxProps {
languageSelection: AppState['config']['languageSelection'];
node: AppState['config']['node'];
nodeSelection: AppState['config']['nodeSelection'];
isChangingNode: AppState['config']['isChangingNode'];
gasPriceGwei: AppState['config']['gasPriceGwei'];
customNodes: AppState['config']['customNodes'];
customNetworks: AppState['config']['customNetworks'];
latestBlock: AppState['config']['latestBlock'];
}
interface ActionProps {
changeLanguage: TChangeLanguage;
changeNodeIntent: TChangeNodeIntent;
changeGasPrice: TChangeGasPrice;
addCustomNode: TAddCustomNode;
removeCustomNode: TRemoveCustomNode;
addCustomNetwork: TAddCustomNetwork;
}
type Props = {
// FIXME
children: any;
} & ReduxProps &
ActionProps;
class TabSection extends Component<Props, {}> {
public render() {
const {
children,
// APP
node,
nodeSelection,
isChangingNode,
languageSelection,
gasPriceGwei,
customNodes,
customNetworks,
latestBlock,
changeLanguage,
changeNodeIntent,
changeGasPrice,
addCustomNode,
removeCustomNode,
addCustomNetwork
} = this.props;
const headerProps = {
languageSelection,
node,
nodeSelection,
isChangingNode,
gasPriceGwei,
customNodes,
customNetworks,
changeLanguage,
changeNodeIntent,
changeGasPrice,
addCustomNode,
removeCustomNode,
addCustomNetwork
};
return (
<div className="page-layout">
<main>
<Header {...headerProps} />
<div className="Tab container">{children}</div>
<Footer latestBlock={latestBlock} />
</main>
<Notifications />
<AlphaAgreement />
</div>
);
}
}
function mapStateToProps(state: AppState): ReduxProps {
return {
node: state.config.node,
nodeSelection: state.config.nodeSelection,
isChangingNode: state.config.isChangingNode,
languageSelection: state.config.languageSelection,
gasPriceGwei: state.config.gasPriceGwei,
customNodes: state.config.customNodes,
customNetworks: state.config.customNetworks,
latestBlock: state.config.latestBlock
};
}
export default connect(mapStateToProps, {
changeGasPrice: dChangeGasPrice,
changeLanguage: dChangeLanguage,
changeNodeIntent: dChangeNodeIntent,
addCustomNode: dAddCustomNode,
removeCustomNode: dRemoveCustomNode,
addCustomNetwork: dAddCustomNetwork
})(TabSection);