Skip to content

Commit 984c495

Browse files
committed
6.2 release branch setup with windup working
Signed-off-by: ibolton336 <[email protected]>
1 parent 96e867e commit 984c495

File tree

13 files changed

+180
-103
lines changed

13 files changed

+180
-103
lines changed

client/public/locales/en/translation.json

+2
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@
306306
"select": "Select",
307307
"settingsAllowApps": "Allow reviewing applications without running an assessment first",
308308
"source": "Source",
309+
"settingsCSVReports": "Enable downloads for CSV reports",
310+
"settingsHTMLReports": "Enable downloads for HTML reports",
309311
"sourceBranch": "Branch",
310312
"sourceCode": "Source code",
311313
"sourceRepo": "Source Repository",

client/public/locales/es/translation.json

+2
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@
274274
"scheduled": "Programado",
275275
"select": "Seleccione",
276276
"settingsAllowApps": "Permitir la revisión de aplicaciones sin ejecutar una evaluación primero",
277+
"settingsCSVReports": "Habilitar descargas para informes CSV",
278+
"settingsHTMLReports": "Habilitar descargas para informes HTML",
277279
"sourceBranch": "Rama",
278280
"sourceCode": "Código fuente.",
279281
"sourceRepo": "Repositorio",

client/src/app/api/models.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ export interface ApplicationImportPage {
338338
}
339339

