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
|
<script>
import { GlBadge, GlIcon } from '@gitlab/ui';
import { __ } from '~/locale';
import {
STATUS_CLOSED,
STATUS_LOCKED,
STATUS_MERGED,
STATUS_OPEN,
TYPE_EPIC,
TYPE_ISSUE,
TYPE_MERGE_REQUEST,
} from '~/issues/constants';
const badgePropertiesMap = {
[TYPE_EPIC]: {
[STATUS_OPEN]: {
icon: 'issue-open-m',
text: __('Open'),
variant: 'success',
},
[STATUS_CLOSED]: {
icon: 'issue-close',
text: __('Closed'),
variant: 'info',
},
},
[TYPE_ISSUE]: {
[STATUS_OPEN]: {
icon: 'issue-open-m',
text: __('Open'),
variant: 'success',
},
[STATUS_CLOSED]: {
icon: 'issue-close',
text: __('Closed'),
variant: 'info',
},
[STATUS_LOCKED]: {
icon: 'issue-open-m',
text: __('Open'),
variant: 'success',
},
},
[TYPE_MERGE_REQUEST]: {
[STATUS_OPEN]: {
icon: 'merge-request-open',
text: __('Open'),
variant: 'success',
},
[STATUS_CLOSED]: {
icon: 'merge-request-close',
text: __('Closed'),
variant: 'danger',
},
[STATUS_MERGED]: {
icon: 'merge',
text: __('Merged'),
variant: 'info',
},
[STATUS_LOCKED]: {
icon: 'merge-request-open',
text: __('Open'),
variant: 'success',
},
},
};
export default {
components: {
GlBadge,
GlIcon,
},
props: {
issuableType: {
type: String,
required: false,
default: '',
},
state: {
type: String,
required: false,
default: null,
},
},
computed: {
badgeProperties() {
return badgePropertiesMap[this.issuableType][this.state];
},
},
};
</script>
<template>
<gl-badge :variant="badgeProperties.variant" :aria-label="badgeProperties.text">
<gl-icon :name="badgeProperties.icon" />
<span class="gl-display-none gl-sm-display-block gl-ml-2">{{ badgeProperties.text }}</span>
</gl-badge>
</template>
|