Skip to content

Commit 333cbeb

Browse files
Added mr labels to detached pipelines (#200)
* [FEAT] Added mr labels to detached pipelines Co-authored-by: Timo Schwarzer <me@timoschwarzer.com>
1 parent 2b446f0 commit 333cbeb

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

CONFIGURATION.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ projectConfig:
188188
# Whether to show detached pipelines of merge requests
189189
showDetached: false
190190

191+
# Whether to show the labels of the merge request for detached pipelines
192+
showLabels: true
193+
191194
# Minimum number of pipelines to display for this filter
192195
historyCount: 1
193196

charts/gitlab-monitor/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ config: |
5454
"showTags": true,
5555
"showLatestTagOnly": false,
5656
"showDetached": false,
57+
"showLabels": true,
5758
"maxPipelines": 10,
5859
"notifyFailureOn": null
5960
}

src/components/pipeline-view.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
:href="project.web_url + (!pipeline.ref.includes('merge-request') ? '/tree/' + pipeline.ref : '/-/merge_requests' + '/' + pipeline.ref.match(/\d+/))"
1212
>
1313
<octicon :name="!pipeline.ref.includes('merge-request') ? 'git-branch' : 'git-pull-request'" scale="0.9" />
14-
{{ pipeline.ref }} <span v-if="pipeline.additional">{{ pipeline.additional.title }}</span>
14+
{{ pipeline.ref }} <span v-if="pipeline.additional">&nbsp;&nbsp;{{ pipeline.additional.title }}<span class="mr-label" v-for="label in pipeline.additional.labels">{{ label }}</span></span>
1515
</a>
1616

1717
<div :class="['pipeline', {'with-stages-names': showStagesNames, 'is-skipped': pipeline.status === 'skipped'}]">
@@ -200,6 +200,7 @@
200200

201201
<style lang="scss" scoped>
202202
.pipeline-view {
203+
margin-top: 2px;
203204
&:not(:last-child) {
204205
margin-bottom: 4px;
205206
}
@@ -221,6 +222,16 @@
221222
}
222223
}
223224
225+
.mr-label {
226+
margin-left: 5px;
227+
vertical-align: middle;
228+
padding: 2px;
229+
font-size: 8px;
230+
border-radius: 0.75rem;
231+
color: var(--project-default, #424242);
232+
background: var(--pipeline-id, rgba(255, 255, 255, 0.8));
233+
}
234+
224235
.pipeline {
225236
display: flex;
226237
align-items: center;

src/components/project-card.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777
showDetached() {
7878
return this.config.showDetached
7979
},
80+
showLabels() {
81+
return this.config.showLabels
82+
},
8083
showProjectOnlyOn() {
8184
const showProjectOnlyOn = Config.root.showProjectOnlyOn
8285
if (showProjectOnlyOn && showProjectOnlyOn.length) {
@@ -205,6 +208,7 @@
205208
const showTags = this.showTags
206209
const showLatestTagOnly = this.showLatestTagOnly
207210
const showDetached = this.showDetached
211+
const showLabels = this.showLabels
208212
const fetchCount = Config.root.fetchCount
209213
210214
let refNamesAdditional = {}
@@ -243,6 +247,9 @@
243247
const mrPipelineRef = mrPipelines[0].ref
244248
detached.push(mrPipelineRef)
245249
refNamesAdditional[mrPipelineRef] = {title: mergeRequest.title}
250+
if (showLabels && mergeRequest.labels.length) {
251+
refNamesAdditional[mrPipelineRef].labels = mergeRequest.labels
252+
}
246253
}
247254
}
248255
}

src/config.default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"showTags": true,
4141
"showLatestTagOnly": false,
4242
"showDetached": false,
43+
"showLabels": true,
4344
"historyCount": 1,
4445
"hideSkippedPipelines": false,
4546
"hideSuccessfulPipelines": false,

0 commit comments

Comments
 (0)