couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From garrensmith <...@git.apache.org>
Subject [GitHub] couchdb-fauxton pull request: Changes page content moved to React
Date Wed, 04 Mar 2015 14:37:19 GMT
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/303#discussion_r25778339
  
    --- Diff: app/addons/documents/changes/components.react.jsx ---
    @@ -268,18 +271,169 @@ define([
       });
     
     
    +  var ChangesController = React.createClass({
    +    getInitialState: function () {
    +      return this.getState();
    +    },
    +
    +    getState: function () {
    +      return {
    +        changes: changesStore.getChanges(),
    +        databaseName: changesStore.getDatabaseName(),
    +        isShowingSubset: changesStore.isShowingSubset()
    +      };
    +    },
    +
    +    onChange: function () {
    +      this.setState(this.getState());
    +    },
    +
    +    componentDidMount: function () {
    +      changesStore.on('change', this.onChange, this);
    +    },
    +
    +    componentWillUnmount: function () {
    +      changesStore.off('change', this.onChange);
    +    },
    +
    +    showingSubsetMsg: function () {
    +      var msg = '';
    +      if (this.state.isShowingSubset) {
    +        var numChanges = this.state.changes.length;
    +        msg = <p className="changes-result-limit">Limiting results to latest <b>{numChanges}</b>
changes.</p>;
    +      }
    +      return msg;
    +    },
    +
    +    getRows: function () {
    +      return _.map(this.state.changes, function (change) {
    +        return <ChangeRow change={change} key={change.id} databaseName={this.state.databaseName}
/>;
    +      }, this);
    +    },
    +
    +    render: function () {
    +      return (
    +        <div className="js-changes-view">
    +          {this.showingSubsetMsg()}
    +          {this.getRows()}
    +        </div>
    +      );
    +    }
    +  });
    +
    +
    +  var ChangeRow = React.createClass({
    +    propTypes: function () {
    +      return {
    +        change: React.PropTypes.object,
    +        databaseName: React.PropTypes.string.isRequired
    +      };
    +    },
    +
    +    getInitialState: function () {
    +      return {
    +        codeVisible: false
    +      };
    +    },
    +
    +    toggleJSON: function (e) {
    +      e.preventDefault();
    +      this.setState({ codeVisible: !this.state.codeVisible });
    +    },
    +
    +    getChangesCode: function () {
    +      var json = '';
    +      if (this.state.codeVisible) {
    +        var code = {
    --- End diff --
    
    You could neaten this a bit by moving it into a function.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message