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

label_item.vue « labels_select_vue « sidebar « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 154e3013acd86954f47578a11b1d76bb3e398742 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<script>
import { GlLink, GlIcon } from '@gitlab/ui';
import { __ } from '~/locale';

// @deprecated This component should only be used when there is no GraphQL API.
// In most cases you should use
// `app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/label_item.vue` instead.
export default {
  functional: true,
  props: {
    label: {
      type: Object,
      required: true,
    },
    isLabelSet: {
      type: Boolean,
      required: true,
    },
    isLabelIndeterminate: {
      type: Boolean,
      required: false,
      default: false,
    },
    highlight: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  render(h, { props, listeners }) {
    const { label, highlight, isLabelSet, isLabelIndeterminate } = props;

    const labelColorBox = h('span', {
      class: 'dropdown-label-box gl-flex-shrink-0 gl-top-0 gl-mr-3',
      style: {
        backgroundColor: label.color,
      },
      attrs: {
        'data-testid': 'label-color-box',
      },
    });

    const checkedIcon = h(GlIcon, {
      class: {
        'gl-mr-3 gl-flex-shrink-0 has-tooltip': true,
        hidden: !isLabelSet,
      },
      attrs: {
        title: __('Selected for all items.'),
        'data-testid': 'checked-icon',
      },
      props: {
        name: 'mobile-issue-close',
      },
    });

    const indeterminateIcon = h(GlIcon, {
      class: {
        'gl-mr-3 gl-flex-shrink-0 has-tooltip': true,
        hidden: !isLabelIndeterminate,
      },
      attrs: {
        title: __('Selected for some items.'),
        'data-testid': 'indeterminate-icon',
      },
      props: {
        name: 'dash',
      },
    });

    const noIcon = h('span', {
      class: {
        'gl-mr-5 gl-pr-3': true,
        hidden: isLabelSet || isLabelIndeterminate,
      },
      attrs: {
        'data-testid': 'no-icon',
      },
    });

    const labelTitle = h('span', label.title);

    const labelLink = h(
      GlLink,
      {
        class: 'gl-display-flex gl-align-items-center label-item gl-text-body',
        on: {
          click: () => {
            listeners.clickLabel(label);
          },
        },
      },
      [noIcon, checkedIcon, indeterminateIcon, labelColorBox, labelTitle],
    );

    return h(
      'li',
      {
        class: {
          'gl-display-block': true,
          'gl-text-left': true,
          'is-focused': highlight,
        },
      },
      [labelLink],
    );
  },
};
</script>