Welcome to mirror list, hosted at ThFree Co, Russian Federation.

request_selector.vue « components « performance_bar « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a46ac620f486a96c63d09edb16b971509d6de838 (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
75
76
<script>
import { GlPopover, GlSafeHtmlDirective } from '@gitlab/ui';
import { glEmojiTag } from '~/emoji';
import { n__ } from '~/locale';

export default {
  components: {
    GlPopover,
  },
  directives: {
    SafeHtml: GlSafeHtmlDirective,
  },
  props: {
    currentRequest: {
      type: Object,
      required: true,
    },
    requests: {
      type: Array,
      required: true,
    },
  },
  data() {
    return {
      currentRequestId: this.currentRequest.id,
    };
  },
  computed: {
    requestsWithWarnings() {
      return this.requests.filter((request) => request.hasWarnings);
    },
    warningMessage() {
      return n__(
        '%d request with warnings',
        '%d requests with warnings',
        this.requestsWithWarnings.length,
      );
    },
  },
  watch: {
    currentRequestId(newRequestId) {
      this.$emit('change-current-request', newRequestId);
    },
  },
  methods: {
    glEmojiTag,
  },
  safeHtmlConfig: { ADD_TAGS: ['gl-emoji'] },
};
</script>
<template>
  <div id="peek-request-selector" data-qa-selector="request_dropdown" class="view">
    <select v-model="currentRequestId">
      <option
        v-for="request in requests"
        :key="request.id"
        :value="request.id"
        data-qa-selector="request_dropdown_option"
      >
        {{ request.truncatedUrl }}
        <span v-if="request.hasWarnings">(!)</span>
      </option>
    </select>
    <span v-if="requestsWithWarnings.length" class="gl-cursor-default">
      <span
        id="performance-bar-request-selector-warning"
        v-safe-html:[$options.safeHtmlConfig]="glEmojiTag('warning')"
      ></span>
      <gl-popover
        placement="bottom"
        target="performance-bar-request-selector-warning"
        :content="warningMessage"
      />
    </span>
  </div>
</template>