Code coverage report for src/components/breadcrumb/index.cjsx

Statements: 76.36% (42 / 55)      Branches: 75% (15 / 20)      Functions: 72.73% (8 / 11)      Lines: 76.36% (42 / 55)      Ignored: none     

All files » src/components/breadcrumb/ » index.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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110                                                                         122× 122× 122× 122× 122× 11× 11×       122× 122× 122×     122×     122× 122×     149× 149× 149× 149× 123×   149× 123×   149×                 135× 135× 135× 27×       692× 692× 692× 692×                    
var Breadcrumb, BreadcrumbStatic, BreadcrumbTaskDynamic, React, StepPanel, TaskStepActions, TaskStepStore, TaskStore, ref;
 
React = require('react');
 
Breadcrumb = require('openstax-react-components').Breadcrumb;
 
StepPanel = require('../../helpers/policies').StepPanel;
 
ref = require('../../flux/task-step'), TaskStepActions = ref.TaskStepActions, TaskStepStore = ref.TaskStepStore;
 
TaskStore = require('../../flux/task').TaskStore;
 
BreadcrumbStatic = React.createClass({
  displayName: 'BreadcrumbStatic',
  componentWillMount: function() {
    return this.setStep(this.props);
  },
  setStep: function(props) {
    var crumb, step;
    crumb = props.crumb;
    step = crumb.data;
    if (crumb.type === 'step') {
      step = crumb.data;
    }
    return this.setState({
      step: step
    });
  },
  render: function() {
    var crumbProps, step;
    step = this.state.step;
    crumbProps = _.omit(this.props, 'step');
    if (_.isArray(step)) {
      step = _.first(step);
    }
    return React.createElement(Breadcrumb, React.__spread({}, crumbProps, {
      "step": step
    }));
  }
});
 
BreadcrumbTaskDynamic = React.createClass({
  displayName: 'BreadcrumbTaskDynamic',
  componentWillMount: function() {
    var crumb;
    crumb = this.props.crumb;
    this.setStep(this.props);
    TaskStepStore.on('step.completed', this.update);
    if (crumb.type === 'step' && TaskStepStore.isPlaceholder(crumb.data.id)) {
      TaskStepStore.on('step.completed', this.checkPlaceholder);
      return TaskStepStore.on('step.loaded', this.update);
    }
  },
  removeListeners: function() {
    TaskStepStore.off('step.completed', this.update);
    TaskStepStore.off('step.completed', this.checkPlaceholder);
    return TaskStepStore.off('step.loaded', this.update);
  },
  componentWillUnmount: function() {
    return this.removeListeners();
  },
  componentDidMount: function() {
    var base;
    return typeof (base = this.props).onMount === "function" ? base.onMount() : void 0;
  },
  setStep: function(props) {
    var canReview, crumb, step;
    crumb = props.crumb;
    step = crumb.data;
    if (crumb.type === 'step') {
      step = TaskStepStore.get(crumb.data.id);
    }
    if (crumb.type === 'step' && (step != null)) {
      canReview = StepPanel.canReview(step.id);
    }
    return this.setState({
      step: step,
      canReview: canReview
    });
  },
  checkPlaceholder: function() {
    var id, ref1, task_id;
    ref1 = this.props.crumb.data, task_id = ref1.task_id, id = ref1.id;
    if (!TaskStore.hasIncompleteCoreStepsIndexes(task_id)) {
      return TaskStepActions.load(id);
    }
  },
  update: function(id) {
    var crumb;
    crumb = this.props.crumb;
    if (crumb.data.id === id) {
      return this.setStep(this.props);
    }
  },
  render: function() {
    var crumbProps, step;
    step = this.state.step;
    crumbProps = _.omit(this.props, 'step');
    return React.createElement(Breadcrumb, React.__spread({}, crumbProps, {
      "step": step
    }));
  }
});
 
module.exports = {
  BreadcrumbTaskDynamic: BreadcrumbTaskDynamic,
  BreadcrumbStatic: BreadcrumbStatic
};