blob: 1baf35ba99315c1f4dc3955af7972f7b4f63cf23 [file] [log] [blame]
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +02001// 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
5import {LABELS_PREFIX} from "./IssueWizardConfig.ts";
6
7// Chromium project component prefix
8const CR_PREFIX = 'Cr-';
9
10// customized function for add additoinal data base on different categories.
11export 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ínezde942802022-07-15 14:06:55 +020024 if (category === 'Security') {
25 typeLabel = 'Type-Bug-Security'
26 }
27
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020028 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ínezde942802022-07-15 14:06:55 +020049 typeLabel = 'Type-Bug-Security';
50 break;
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020051 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 }