Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 1 | // Copyright 2022 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | import {LABELS_PREFIX} from "./IssueWizardConfig.ts"; |
| 6 | |
| 7 | // Chromium project component prefix |
| 8 | const CR_PREFIX = 'Cr-'; |
| 9 | |
| 10 | // customized function for add additoinal data base on different categories. |
| 11 | export function expandDescriptions( |
| 12 | category: string, |
| 13 | customQuestionsAnswers: Array<string>, |
| 14 | isRegression: boolean, |
| 15 | description: string, |
| 16 | labels: Array<any>, |
| 17 | component?: string, |
| 18 | ): {expandDescription:string, expandLabels:Array<any>, compVal:string} { |
| 19 | let expandDescription = ""; |
| 20 | let expandLabels = labels; |
| 21 | let compVal = component || ''; |
| 22 | let typeLabel = isRegression ? 'Type-Bug-Regression' : 'Type-Bug'; |
| 23 | |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame^] | 24 | if (category === 'Security') { |
| 25 | typeLabel = 'Type-Bug-Security' |
| 26 | } |
| 27 | |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 28 | customQuestionsAnswers.forEach((ans) => { |
| 29 | if (ans.startsWith(LABELS_PREFIX)) { |
| 30 | const currentAnswer = ans.substring(LABELS_PREFIX.length); |
| 31 | switch (category) { |
| 32 | case 'Content': |
| 33 | if (currentAnswer.split(' - ')[0] === 'Yes') { |
| 34 | compVal = 'Cr-Blink'; |
| 35 | typeLabel = 'Type-Bug'; |
| 36 | } else { |
| 37 | compVal = ''; |
| 38 | typeLabel = 'Type-Compat'; |
| 39 | } |
| 40 | break; |
| 41 | case 'Extensions / Themes': |
| 42 | if (currentAnswer.split(' - ')[0] === 'Chrome Extension') { |
| 43 | compVal = 'Cr-Platform-Extensions'; |
| 44 | } else { |
| 45 | compVal = 'Cr-UI-Browser-Themes'; |
| 46 | } |
| 47 | break; |
| 48 | case 'Security': |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame^] | 49 | typeLabel = 'Type-Bug-Security'; |
| 50 | break; |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 51 | case 'Other': |
| 52 | typeLabel = "Type-Bug"; |
| 53 | const issueType = currentAnswer.split(' - ')[0]; |
| 54 | if (issueType !== 'Not sure'){ |
| 55 | typeLabel = issueType; |
| 56 | } |
| 57 | if (issueType === 'Cr-UI-I18N') { |
| 58 | compVal = 'Cr-UI-I18N'; |
| 59 | } |
| 60 | break; |
| 61 | case 'API': |
| 62 | compVal = currentAnswer; |
| 63 | if (compVal === "Not sure - I don't know") { |
| 64 | compVal = ''; |
| 65 | } |
| 66 | break; |
| 67 | } |
| 68 | } else { |
| 69 | expandDescription = expandDescription + ans + "\n\n"; |
| 70 | } |
| 71 | }); |
| 72 | |
| 73 | expandDescription = expandDescription + description; |
| 74 | |
| 75 | if (typeLabel.length > 0) { |
| 76 | expandLabels.push({ |
| 77 | label: typeLabel |
| 78 | }); |
| 79 | } |
| 80 | |
| 81 | if (compVal.length > 0) { |
| 82 | if (compVal.startsWith(CR_PREFIX)) { |
| 83 | compVal = compVal.substring(CR_PREFIX.length); |
| 84 | compVal = compVal.replace(/-/g, '>'); |
| 85 | } |
| 86 | } |
| 87 | return {expandDescription, expandLabels, compVal}; |
| 88 | } |