All files / app/assets/javascripts/notebook/cells code.vue

100% Statements 8/8
87.5% Branches 7/8
100% Functions 4/4
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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  3x 3x                                         62x 61x     1x     62x     52x           195x                                              
<script>
import CodeOutput from './code/index.vue';
import OutputCell from './output/index.vue';
 
export default {
  name: 'CodeCell',
  components: {
    CodeOutput,
    OutputCell,
  },
  props: {
    cell: {
      type: Object,
      required: true,
    },
    codeCssClass: {
      type: String,
      required: false,
      default: '',
    },
  },
  computed: {
    rawInputCode() {
      if (this.cell.source && Array.isArray(this.cell.source)) {
        return this.cell.source.join('');
      }
 
      return this.cell.source || '';
    },
    hasOutput() {
      return this.cell.outputs.length;
    },
    outputs() {
      return this.cell.outputs;
    },
  },
};
</script>
 
<template>
  <div class="cell">
    <code-output
      :raw-code="rawInputCode"
      :count="cell.execution_count"
      :code-css-class="codeCssClass"
      type="input"
    />
    <output-cell
      v-if="hasOutput"
      :count="cell.execution_count"
      :outputs="outputs"
      :metadata="cell.metadata"
      :code-css-class="codeCssClass"
    />
  </div>
</template>
 
<style scoped>
.cell {
  flex-direction: column;
}
</style>