All files / ee/app/assets/javascripts/analytics/productivity_analytics/components metric_column.vue

100% Statements 4/4
100% Branches 4/4
100% Functions 3/3
100% Lines 4/4

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  4x                                               5x     4x             27x                        
<script>
import { n__ } from '~/locale';
 
export default {
  props: {
    type: {
      type: String,
      required: true,
    },
    /**
     * With default null we will render a "-" in the last column as opposed to a numeric value
     */
    value: {
      type: Number,
      required: false,
      default: null,
    },
    label: {
      type: String,
      required: false,
      default: '',
    },
  },
  computed: {
    isNumber() {
      return typeof this.value === 'number';
    },
    unit() {
      return this.type === 'days_to_merge'
        ? n__('day', 'days', this.value)
        : n__('Time|hr', 'Time|hrs', this.value);
    },
  },
};
</script>
<template>
  <div class="metric-col">
    <span class="time">
      <template v-if="isNumber">
        {{ value }}
        <span> {{ unit }} </span>
      </template>
      <template v-else> &ndash; </template>
    </span>
    <span v-if="label" class="d-flex d-md-none text-secondary metric-label">{{ label }}</span>
  </div>
</template>