All files / app/assets/javascripts/vue_shared/components papa_parse_alert.vue

0% Statements 0/2
100% Branches 0/0
0% Functions 0/3
0% Lines 0/2

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                                                                                         
<script>
import { GlAlert } from '@gitlab/ui';
import { s__ } from '~/locale';
 
export default {
  components: {
    GlAlert,
  },
  i18n: {
    genericErrorMessage: s__('CsvParser|Failed to render the CSV file for the following reasons:'),
    MissingQuotes: s__('CsvParser|Quoted field unterminated'),
    InvalidQuotes: s__('CsvParser|Trailing quote on quoted field is malformed'),
    UndetectableDelimiter: s__('CsvParser|Unable to auto-detect delimiter; defaulted to ","'),
    TooManyFields: s__('CsvParser|Too many fields'),
    TooFewFields: s__('CsvParser|Too few fields'),
  },
  props: {
    papaParseErrors: {
      type: Array,
      required: false,
      default: () => [],
    },
  },
  computed: {
    errorMessages() {
      const errorMessages = this.papaParseErrors.map(
        (error) => this.$options.i18n[error.code] ?? error.message,
      );
      return new Set(errorMessages);
    },
  },
};
</script>
 
<template>
  <gl-alert variant="danger" :dismissible="false">
    {{ $options.i18n.genericErrorMessage }}
    <ul class="gl-mb-0!">
      <li v-for="error in errorMessages" :key="error">
        {{ error }}
      </li>
    </ul>
  </gl-alert>
</template>