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
110
111
|
<script>
import { GlSprintf, GlLink } from '@gitlab/ui';
import { s__ } from '~/locale';
import { PUSH_EVENT_REF_TYPE_BRANCH, PUSH_EVENT_REF_TYPE_TAG } from '../../constants';
import ResourceParentLink from '../resource_parent_link.vue';
import ContributionEventBase from './contribution_event_base.vue';
export default {
name: 'ContributionEventPushed',
i18n: {
new: {
[PUSH_EVENT_REF_TYPE_BRANCH]: s__(
'ContributionEvent|Pushed a new branch %{refLink} in %{resourceParentLink}.',
),
[PUSH_EVENT_REF_TYPE_TAG]: s__(
'ContributionEvent|Pushed a new tag %{refLink} in %{resourceParentLink}.',
),
},
removed: {
[PUSH_EVENT_REF_TYPE_BRANCH]: s__(
'ContributionEvent|Deleted branch %{refLink} in %{resourceParentLink}.',
),
[PUSH_EVENT_REF_TYPE_TAG]: s__(
'ContributionEvent|Deleted tag %{refLink} in %{resourceParentLink}.',
),
},
pushed: {
[PUSH_EVENT_REF_TYPE_BRANCH]: s__(
'ContributionEvent|Pushed to branch %{refLink} in %{resourceParentLink}.',
),
[PUSH_EVENT_REF_TYPE_TAG]: s__(
'ContributionEvent|Pushed to tag %{refLink} in %{resourceParentLink}.',
),
},
multipleCommits: s__(
'ContributionEvent|…and %{count} more commits. %{linkStart}Compare%{linkEnd}.',
),
},
components: { ContributionEventBase, GlSprintf, GlLink, ResourceParentLink },
props: {
event: {
type: Object,
required: true,
},
},
computed: {
ref() {
return this.event.ref;
},
commit() {
return this.event.commit;
},
message() {
if (this.ref.is_new) {
return this.$options.i18n.new[this.ref.type];
}
if (this.ref.is_removed) {
return this.$options.i18n.removed[this.ref.type];
}
return this.$options.i18n.pushed[this.ref.type];
},
iconName() {
if (this.ref.is_removed) {
return 'remove';
}
return 'commit';
},
hasMultipleCommits() {
return this.commit.count > 1;
},
},
};
</script>
<template>
<contribution-event-base :event="event" :icon-name="iconName">
<gl-sprintf :message="message">
<template #refLink>
<gl-link v-if="ref.path" :href="ref.path" class="gl-font-monospace">{{ ref.name }}</gl-link>
<span v-else class="gl-font-monospace">{{ ref.name }}</span>
</template>
<template #resourceParentLink>
<resource-parent-link :event="event" />
</template>
</gl-sprintf>
<template v-if="!ref.is_removed" #additional-info>
<div>
<gl-link :href="commit.path" class="gl-font-monospace">{{ commit.truncated_sha }}</gl-link>
<template v-if="commit.title">
·
<span>{{ commit.title }}</span>
</template>
</div>
<div v-if="hasMultipleCommits" class="gl-mt-2">
<gl-sprintf :message="$options.i18n.multipleCommits">
<template #count>{{ commit.count - 1 }}</template>
<template #link="{ content }">
<gl-link :href="commit.compare_path"
>{{ content }}
<span class="gl-font-monospace"
>{{ commit.from_truncated_sha }}…{{ commit.to_truncated_sha }}</span
></gl-link
>
</template>
</gl-sprintf>
</div>
</template>
</contribution-event-base>
</template>
|