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

100% Statements 5/5
50% Branches 1/2
100% Functions 4/4
100% Lines 5/5

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    5x                                                           76x     76x   76x     76x                                  
<script>
import CodeBlockHighlighted from '~/vue_shared/components/code_block_highlighted.vue';
import Prompt from '../prompt.vue';
 
export default {
  name: 'CodeOutput',
  components: {
    CodeBlockHighlighted,
    Prompt,
  },
  props: {
    count: {
      type: Number,
      required: false,
      default: 0,
    },
    type: {
      type: String,
      required: true,
    },
    rawCode: {
      type: String,
      required: true,
    },
    metadata: {
      type: Object,
      default: () => ({}),
      required: false,
    },
  },
  computed: {
    code() {
      return this.rawCode;
    },
    promptType() {
      const type = this.type.split('put')[0];
 
      return type.charAt(0).toUpperCase() + type.slice(1);
    },
    maxHeight() {
      return this.metadata.scrolled ? '20rem' : 'initial';
    },
  },
};
</script>
 
<template>
  <div :class="type">
    <prompt :type="promptType" :count="count" />
    <code-block-highlighted
      language="python"
      :code="code"
      :max-height="maxHeight"
      class="gl-border gl-p-4!"
    />
  </div>
</template>