michellephung commented on a change in pull request #933: Update for changes to
_cluster_setup endpoint
URL: https://github.com/apache/couchdb-fauxton/pull/933#discussion_r128898045
##########
File path: app/addons/setup/setup.js
##########
@@ -22,11 +22,41 @@ var ConfirmButton = ReactComponents.ConfirmButton;
var ClusterConfiguredScreen = React.createClass({
+ getInitialState: function () {
+ return this.getStoreState();
+ },
+
+ getStoreState: function () {
+ return {
+ clusterState: setupStore.getClusterState()
+ };
+ },
+
+ componentDidMount: function () {
+ setupStore.on('change', this.onChange, this);
+ },
+
+ componentWillUnmount: function () {
+ setupStore.off('change', this.onChange);
+ },
+
+ onChange: function () {
+ this.setState(this.getStoreState());
+ },
render: function () {
+ var nodetype;
+
+ if (this.state.clusterState === 'cluster_finished') {
+ nodetype = 'clustered';
+ } else if (this.state.clusterState === 'single_node_enabled') {
+ nodetype = 'single';
+ } else {
+ nodetype = 'unknown state';
Review comment:
you can put this if-else in a function to clean up the render function.
like
var nodetype = this.getNodeType();
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services