340340
export type SettingTypes = {
341+
"download.csv.enabled": boolean;
342+
"download.html.enabled": boolean;
341343
"git.insecure.enabled": boolean;
342344
"mvn.dependencies.update.forced": boolean;
343345
"mvn.insecure.enabled": boolean;
@@ -385,6 +387,7 @@ export interface TaskData {
385387
tagger: {
386388
enabled: boolean;
387389
};
390+
output: string;
388391
mode: {
389392
binary: boolean;
390393
withDeps: boolean;
@@ -409,10 +412,7 @@ export interface TaskData {
409412
rulesets: Ref[];
410413
repository?: Repository;
411414
identity?: Ref;
412-
labels: {
413-
included: string[];
414-
excluded: string[];
415-
};
415+
labels: string[];
416416
};
417417
}
418418

client/src/app/common/CustomRules/rules-utils.tsx

+31-59
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { IReadFile, ParsedRule, Rule, Ruleset } from "@app/api/models";
2-
import yaml from "js-yaml";
1+
import { IReadFile, ParsedRule, Ruleset } from "@app/api/models";
32

43
type RuleFileType = "YAML" | "XML" | null;
54

@@ -14,69 +13,43 @@ export const checkRuleFileType = (filename: string): RuleFileType => {
1413

1514
export const parseRules = (file: IReadFile): ParsedRule => {
1615
if (file.data) {
17-
if (checkRuleFileType(file.fileName) === "YAML") {
18-
const yamlDoc = yaml.load(file.data) as any[];
19-
const yamlLabels = yamlDoc?.reduce((acc, parsedLine) => {
20-
const newLabels = parsedLine?.labels ? parsedLine?.labels : [];
21-
return [...acc, ...newLabels];
22-
}, []);
23-
const allLabels = getLabels(yamlLabels);
24-
return {
25-
source: allLabels?.sourceLabel,
26-
target: allLabels?.targetLabel,
27-
otherLabels: allLabels?.otherLabels,
28-
allLabels: allLabels?.allLabels,
29-
total: 0,
30-
...(file.responseID && {
31-
fileID: file.responseID,
32-
}),
33-
};
34-
} else if (checkRuleFileType(file.fileName) === "XML") {
35-
let source: string | null = null;
36-
let target: string | null = null;
37-
let rulesCount = 0;
16+
let source: string | null = null;
17+
let target: string | null = null;
18+
let rulesCount = 0;
3819

39-
const parser = new DOMParser();
40-
const xml = parser.parseFromString(file.data, "text/xml");
20+
const parser = new DOMParser();
21+
const xml = parser.parseFromString(file.data, "text/xml");
4122

42-
const ruleSets = xml.getElementsByTagName("ruleset");
23+
const ruleSets = xml.getElementsByTagName("ruleset");
4324

44-
if (ruleSets && ruleSets.length > 0) {
45-
const metadata = ruleSets[0].getElementsByTagName("metadata");
25+
if (ruleSets && ruleSets.length > 0) {
26+
const metadata = ruleSets[0].getElementsByTagName("metadata");
4627

47-
if (metadata && metadata.length > 0) {
48-
const sources = metadata[0].getElementsByTagName("sourceTechnology");
49-
if (sources && sources.length > 0) source = sources[0].id;
28+
if (metadata && metadata.length > 0) {
29+
const sources = metadata[0].getElementsByTagName("sourceTechnology");
30+
if (sources && sources.length > 0) source = sources[0].id;
5031

51-
const targets = metadata[0].getElementsByTagName("targetTechnology");
52-
if (targets && targets.length > 0) target = targets[0].id;
53-
}
54-
55-
const rulesGroup = ruleSets[0].getElementsByTagName("rules");
56-
if (rulesGroup && rulesGroup.length > 0)
57-
rulesCount = rulesGroup[0].getElementsByTagName("rule").length;
32+
const targets = metadata[0].getElementsByTagName("targetTechnology");
33+
if (targets && targets.length > 0) target = targets[0].id;
5834
}
59-
const allLabels = [
60-
...(source ? [`konveyor.io/source=${source}`] : []),
61-
...(target ? [`konveyor.io/target=${target}`] : []),
62-
];
63-
return {
64-
source: source,
65-
target: target,
66-
otherLabels: allLabels,
67-
allLabels: allLabels,
68-
total: rulesCount,
69-
...(file.responseID && {
70-
fileID: file.responseID,
71-
}),
72-
};
73-
} else {
74-
return {
75-
source: null,
76-
target: null,
77-
total: 0,
78-
};
35+
36+
const rulesGroup = ruleSets[0].getElementsByTagName("rules");
37+
if (rulesGroup && rulesGroup.length > 0)
38+
rulesCount = rulesGroup[0].getElementsByTagName("rule").length;
7939
}
40+
const allLabels = [
41+
...(source ? [`konveyor.io/source=${source}`] : []),
42+
...(target ? [`konveyor.io/target=${target}`] : []),
43+
];
44+
return {
45+
source,
46+
target,
47+
total: rulesCount,
48+
allLabels,
49+
...(file.responseID && {
50+
fileID: file.responseID,
51+
}),
52+
};
8053
} else {
8154
return {
8255
source: null,
@@ -85,7 +58,6 @@ export const parseRules = (file: IReadFile): ParsedRule => {
8558
};
8659
}
8760
};
88-
8961
interface ILabelMap {
9062
sourceLabel: string;
9163
targetLabel: string;

client/src/app/common/CustomRules/useRuleFiles.tsx

+14-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { useContext, useState } from "react";
2+
import XSDSchema from "./windup-jboss-ruleset.xsd";
3+
import { XMLValidator } from "fast-xml-parser";
24
import { FileLoadError, IReadFile } from "@app/api/models";
35
import { NotificationsContext } from "@app/shared/notifications-context";
46
import { AxiosError } from "axios";
@@ -7,9 +9,6 @@ import { getAxiosErrorMessage } from "@app/utils/utils";
79
import { useCreateFileMutation } from "@app/queries/rulesets";
810
import { CustomTargetFormValues } from "@app/pages/migration-targets/custom-target-form";
911
import { UseFormReturn } from "react-hook-form";
10-
import { XMLValidator } from "fast-xml-parser";
11-
import XSDSchema from "./windup-jboss-ruleset.xsd";
12-
import { checkRuleFileType } from "./rules-utils";
1312
const xmllint = require("xmllint");
1413

1514
export default function useRuleFiles(
@@ -199,22 +198,15 @@ export default function useRuleFiles(
199198
handleReadFail(error, 100, file);
200199
} else {
201200
if (data) {
202-
if (checkRuleFileType(file.name) === "XML") {
203-
const validatedXMLResult = validateXMLFile(data);
204-
if (validatedXMLResult.state === "valid") {
205-
handleReadSuccess(data, file);
206-
} else {
207-
const error = new Error(
208-
`File "${file.name}" is not a valid XML: ${validatedXMLResult.message}`
209-
);
210-
handleReadFail(error, 100, file);
211-
}
212-
} else {
201+
const validatedXMLResult = validateXMLFile(data);
202+
if (validatedXMLResult.state === "valid")
213203
handleReadSuccess(data, file);
204+
else {
205+
const error = new Error(
206+
`File "${file.name}" is not a valid XML: ${validatedXMLResult.message}`
207+
);
208+
handleReadFail(error, 100, file);
214209
}
215-
} else {
216-
const error = new Error("error");
217-
handleReadFail(error, 100, file);
218210
}
219211
}
220212
}
@@ -314,6 +306,11 @@ export default function useRuleFiles(
314306
};
315307
};
316308

309+
interface IParsedXMLFileStatus {
310+
state: "valid" | "error";
311+
message?: string;
312+
}
313+
317314
return {
318315
handleFileDrop,
319316
removeFiles,

client/src/app/pages/applications/analysis-wizard/analysis-wizard.tsx

+7-12
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ interface IAnalysisWizard {
4747
}
4848

4949
const defaultTaskData: TaskData = {
50+
output: "/windup/report",
5051
tagger: {
5152
enabled: true,
5253
},
@@ -56,8 +57,6 @@ const defaultTaskData: TaskData = {
5657
artifact: "",
5758
diva: false,
5859
},
59-
targets: [],
60-
sources: [],
6160
scope: {
6261
withKnown: false,
6362
packages: {
@@ -68,8 +67,8 @@ const defaultTaskData: TaskData = {
6867
};
6968

7069
const defaultTaskgroup: Taskgroup = {
71-
name: `taskgroup.analyzer`,
72-
addon: "analyzer",
70+
name: `taskgroup.windup`,
71+
addon: "windup",
7372
data: {
7473
...defaultTaskData,
7574
},
@@ -194,7 +193,6 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
194193

195194
const { handleSubmit, watch, reset } = methods;
196195
const values = watch();
197-
console.log("values", values);
198196

199197
enum StepId {
200198
AnalysisMode = 1,
@@ -256,13 +254,10 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
256254
},
257255
},
258256
rules: {
259-
labels: {
260-
included: [
261-
...fieldValues.formTargets,
262-
...fieldValues.selectedFormSources,
263-
],
264-
excluded: [],
265-
},
257+
labels: [
258+
...fieldValues.formTargets,
259+
...fieldValues.selectedFormSources,
260+
],
266261
path: fieldValues.customRulesFiles.length > 0 ? "/rules" : "",
267262
tags: {
268263
excluded: fieldValues.excludedRulesTags,

client/src/app/pages/applications/analysis-wizard/custom-rules.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -484,14 +484,14 @@ export const CustomRules: React.FC<CustomRulesProps> = (props) => {
484484
<MultipleFileUpload
485485
onFileDrop={handleFileDrop}
486486
dropzoneProps={{
487-
accept: ".yml, .yaml, .xml",
487+
accept: ".xml",
488488
}}
489489
>
490490
<MultipleFileUploadMain
491491
titleIcon={<UploadIcon />}
492492
titleText="Drag and drop files here"
493493
titleTextSeparator="or"
494-
infoText="Accepted file types: .yml, .yaml, .xml "
494+
infoText="Accepted file types: .xml "
495495
/>
496496
{showStatus && (
497497
<MultipleFileUploadStatus

client/src/app/pages/applications/applications-table-analyze/applications-table-analyze.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const ApplicationsTableAnalyze: React.FC = () => {
124124
activeAppInDetailDrawer,
125125
} = useApplicationsFilterValues(ApplicationTableType.Analysis, applications);
126126

127-
const { tasks } = useFetchTasks({ addon: "analyzer" });
127+
const { tasks } = useFetchTasks({ addon: "windup" });
128128

129129
const queryClient = useQueryClient();
130130
const allTasksComplete = tasks.every((task) => task.state !== "Running");

client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export const ApplicationsTable: React.FC = () => {
137137
refetch: fetchApplications,
138138
} = useFetchApplications();
139139

140-
const { tasks } = useFetchTasks({ addon: "analyzer" });
140+
const { tasks } = useFetchTasks({ addon: "windup" });
141141

142142
const getTask = (application: Application) =>
143143
tasks.find((task: Task) => task.application?.id === application.id);

0 commit comments

Comments
 (0)