Code coverage report for src/components/reference-book/page-shell.cjsx

Statements: 63.64% (14 / 22)      Branches: 33.33% (3 / 9)      Functions: 50% (3 / 6)      Lines: 63.64% (14 / 22)      Ignored: none     

All files » src/components/reference-book/ » page-shell.cjsx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66                                 43×                                         94×     54× 54× 54×                            
var Invalid, LoadableItem, React, ReferenceBookPage, ReferenceBookPageActions, ReferenceBookPageShell, ReferenceBookPageStore, _, ref;
 
React = require('react');
 
_ = require('underscore');
 
LoadableItem = require('../loadable-item');
 
ReferenceBookPage = require('./page');
 
Invalid = require('../index').Invalid;
 
ref = require('../../flux/reference-book-page'), ReferenceBookPageActions = ref.ReferenceBookPageActions, ReferenceBookPageStore = ref.ReferenceBookPageStore;
 
ReferenceBookPageShell = React.createClass({displayName: "ReferenceBookPageShell",
  propTypes: {
    cnxId: React.PropTypes.string.isRequired
  },
  getDefaultState: function() {
    return {
      previousPageProps: null
    };
  },
  componentWillReceiveProps: function(nextProps) {
    return this.setState({
      previousPageProps: this.props
    });
  },
  isAnotherPage: function(previousPageProps, currentProps) {
    return (previousPageProps != null) && (previousPageProps.cnxId != null) && !_.isEqual(previousPageProps, currentProps);
  },
  renderLoading: function(previousPageProps, currentProps, refreshButton) {
    var loading;
    if (this.isAnotherPage(previousPageProps, currentProps)) {
      loading = React.createElement(ReferenceBookPage, React.__spread({}, previousPageProps, {
        "className": 'page-loading loadable is-loading'
      }), refreshButton);
    } else {
      loading = React.createElement("div", {
        "className": 'loadable is-loading'
      }, "Loading... ", refreshButton);
    }
    return loading;
  },
  renderLoaded: function() {
    return React.createElement(ReferenceBookPage, React.__spread({}, this.props));
  },
  render: function() {
    var ref1;
    Eif (this.props.cnxId != null) {
      return React.createElement(LoadableItem, {
        "id": this.props.cnxId,
        "store": ReferenceBookPageStore,
        "actions": ReferenceBookPageActions,
        "renderLoading": _.partial(this.renderLoading, (ref1 = this.state) != null ? ref1.previousPageProps : void 0, this.props),
        "renderItem": this.renderLoaded
      });
    } else {
      return React.createElement(Invalid, null);
    }
  }
});
 
module.exports = ReferenceBookPageShell;