|
1 | | -import { LWCAssessmentInfo } from '../interfaces'; |
2 | | -import { Logger } from '../logger'; |
3 | | -import { OmnistudioOrgDetails } from '../orgUtils'; |
4 | | -import { |
5 | | - FilterGroupParam, |
6 | | - ReportHeaderGroupParam, |
7 | | - ReportParam, |
8 | | - ReportRowParam, |
9 | | - SummaryItemDetailParam, |
10 | | - CTASummary, |
11 | | -} from '../reportGenerator/reportInterfaces'; |
12 | | -import { createFilterGroupParam, createRowDataParam, getOrgDetailsForReport } from '../reportGenerator/reportUtil'; |
13 | | -import { FileDiffUtil } from '../lwcparser/fileutils/FileDiffUtil'; |
14 | | -import { reportingHelper } from './reportingHelper'; |
| 1 | +// import { LWCAssessmentInfo } from '../interfaces'; |
| 2 | +// import { FileDiffUtil } from '../lwcparser/fileutils/FileDiffUtil'; |
| 3 | +// import { generateHtmlTable } from '../reportGenerator/reportGenerator'; |
| 4 | +// import { |
| 5 | +// Filter, |
| 6 | +// HeaderColumn, |
| 7 | +// ReportFrameworkParameters, |
| 8 | +// ReportHeaderFormat, |
| 9 | +// TableColumn, |
| 10 | +// } from '../reportGenerator/reportInterfaces'; |
15 | 11 |
|
16 | | -export class LWCAssessmentReporter { |
17 | | - private static rowId = 0; |
18 | | - private static rowIdPrefix = 'lwc-row-data-'; |
| 12 | +// type RowType = { |
| 13 | +// name: string; |
| 14 | +// filePath: string; |
| 15 | +// fileName: string; |
| 16 | +// diff: string; |
| 17 | +// migrationStatus: string; |
| 18 | +// errors: string; |
| 19 | +// }; |
19 | 20 |
|
20 | | - public static getLwcAssessmentData( |
21 | | - lwcAssessmentInfos: LWCAssessmentInfo[], |
22 | | - omnistudioOrgDetails: OmnistudioOrgDetails |
23 | | - ): ReportParam { |
24 | | - Logger.captureVerboseData('lwc data:', lwcAssessmentInfos); |
25 | | - return { |
26 | | - title: 'LWC Migration Assessment', |
27 | | - heading: 'Lightning Web Components (LWC)', |
28 | | - org: getOrgDetailsForReport(omnistudioOrgDetails), |
29 | | - assessmentDate: new Date().toString(), |
30 | | - total: this.getTotalFileCount(lwcAssessmentInfos), |
31 | | - filterGroups: this.getFilterGroupsForReport(lwcAssessmentInfos), |
32 | | - headerGroups: this.getHeaderGroupsForReport(), |
33 | | - rows: this.getRowsForReport(lwcAssessmentInfos), |
34 | | - callToAction: this.getCallToAction(lwcAssessmentInfos), |
35 | | - }; |
36 | | - } |
| 21 | +// export class LWCAssessmentReporter { |
| 22 | +// public static generateLwcAssesment( |
| 23 | +// lwcAssessmentInfos: LWCAssessmentInfo[], |
| 24 | +// instanceUrl: string, |
| 25 | +// org: ReportHeaderFormat[] |
| 26 | +// ): string { |
| 27 | +// // Header Columns |
| 28 | +// const headerColumn: HeaderColumn[] = [ |
| 29 | +// { |
| 30 | +// label: 'Name', |
| 31 | +// key: 'name', |
| 32 | +// colspan: 1, |
| 33 | +// rowspan: 1, |
| 34 | +// subColumn: [], |
| 35 | +// }, |
| 36 | +// { |
| 37 | +// label: 'File Path', |
| 38 | +// key: 'filePath', |
| 39 | +// colspan: 1, |
| 40 | +// rowspan: 1, |
| 41 | +// subColumn: [], |
| 42 | +// }, |
| 43 | +// { |
| 44 | +// label: 'File Diff', |
| 45 | +// key: 'diff', |
| 46 | +// colspan: 1, |
| 47 | +// rowspan: 1, |
| 48 | +// subColumn: [], |
| 49 | +// }, |
| 50 | +// { |
| 51 | +// label: 'Migration Status', |
| 52 | +// key: 'migrationStatus', |
| 53 | +// colspan: 1, |
| 54 | +// rowspan: 1, |
| 55 | +// subColumn: [], |
| 56 | +// }, |
| 57 | +// { |
| 58 | +// label: 'Errors', |
| 59 | +// key: 'errors', |
| 60 | +// colspan: 1, |
| 61 | +// rowspan: 1, |
| 62 | +// subColumn: [], |
| 63 | +// }, |
| 64 | +// ]; |
37 | 65 |
|
38 | | - public static getSummaryData(lwcAssessmentInfos: LWCAssessmentInfo[]): SummaryItemDetailParam[] { |
39 | | - return [ |
40 | | - { |
41 | | - name: 'Can be Automated', |
42 | | - count: lwcAssessmentInfos.filter( |
43 | | - (lwcAssessmentInfo) => !lwcAssessmentInfo.errors || lwcAssessmentInfo.errors.length === 0 |
44 | | - ).length, |
45 | | - cssClass: 'text-success', |
46 | | - }, |
47 | | - { |
48 | | - name: 'Has Warnings', |
49 | | - count: lwcAssessmentInfos.filter((info) => info.warnings && info.warnings.length > 0).length, |
50 | | - cssClass: 'text-warning', |
51 | | - }, |
52 | | - { |
53 | | - name: 'Has Errors', |
54 | | - count: lwcAssessmentInfos.filter((info) => info.errors && info.errors.length > 0).length, |
55 | | - cssClass: 'text-warning', |
56 | | - }, |
57 | | - ]; |
58 | | - } |
| 66 | +// // Define columns |
| 67 | +// const columns: Array<TableColumn<RowType>> = [ |
| 68 | +// { |
| 69 | +// key: 'name', |
| 70 | +// cell: (row: RowType): string => row.name, |
| 71 | +// filterValue: (row: RowType): string => row.name, |
| 72 | +// title: (row: RowType): string => row.name, |
| 73 | +// }, |
| 74 | +// { |
| 75 | +// key: 'filePath', |
| 76 | +// cell: (row: RowType): string => `<span><a href="${row.filePath}">${row.fileName}</a></span>`, |
| 77 | +// filterValue: (row: RowType): string => row.fileName, |
| 78 | +// title: (row: RowType): string => row.fileName, |
| 79 | +// }, |
| 80 | +// { |
| 81 | +// key: 'diff', |
| 82 | +// cell: (row: RowType): string => FileDiffUtil.getDiffHTML(row.diff, row.name), |
| 83 | +// filterValue: (row: RowType): string => `Diff_${row.fileName}`, |
| 84 | +// title: (row: RowType): string => `Diff_${row.fileName}`, |
| 85 | +// }, |
| 86 | +// { |
| 87 | +// key: 'migrationStatus', |
| 88 | +// cell: (row: RowType): string => row.migrationStatus, |
| 89 | +// filterValue: (row: RowType): string => row.migrationStatus, |
| 90 | +// title: (row: RowType): string => row.migrationStatus, |
| 91 | +// }, |
| 92 | +// { |
| 93 | +// key: 'errors', |
| 94 | +// cell: (row: RowType): string => row.errors, |
| 95 | +// filterValue: (row: RowType): string => row.errors, |
| 96 | +// title: (row: RowType): string => row.errors, |
| 97 | +// }, |
| 98 | +// ]; |
59 | 99 |
|
60 | | - private static getTotalFileCount(lwcAssessmentInfos: LWCAssessmentInfo[]): number { |
61 | | - return lwcAssessmentInfos.reduce((total, info) => total + (info.changeInfos?.length || 0), 0); |
62 | | - } |
| 100 | +// const rows = this.generateRows(lwcAssessmentInfos); |
63 | 101 |
|
64 | | - private static getRowsForReport(lwcAssessmentInfos: LWCAssessmentInfo[]): ReportRowParam[] { |
65 | | - const rows: ReportRowParam[] = []; |
| 102 | +// const filters: Filter[] = [ |
| 103 | +// { |
| 104 | +// label: 'Status', |
| 105 | +// key: 'status', |
| 106 | +// filterOptions: Array.from(new Set(rows.map((row: RowType) => row.migrationStatus))), |
| 107 | +// }, |
| 108 | +// { |
| 109 | +// label: 'Errors', |
| 110 | +// key: 'errors', |
| 111 | +// filterOptions: Array.from(new Set(rows.map((row: RowType) => row.errors))), |
| 112 | +// }, |
| 113 | +// ]; |
66 | 114 |
|
67 | | - for (const lwcAssessmentInfo of lwcAssessmentInfos) { |
68 | | - if (lwcAssessmentInfo.changeInfos && lwcAssessmentInfo.changeInfos.length > 0) { |
69 | | - // Create rows for each file change |
70 | | - for (const fileChangeInfo of lwcAssessmentInfo.changeInfos) { |
71 | | - rows.push({ |
72 | | - rowId: `${this.rowIdPrefix}${this.rowId++}`, |
73 | | - data: [ |
74 | | - createRowDataParam('componentName', lwcAssessmentInfo.name, true, 1, 1, false), |
75 | | - createRowDataParam( |
76 | | - 'fileReference', |
77 | | - fileChangeInfo.name, |
78 | | - false, |
79 | | - 1, |
80 | | - 1, |
81 | | - true, |
82 | | - fileChangeInfo.path, |
83 | | - fileChangeInfo.name |
84 | | - ), |
85 | | - createRowDataParam( |
86 | | - 'status', |
87 | | - lwcAssessmentInfo.errors.length > 0 ? 'Has Errors' : 'Can be Automated', |
88 | | - false, |
89 | | - 1, |
90 | | - 1, |
91 | | - false, |
92 | | - undefined, |
93 | | - undefined, |
94 | | - lwcAssessmentInfo.errors.length > 0 ? 'text-error' : 'text-success' |
95 | | - ), |
96 | | - createRowDataParam( |
97 | | - 'diff', |
98 | | - fileChangeInfo.name + '_diff', |
99 | | - false, |
100 | | - 1, |
101 | | - 1, |
102 | | - false, |
103 | | - undefined, |
104 | | - FileDiffUtil.getDiffHTML(fileChangeInfo.diff, fileChangeInfo.name) |
105 | | - ), |
106 | | - createRowDataParam( |
107 | | - 'errors', |
108 | | - lwcAssessmentInfo.errors ? lwcAssessmentInfo.errors.join(', ') : '', |
109 | | - false, |
110 | | - 1, |
111 | | - 1, |
112 | | - false, |
113 | | - undefined, |
114 | | - lwcAssessmentInfo.errors ? reportingHelper.decorateErrors(lwcAssessmentInfo.errors) : [] |
115 | | - ), |
116 | | - ], |
117 | | - }); |
118 | | - } |
119 | | - } else { |
120 | | - // Create a single row for components without file changes but with errors |
121 | | - rows.push({ |
122 | | - rowId: `${this.rowIdPrefix}${this.rowId++}`, |
123 | | - data: [ |
124 | | - createRowDataParam('componentName', lwcAssessmentInfo.name, true, 1, 1, false), |
125 | | - createRowDataParam('fileReference', 'No file changes', false, 1, 1, false), |
126 | | - createRowDataParam( |
127 | | - 'status', |
128 | | - lwcAssessmentInfo.errors.length > 0 ? 'Has Errors' : 'Can be Automated', |
129 | | - false, |
130 | | - 1, |
131 | | - 1, |
132 | | - false, |
133 | | - undefined, |
134 | | - undefined, |
135 | | - lwcAssessmentInfo.errors.length > 0 ? 'text-error' : 'text-success' |
136 | | - ), |
137 | | - createRowDataParam('diff', 'No diff available', false, 1, 1, false), |
138 | | - createRowDataParam( |
139 | | - 'errors', |
140 | | - lwcAssessmentInfo.errors ? lwcAssessmentInfo.errors.join(', ') : '', |
141 | | - false, |
142 | | - 1, |
143 | | - 1, |
144 | | - false, |
145 | | - undefined, |
146 | | - lwcAssessmentInfo.errors ? reportingHelper.decorateErrors(lwcAssessmentInfo.errors) : [] |
147 | | - ), |
148 | | - ], |
149 | | - }); |
150 | | - } |
151 | | - } |
| 115 | +// const reportFrameworkParameters: ReportFrameworkParameters<RowType> = { |
| 116 | +// headerColumns: headerColumn, |
| 117 | +// columns, |
| 118 | +// rows, |
| 119 | +// orgDetails: org, |
| 120 | +// filters, |
| 121 | +// ctaSummary: [], |
| 122 | +// reportHeaderLabel: 'LWC Assessment', |
| 123 | +// showMigrationBanner: true, |
| 124 | +// }; |
| 125 | +// // Render table |
| 126 | +// const tableHtml = generateHtmlTable(reportFrameworkParameters); |
| 127 | +// return `${tableHtml}`; |
| 128 | +// } |
152 | 129 |
|
153 | | - return rows; |
154 | | - } |
155 | | - |
156 | | - private static getFilterGroupsForReport(lwcAssessmentInfos: LWCAssessmentInfo[]): FilterGroupParam[] { |
157 | | - const componentNames = Array.from(new Set(lwcAssessmentInfos.map((info) => info.name))); |
158 | | - const statusOptions = Array.from( |
159 | | - new Set(lwcAssessmentInfos.map((info) => (info.errors.length > 0 ? 'Has Errors' : 'Can be Automated'))) |
160 | | - ); |
161 | | - const errorMessages = Array.from( |
162 | | - new Set(lwcAssessmentInfos.filter((info) => info.errors && info.errors.length > 0).flatMap((info) => info.errors)) |
163 | | - ); |
164 | | - |
165 | | - return [ |
166 | | - createFilterGroupParam('Filter By Component', 'componentName', componentNames), |
167 | | - createFilterGroupParam('Filter By Status', 'status', statusOptions), |
168 | | - createFilterGroupParam('Filter By Errors', 'errors', errorMessages), |
169 | | - ]; |
170 | | - } |
171 | | - |
172 | | - private static getHeaderGroupsForReport(): ReportHeaderGroupParam[] { |
173 | | - return [ |
174 | | - { |
175 | | - header: [ |
176 | | - { |
177 | | - name: 'Component Name', |
178 | | - colspan: 1, |
179 | | - rowspan: 1, |
180 | | - }, |
181 | | - { |
182 | | - name: 'File Reference', |
183 | | - colspan: 1, |
184 | | - rowspan: 1, |
185 | | - }, |
186 | | - { |
187 | | - name: 'Assessment Status', |
188 | | - colspan: 1, |
189 | | - rowspan: 1, |
190 | | - }, |
191 | | - { |
192 | | - name: 'Diff', |
193 | | - colspan: 1, |
194 | | - rowspan: 1, |
195 | | - }, |
196 | | - { |
197 | | - name: 'Errors', |
198 | | - colspan: 1, |
199 | | - rowspan: 1, |
200 | | - }, |
201 | | - ], |
202 | | - }, |
203 | | - ]; |
204 | | - } |
205 | | - |
206 | | - private static getCallToAction(lwcAssessmentInfos: LWCAssessmentInfo[]): CTASummary[] { |
207 | | - // For LWC assessment, we'll create a simple call to action based on errors |
208 | | - const hasErrors = lwcAssessmentInfos.some((info) => info.errors && info.errors.length > 0); |
209 | | - |
210 | | - if (hasErrors) { |
211 | | - return [ |
212 | | - { |
213 | | - name: 'LWC_MIGRATION_ERRORS', |
214 | | - message: 'Some Lightning Web Components have errors that need to be addressed before migration.', |
215 | | - link: '#', // Add appropriate documentation link here |
216 | | - }, |
217 | | - ]; |
218 | | - } |
219 | | - |
220 | | - return []; |
221 | | - } |
222 | | -} |
| 130 | +// private static generateRows(lwcAssessmentInfos: LWCAssessmentInfo[]): RowType[] { |
| 131 | +// const rows: RowType[] = []; |
| 132 | +// for (const lwcAssessmentInfo of lwcAssessmentInfos) { |
| 133 | +// for (const fileChangeInfo of lwcAssessmentInfo.changeInfos) { |
| 134 | +// rows.push({ |
| 135 | +// name: lwcAssessmentInfo.name, |
| 136 | +// filePath: fileChangeInfo.path, |
| 137 | +// fileName: fileChangeInfo.name, |
| 138 | +// diff: fileChangeInfo.diff, |
| 139 | +// migrationStatus: '', |
| 140 | +// errors: lwcAssessmentInfo.errors.join(', '), |
| 141 | +// }); |
| 142 | +// } |
| 143 | +// } |
| 144 | +// return rows; |
| 145 | +// } |
| 146 | +// } |
0 commit comments