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

escalation_status.vue « incidents « components « sidebar « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9c41db98c63988fc30e5d954b001637b6f1775e4 (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
<script>
import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { i18n, STATUS_ACKNOWLEDGED, STATUS_TRIGGERED, STATUS_RESOLVED } from './constants';
import { getStatusLabel } from './utils';

const STATUS_LIST = [STATUS_TRIGGERED, STATUS_ACKNOWLEDGED, STATUS_RESOLVED];

export default {
  i18n,
  STATUS_LIST,
  components: {
    GlDropdown,
    GlDropdownItem,
  },
  props: {
    value: {
      type: String,
      required: false,
      default: null,
      validator(value) {
        return [...STATUS_LIST, null].includes(value);
      },
    },
    preventDropdownClose: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  computed: {
    currentStatusLabel() {
      return this.getStatusLabel(this.value);
    },
  },
  methods: {
    show() {
      this.$refs.dropdown.show();
    },
    hide() {
      this.$refs.dropdown.hide();
    },
    getStatusLabel,
    hideDropdown(event) {
      if (this.preventDropdownClose) {
        event.preventDefault();
      }
    },
  },
};
</script>

<template>
  <gl-dropdown
    ref="dropdown"
    block
    :text="currentStatusLabel"
    toggle-class="dropdown-menu-toggle gl-mb-2"
    @hide="hideDropdown"
  >
    <slot name="header"> </slot>
    <gl-dropdown-item
      v-for="status in $options.STATUS_LIST"
      :key="status"
      data-testid="status-dropdown-item"
      is-check-item
      :is-checked="status === value"
      @click="$emit('input', status)"
    >
      {{ getStatusLabel(status) }}
    </gl-dropdown-item>
  </gl-dropdown>
</template>