summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/reports/grouped_test_report/components/modal.vue
blob: af93e5bc639dcf61c1775af65a0e31913adc34a4 (plain)
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
<script>
import { GlModal, GlLink, GlSprintf } from '@gitlab/ui';

import CodeBlock from '~/vue_shared/components/code_block.vue';
import { fieldTypes } from '../../constants';

export default {
  components: {
    CodeBlock,
    GlModal,
    GlLink,
    GlSprintf,
  },
  props: {
    visible: {
      type: Boolean,
      required: true,
    },
    title: {
      type: String,
      required: true,
    },
    modalData: {
      type: Object,
      required: true,
    },
  },
  computed: {
    filteredModalData() {
      // Filter out the properties that don't have a value
      return Object.fromEntries(
        Object.entries(this.modalData).filter((data) => Boolean(data[1].value)),
      );
    },
  },
  fieldTypes,
};
</script>
<template>
  <gl-modal
    :visible="visible"
    modal-id="modal-mrwidget-reports"
    :title="title"
    :hide-footer="true"
    @hide="$emit('hide')"
  >
    <div v-for="(field, key, index) in filteredModalData" :key="index" class="row gl-mt-3 gl-mb-3">
      <strong class="col-sm-3 text-right"> {{ field.text }}: </strong>

      <div class="col-sm-9 text-secondary">
        <code-block v-if="field.type === $options.fieldTypes.codeBlock" :code="field.value" />

        <gl-link
          v-else-if="field.type === $options.fieldTypes.link"
          :href="field.value.path"
          target="_blank"
        >
          {{ field.value.text }}
        </gl-link>

        <gl-sprintf
          v-else-if="field.type === $options.fieldTypes.seconds"
          :message="__('%{value} s')"
        >
          <template #value>{{ field.value }}</template>
        </gl-sprintf>

        <template v-else-if="field.type === $options.fieldTypes.text">
          {{ field.value }}
        </template>
      </div>
    </div>
  </gl-modal>
</template>