Files
weave-scope/client/app/scripts/components/topology-options.js
David Kaltschmidt 96aae9bc99 Migrate from Flux to Redux
* better state visibility
* pure state changes
* state debug panel (show: crtl-h, move: ctrl-w)
2016-04-27 17:21:46 +02:00

47 lines
1.3 KiB
JavaScript

import React from 'react';
import { connect } from 'react-redux';
import { getActiveTopologyOptions, getCurrentTopologyOptions } from '../utils/topology-utils';
import TopologyOptionAction from './topology-option-action';
class TopologyOptions extends React.Component {
renderOption(option) {
const { activeOptions, topologyId } = this.props;
const optionId = option.get('id');
const activeValue = activeOptions && activeOptions.has(optionId)
? activeOptions.get(optionId) : option.get('defaultValue');
return (
<div className="topology-option" key={optionId}>
<div className="topology-option-wrapper">
{option.get('options').map(item => <TopologyOptionAction
optionId={optionId} topologyId={topologyId} key={item.get('value')}
activeValue={activeValue} item={item} />)}
</div>
</div>
);
}
render() {
return (
<div className="topology-options">
{this.props.options && this.props.options.toIndexedSeq().map(
option => this.renderOption(option))}
</div>
);
}
}
function mapStateToProps(state) {
return {
options: getCurrentTopologyOptions(state),
topologyId: state.get('currentTopologyId'),
activeOptions: getActiveTopologyOptions(state)
};
}
export default connect(
mapStateToProps
)(TopologyOptions);