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

embedded_labels_list.vue « labels_select_widget « labels « components « sidebar « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3a93fc7f3b26b54a1991089e0be8aea6dcf75182 (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
<script>
import { GlLabel } from '@gitlab/ui';
import { sortBy } from 'lodash';
import { isScopedLabel } from '~/lib/utils/common_utils';

export default {
  components: {
    GlLabel,
  },
  inject: ['allowScopedLabels'],
  props: {
    disabled: {
      type: Boolean,
      required: false,
      default: false,
    },
    selectedLabels: {
      type: Array,
      required: true,
    },
    allowLabelRemove: {
      type: Boolean,
      required: true,
    },
    labelsFilterBasePath: {
      type: String,
      required: true,
    },
    labelsFilterParam: {
      type: String,
      required: true,
    },
  },
  computed: {
    sortedSelectedLabels() {
      return sortBy(this.selectedLabels, (label) => isScopedLabel(label));
    },
  },
  methods: {
    buildFilterUrl({ title }) {
      const { labelsFilterBasePath: basePath, labelsFilterParam: filterParam } = this;

      return `${basePath}?${filterParam}[]=${encodeURIComponent(title)}`;
    },
    showScopedLabel(label) {
      return this.allowScopedLabels && isScopedLabel(label);
    },
    removeLabel(labelId) {
      this.$emit('onLabelRemove', labelId);
    },
  },
};
</script>

<template>
  <div>
    <gl-label
      v-for="label in sortedSelectedLabels"
      :key="label.id"
      class="gl-mr-2 gl-mb-2"
      :data-qa-label-name="label.title"
      :title="label.title"
      :description="label.description"
      :background-color="label.color"
      :target="buildFilterUrl(label)"
      :scoped="showScopedLabel(label)"
      :show-close-button="allowLabelRemove"
      :disabled="disabled"
      tooltip-placement="top"
      @close="removeLabel(label.id)"
    />
  </div>
</template>