Skip to content

Commit 266112b

Browse files
Merge pull request #563 from javihernandez/bs-393
Updates to the errata creation UI and process Resolves: AlmaLinux/build-system#393
2 parents faee113 + 00269a4 commit 266112b

File tree

3 files changed

+65
-45
lines changed

3 files changed

+65
-45
lines changed

src/components/ErrataReferencesSelection.vue

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,7 @@
2525
/>
2626
<div class="row q-gutter-md">
2727
<q-input
28-
v-if="Object.keys(reference).length !== 0"
29-
ref="refId"
30-
label="Ref ID"
31-
v-model="origRefId"
32-
class="col"
33-
:rules="[(val) => !!val || 'Ref ID is required']"
34-
/>
35-
<q-input
36-
v-if="Object.keys(reference).length !== 0"
28+
v-if="Object.keys(reference).length !== 0 && type.value !== 'cve'"
3729
label="Title"
3830
v-model="refTitle"
3931
class="col"
@@ -55,7 +47,7 @@
5547
>
5648
<q-input
5749
ref="refCveId"
58-
label="CVE ID"
50+
label="CVE ID (Title)"
5951
v-model="cveId"
6052
class="col"
6153
:rules="[(val) => !!val || 'ID is required']"
@@ -264,11 +256,7 @@
264256
this.close()
265257
},
266258
editRef() {
267-
if (
268-
!this.$refs.refURL.validate() ||
269-
!this.$refs.refType.validate() ||
270-
!this.$refs.refId.validate()
271-
)
259+
if (!this.$refs.refURL.validate() || !this.$refs.refType.validate())
272260
return
273261
let newRef = {
274262
href: this.url,

src/constants.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ const ErrataReleaseStatus = {
184184
const ErrataReferenceType = {
185185
'ErrataReferenceType.cve': 'cve',
186186
'ErrataReferenceType.rhsa': 'rhsa',
187-
'ErrataReferenceType.self_ref': 'self',
188187
'ErrataReferenceType.bugzilla': 'bugzilla',
189188
}
190189

src/pages/CreateErrata.vue

Lines changed: 62 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
<div class="text-h6">Create New Advisory</div>
77
</q-card-section>
88
<q-card-section class="row q-gutter-md" style="max-width: 100%">
9-
<q-input
10-
label="ID"
11-
v-model="advisoryId"
12-
class="col"
13-
hint="Example: ALSA-2024:A001"
14-
:rules="[(val) => !!val || 'ID is required']"
15-
/>
169
<q-select
1710
v-model="platform"
1811
:options="platforms"
@@ -21,6 +14,14 @@
2114
clearable
2215
:rules="[(val) => !!val.value || 'Platform is required']"
2316
/>
17+
<q-input
18+
label="ID"
19+
v-model="advisoryId"
20+
class="col"
21+
hint="Example: ALSA-2024:A001"
22+
hide-hint
23+
:rules="[isValidId]"
24+
/>
2425
<q-input
2526
v-model="issued_date"
2627
type="date"
@@ -43,20 +44,6 @@
4344
class="col"
4445
hint="Can be empty"
4546
/>
46-
<q-input
47-
label="Version"
48-
v-model="version"
49-
class="col"
50-
hint="'3' by default"
51-
:rules="[(val) => !!val || 'Version is required']"
52-
/>
53-
<q-input
54-
label="Status"
55-
v-model="status"
56-
class="col"
57-
hint="'final' by default"
58-
:rules="[(val) => !!val || 'Status is required']"
59-
/>
6047
<q-select
6148
ref="refSeverity"
6249
v-model="severity"
@@ -109,7 +96,7 @@
10996
<template v-slot:body="props">
11097
<q-tr :props="props">
11198
<q-td key="id" :props="props">
112-
{{ props.row.ref_id }}
99+
{{ props.row.title }}
113100
</q-td>
114101
<q-td key="ref_type" :props="props">
115102
{{ props.row.ref_type.toUpperCase() }}
@@ -362,8 +349,6 @@
362349
return {
363350
advisoryId: '',
364351
platform: '',
365-
version: '3',
366-
status: 'final',
367352
severity: '',
368353
issued_date: '',
369354
updated_date: '',
@@ -379,9 +364,9 @@
379364
{
380365
name: 'id',
381366
required: true,
382-
label: 'ID',
367+
label: 'Title',
383368
align: 'left',
384-
field: (row) => row.ref_id,
369+
field: (row) => row.title,
385370
sortable: true,
386371
},
387372
{
@@ -455,6 +440,30 @@
455440
},
456441
},
457442
methods: {
443+
isValidId(val) {
444+
if (!this.platform) {
445+
return 'Select a platform first'
446+
}
447+
if (!val) {
448+
return 'ID is required'
449+
}
450+
const regex = /^AL[B|E|S]A-\d{4}:A\d{3,4}$/
451+
if (!regex.test(val)) {
452+
return 'ID is invalid. Example: ALSA-2024:A001'
453+
}
454+
return this.$api
455+
.get(`/errata/query/?id=${val}&platform_id=${this.platform.value}`)
456+
.then((response) => {
457+
if (response.data.total_records > 0) {
458+
return 'ID already exists, please choose another one'
459+
}
460+
return true
461+
})
462+
.catch((error) => {
463+
console.log(error)
464+
return false
465+
})
466+
},
458467
goToBuild(build_id) {
459468
window.open(`/build/${build_id}`, '_blank')
460469
},
@@ -551,14 +560,21 @@
551560
let build = response.data
552561
this.uniqueBuildsId.add(+buildId)
553562
let buildRunning = false
563+
let wrongPlatform = false
554564
555-
build.tasks.forEach((task) => {
565+
for (const task of build.tasks) {
566+
if (task.platform.id !== this.platform.value) {
567+
wrongPlatform = true
568+
break
569+
}
556570
switch (task.status) {
557571
case BuildStatus.COMPLETED:
558572
for (let artifact of task.artifacts) {
559573
if (
560574
artifact.type !== 'rpm' ||
561-
artifact.name.includes('.src.')
575+
artifact.name.includes('.src.') ||
576+
artifact.name.includes('debugsource') ||
577+
artifact.name.includes('debuginfo')
562578
)
563579
continue
564580
let pkg = artifact.meta
@@ -567,6 +583,14 @@
567583
pkg = splitRpmFileName(artifact.name)
568584
pkg.epoch = 0
569585
}
586+
let alreadyAdded = pkgs.find((p) => {
587+
return (
588+
p.name === pkg.name &&
589+
p.version === pkg.version &&
590+
p.release === pkg.release
591+
)
592+
})
593+
if (alreadyAdded) continue
570594
pkgs.push({
571595
name: pkg.name,
572596
epoch: pkg.epoch,
@@ -585,7 +609,7 @@
585609
default:
586610
buildRunning = true
587611
}
588-
})
612+
}
589613
if (buildRunning) {
590614
Notify.create({
591615
message: `Build ${buildId} is still running`,
@@ -595,6 +619,15 @@
595619
],
596620
})
597621
this.uniqueBuildsId.delete(+buildId)
622+
} else if (wrongPlatform) {
623+
Notify.create({
624+
message: `Packages in build ${buildId} do not match the selected platform`,
625+
type: 'negative',
626+
actions: [
627+
{label: 'Dismiss', color: 'white', handler: () => {}},
628+
],
629+
})
630+
this.uniqueBuildsId.delete(+buildId)
598631
} else if (pkgs.length === 0) {
599632
Notify.create({
600633
message: `Build ${buildId} failed`,

0 commit comments

Comments
 (0)