Moved the node networks computation to selectors.

This commit is contained in:
Filip Barl
2017-02-10 17:37:37 +01:00
parent 5bd8e8f690
commit b9ba83ffca
14 changed files with 122 additions and 104 deletions

View File

@@ -22,6 +22,7 @@ import NetworkSelector from './networks-selector';
import DebugToolbar, { showingDebugToolbar, toggleDebugToolbar } from './debug-toolbar';
import { getRouter, getUrlState } from '../utils/router-utils';
import { getActiveTopologyOptions } from '../utils/topology-utils';
import { availableNetworksSelector } from '../selectors/node-networks';
const BACKSPACE_KEY_CODE = 8;
const ENTER_KEY_CODE = 13;
@@ -151,7 +152,7 @@ function mapStateToProps(state) {
showingHelp: state.get('showingHelp'),
showingTroubleshootingMenu: state.get('showingTroubleshootingMenu'),
showingMetricsSelector: state.get('availableCanvasMetrics').count() > 0,
showingNetworkSelector: state.get('availableNetworks').count() > 0,
showingNetworkSelector: availableNetworksSelector(state).count() > 0,
showingTerminal: state.get('controlPipes').size > 0,
urlState: getUrlState(state)
};

View File

@@ -3,6 +3,7 @@ import { connect } from 'react-redux';
import classNames from 'classnames';
import { selectNetwork, showNetworks } from '../actions/app-actions';
import { availableNetworksSelector } from '../selectors/node-networks';
import NetworkSelectorItem from './network-selector-item';
class NetworkSelector extends React.Component {
@@ -51,7 +52,7 @@ class NetworkSelector extends React.Component {
function mapStateToProps(state) {
return {
availableNetworks: state.get('availableNetworks'),
availableNetworks: availableNetworksSelector(state),
showingNetworks: state.get('showingNetworks'),
pinnedNetwork: state.get('pinnedNetwork')
};