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 Filters tab moved to Re...
Date Wed, 18 Feb 2015 08:47:30 GMT
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/265#discussion_r24885981
  
    --- Diff: app/addons/documents/changes/components.react.jsx ---
    @@ -0,0 +1,244 @@
    +// Licensed under the Apache License, Version 2.0 (the "License"); you may not
    +// use this file except in compliance with the License. You may obtain a copy of
    +// the License at
    +//
    +//   http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing, software
    +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    +// License for the specific language governing permissions and limitations under
    +// the License.
    +
    +define([
    +  'react',
    +  'addons/documents/changes/actions',
    +  'addons/documents/changes/stores'
    +], function (React, Actions, Stores) {
    +
    +  var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
    +
    +
    +  // the top-level component for the Changes Filter section. Handles hiding/showing
    +  var ChangesHeader = React.createClass({
    +    getInitialState: function () {
    +      return {
    +        showTabContent: Stores.changesHeaderStore.isTabVisible()
    +      };
    +    },
    +
    +    onChange: function () {
    +      this.setState({
    +        showTabContent: Stores.changesHeaderStore.isTabVisible()
    +      });
    +    },
    +
    +    componentDidMount: function () {
    +      Stores.changesHeaderStore.on('change', this.onChange, this);
    +    },
    +
    +    componentWillUnmount: function () {
    +      Stores.changesHeaderStore.off('change', this.onChange);
    +    },
    +
    +    toggleFilterSection: function () {
    +      Actions.toggleTabVisibility();
    +    },
    +
    +    render: function () {
    +      var tabContent = '';
    +      if (this.state.showTabContent) {
    +        tabContent = <ChangesFilter key="changesFilterSection" />;
    +      }
    +
    +      return (
    +        <div className="changes-header-section">
    +          <ChangesHeaderTab onToggle={this.toggleFilterSection} />
    +          <ReactCSSTransitionGroup transitionName="toggleChangesFilter" component="div"
className="changes-tab-content">
    +            {tabContent}
    +          </ReactCSSTransitionGroup>
    +        </div>
    +      );
    +    }
    +  });
    +
    +
    +  var ChangesHeaderTab = React.createClass({
    +    propTypes: {
    +      onToggle: React.PropTypes.func.isRequired
    +    },
    +
    +    render: function () {
    +      return (
    +        <div className="dashboard-upper-menu">
    +          <ul className="nav nav-tabs" id="db-views-tabs-nav">
    +            <li>
    +              <a href="#filter" onClick={this.props.onToggle} data-bypass="true" data-toggle="tab">
    +                <i className="fonticon fonticon-plus"></i> Filter
    +              </a>
    +            </li>
    +          </ul>
    +        </div>
    +      );
    +    }
    +  });
    +
    +
    +  var ChangesFilter = React.createClass({
    +    getStoreState: function () {
    +      return {
    +        filters: Stores.changesFilterStore.getFilters()
    +      };
    +    },
    +
    +    onChange: function () {
    +      this.setState(this.getStoreState());
    +    },
    +
    +    componentDidMount: function () {
    +      Stores.changesFilterStore.on('change', this.onChange, this);
    +    },
    +
    +    componentWillUnmount: function () {
    +      Stores.changesFilterStore.off('change', this.onChange);
    +    },
    +
    +    getInitialState: function () {
    +      return this.getStoreState();
    +    },
    +
    +    getFilters: function () {
    +      return _.map(this.state.filters, function (filter) {
    +        return <Filter key={filter} label={filter} />;
    +      }, this);
    +    },
    +
    +    render: function () {
    +      var filters = this.getFilters();
    +
    +      return (
    +        <div className="tab-content">
    +          <div className="tab-pane active" ref="filterTab">
    +            <div className="changes-header js-filter">
    +              <AddFilterForm tooltip={this.props.tooltip} filter={this.state.filter}
onSubmit={this.submitForm} />
    +              <ul className="filter-list">{filters}</ul>
    +            </div>
    +          </div>
    +        </div>
    +      );
    +    }
    +  });
    +
    +
    +  var AddFilterForm = React.createClass({
    +    getInitialState: function () {
    +      return {
    +        filter: ''
    +      };
    +    },
    +
    +    getDefaultProps: function () {
    +      return {
    +        tooltip: ''
    +      };
    +    },
    +
    +    submitForm: function (e) {
    +      e.preventDefault();
    +      e.stopPropagation();
    +      if (_.isEmpty(this.state.filter)) {
    +        return;
    +      }
    +      Actions.addFilter(this.state.filter);
    --- End diff --
    
    This should also be a dumb component that just calls a callback on a submit form and not
an action directly.


---
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