|
43 | 43 | @keydown.enter.prevent="searchErrata()" |
44 | 44 | /> |
45 | 45 | </div> |
46 | | - <div class="q-pb-md group row justify-end"> |
| 46 | + <div class="q-pb-md group row justify-between"> |
| 47 | + <q-btn |
| 48 | + v-if="userAuthenticated()" |
| 49 | + @click=" |
| 50 | + selectionHasSkippedPackages() |
| 51 | + ? (confirm = true) |
| 52 | + : bulkReleaseErratas() |
| 53 | + " |
| 54 | + no-caps |
| 55 | + color="primary" |
| 56 | + :disable="!selectedAdvisories.length" |
| 57 | + :loading="loadingRelease" |
| 58 | + > |
| 59 | + Release selection |
| 60 | + </q-btn> |
47 | 61 | <q-btn |
48 | 62 | @click="searchErrata()" |
49 | 63 | no-caps |
|
61 | 75 | color="primary" |
62 | 76 | :loading="loadingTable" |
63 | 77 | :rows-per-page-options="[10]" |
| 78 | + row-key="id" |
64 | 79 | hide-pagination |
65 | 80 | binary-state-sort |
66 | 81 | wrap-cells |
| 82 | + :selection="userAuthenticated() ? 'multiple' : null" |
| 83 | + v-model:selected="selectedAdvisories" |
67 | 84 | > |
68 | 85 | <template v-slot:top-right v-if="userAuthenticated()"> |
69 | 86 | <div class="q-gutter-md"> |
|
96 | 113 | :class="markAdvisory(props.row.id)" |
97 | 114 | @click="loadAdvisory(props.row.id, props.row.platform_id)" |
98 | 115 | > |
| 116 | + <q-td v-if="userAuthenticated()" auto-width> |
| 117 | + <q-checkbox v-model="props.selected" /> |
| 118 | + </q-td> |
99 | 119 | <q-td key="release_status" :props="props"> |
100 | 120 | <q-chip |
101 | 121 | :color="statusColor(props.row)" |
|
127 | 147 | <q-td key="original_title" :props="props">{{ |
128 | 148 | title(props.row) |
129 | 149 | }}</q-td> |
| 150 | + <q-td key="id" :props="props">{{ props.row.id }}</q-td> |
130 | 151 | </q-tr> |
131 | 152 | </template> |
132 | 153 | </q-table> |
|
168 | 189 | </q-card-actions> |
169 | 190 | </q-card> |
170 | 191 | </q-dialog> |
| 192 | + |
| 193 | + <q-dialog v-model="confirm" persistent> |
| 194 | + <q-card style="width: 50%"> |
| 195 | + <q-card-section> |
| 196 | + <div class="text-h6">Warning</div> |
| 197 | + </q-card-section> |
| 198 | + <q-card-section> |
| 199 | + Are you sure you want to release the record with skipped packages? |
| 200 | + </q-card-section> |
| 201 | + <q-card-actions align="right"> |
| 202 | + <q-btn |
| 203 | + flat |
| 204 | + label="Ok" |
| 205 | + color="primary" |
| 206 | + @click="bulkReleaseErratas(true)" |
| 207 | + :loading="loadingRelease" |
| 208 | + /> |
| 209 | + <q-btn flat text-color="negative" label="Cancel" v-close-popup /> |
| 210 | + </q-card-actions> |
| 211 | + </q-card> |
| 212 | + </q-dialog> |
171 | 213 | </template> |
172 | 214 |
|
173 | 215 | <script> |
|
187 | 229 | loading: false, |
188 | 230 | loadingReset: false, |
189 | 231 | loadingTable: false, |
| 232 | + loadingRelease: false, |
190 | 233 | totalPages: ref(1), |
191 | 234 | selectedAdvisory: null, |
192 | 235 | showDialogAdvisories: false, |
|
230 | 273 | ], |
231 | 274 | errataStatuses: ErrataReleaseStatus, |
232 | 275 | advisors: [], |
| 276 | + selectedAdvisories: [], |
| 277 | + confirm: false, |
233 | 278 | } |
234 | 279 | }, |
235 | 280 | created() { |
|
270 | 315 | this.loading = true |
271 | 316 | this.currentPage = 1 |
272 | 317 | }, |
| 318 | + bulkReleaseErratas(force = false) { |
| 319 | + this.loadingRelease = true |
| 320 | + let records_ids = this.selectedAdvisories.map((advisory) => advisory.id) |
| 321 | + this.$api |
| 322 | + .post(`/errata/bulk_release_records/?force=${force}`, records_ids) |
| 323 | + .then((response) => { |
| 324 | + this.loadingRelease = false |
| 325 | + Notify.create({ |
| 326 | + message: `${response.data.message}`, |
| 327 | + type: 'positive', |
| 328 | + actions: [{label: 'Dismiss', color: 'white', handler: () => {}}], |
| 329 | + }) |
| 330 | + this.loadAdvisories() |
| 331 | + }) |
| 332 | + .catch((error) => { |
| 333 | + this.loadingRelease = false |
| 334 | + Notify.create({ |
| 335 | + message: `${error.response.status}: ${error.response.statusText}`, |
| 336 | + type: 'negative', |
| 337 | + actions: [{label: 'Dismiss', color: 'white', handler: () => {}}], |
| 338 | + }) |
| 339 | + }) |
| 340 | + this.confirm = false |
| 341 | + }, |
| 342 | + selectionHasSkippedPackages() { |
| 343 | + for (const advisory of this.selectedAdvisories) { |
| 344 | + if (this.advisoryHasSkippedPackages(advisory)) { |
| 345 | + return true |
| 346 | + } |
| 347 | + } |
| 348 | + return false |
| 349 | + }, |
| 350 | + advisoryHasSkippedPackages(advisory) { |
| 351 | + let packages = {} |
| 352 | + let arch_list = this.platforms.find( |
| 353 | + (platform) => platform.value == advisory.platform_id |
| 354 | + ).arch_list |
| 355 | + advisory.packages.forEach((pack) => { |
| 356 | + if (arch_list.includes(pack.arch)) { |
| 357 | + packages[pack.source_srpm] |
| 358 | + ? packages[pack.source_srpm].push(pack) |
| 359 | + : (packages[pack.source_srpm] = [pack]) |
| 360 | + } |
| 361 | + }) |
| 362 | + for (const src in packages) { |
| 363 | + for (const pack of packages[src]) { |
| 364 | + if (pack.albs_packages.length === 0) { |
| 365 | + return true |
| 366 | + } |
| 367 | + } |
| 368 | + } |
| 369 | + return false |
| 370 | + }, |
273 | 371 | statusColor(record) { |
274 | 372 | let col = '' |
275 | 373 | switch (record.release_status) { |
|
0 commit comments