|
1 | 1 | import { DataRaptorAssessmentInfo } from '../interfaces'; |
| 2 | +import { Filter, HeaderColumn, ReportHeaderFormat, TableColumn } from '../reportGenerator/reportInterfaces'; |
| 3 | +import { generateHtmlTable } from '../reportGenerator/reportGenerator'; |
2 | 4 | import { reportingHelper } from './reportingHelper'; |
3 | 5 |
|
4 | 6 | export class DRAssessmentReporter { |
5 | 7 | public static generateDRAssesment( |
6 | 8 | dataRaptorAssessmentInfos: DataRaptorAssessmentInfo[], |
7 | | - instanceUrl: string |
| 9 | + instanceUrl: string, |
| 10 | + org: ReportHeaderFormat[] |
8 | 11 | ): string { |
9 | | - let tableBody = ''; |
10 | | - tableBody += '<div class="slds-text-heading_large">Data Mapper Components Assessment</div>'; |
11 | | - for (const dr of dataRaptorAssessmentInfos) { |
12 | | - const row = ` |
13 | | - <tr class="slds-hint_parent"> |
14 | | - <td style="word-wrap: break-word; white-space: normal; max-width: 200px;"> |
15 | | - <div class="slds-truncate" title="${dr.name}">${dr.name}</div> |
16 | | - </td> |
17 | | - <td style="word-wrap: break-word; white-space: normal; max-width: 100px;"> |
18 | | - <div class="slds-truncate" title="${dr.id}"> |
19 | | - <a href="${instanceUrl}/${dr.id}">${dr.id}</div> |
20 | | - </td> |
21 | | - <td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;"> |
22 | | - ${reportingHelper.convertToBuletedList(dr.warnings)} |
23 | | - </td> |
24 | | - <td style="word-wrap: break-word; white-space: normal; max-width: 200px;"> |
25 | | - <div> ${reportingHelper.decorateChanges(dr.formulaChanges, 'Formula')} </div> |
26 | | - </td> |
27 | | - <td style="word-wrap: break-word; white-space: normal; max-width: 60%; overflow: hidden;"> |
28 | | - ${reportingHelper.convertToBuletedList(dr.apexDependencies)} |
29 | | - </td> |
| 12 | + // Header Column |
| 13 | + const headerColumn: HeaderColumn[] = [ |
| 14 | + { |
| 15 | + label: 'In Package', |
| 16 | + colspan: 2, |
| 17 | + styles: 'color: purple;', |
| 18 | + subColumn: [ |
| 19 | + { |
| 20 | + label: 'Name', |
| 21 | + key: 'oldName', |
| 22 | + }, |
| 23 | + { |
| 24 | + label: 'Record ID', |
| 25 | + key: 'id', |
| 26 | + }, |
| 27 | + ], |
| 28 | + }, |
| 29 | + { |
| 30 | + label: 'In Core', |
| 31 | + colspan: 1, |
| 32 | + subColumn: [ |
| 33 | + { |
| 34 | + label: 'Name', |
| 35 | + key: 'name', |
| 36 | + }, |
| 37 | + ], |
| 38 | + }, |
| 39 | + { |
| 40 | + label: 'Type', |
| 41 | + key: 'type', |
| 42 | + rowspan: 2, |
| 43 | + subColumn: [], |
| 44 | + }, |
| 45 | + { |
| 46 | + label: 'Summary', |
| 47 | + key: 'summary', |
| 48 | + rowspan: 2, |
| 49 | + subColumn: [], |
| 50 | + }, |
| 51 | + { |
| 52 | + label: 'Custom Function Changes', |
| 53 | + key: 'customFunctionChanges', |
| 54 | + rowspan: 2, |
| 55 | + subColumn: [], |
| 56 | + }, |
| 57 | + { |
| 58 | + label: 'Apex Dependencies', |
| 59 | + key: 'apexDependencies', |
| 60 | + rowspan: 2, |
| 61 | + subColumn: [], |
| 62 | + }, |
| 63 | + ]; |
30 | 64 |
|
31 | | - </tr>`; |
32 | | - tableBody += row; |
33 | | - } |
| 65 | + // Define columns |
| 66 | + const columns: Array<TableColumn<DataRaptorAssessmentInfo>> = [ |
| 67 | + { |
| 68 | + key: 'oldName', |
| 69 | + cell: (row: DataRaptorAssessmentInfo): string => row.oldName, |
| 70 | + filterValue: (row: DataRaptorAssessmentInfo): string => row.oldName, |
| 71 | + title: (row: DataRaptorAssessmentInfo): string => row.oldName, |
| 72 | + }, |
| 73 | + { |
| 74 | + key: 'id', |
| 75 | + cell: (row: DataRaptorAssessmentInfo): string => |
| 76 | + row.id ? `<a href="${instanceUrl}/${row.id}">${row.id}</a>` : '', |
| 77 | + filterValue: (row: DataRaptorAssessmentInfo): string => row.id, |
| 78 | + title: (row: DataRaptorAssessmentInfo): string => row.id, |
| 79 | + }, |
| 80 | + { |
| 81 | + key: 'name', |
| 82 | + cell: (row: DataRaptorAssessmentInfo): string => row.name || '', |
| 83 | + filterValue: (row: DataRaptorAssessmentInfo): string => row.name, |
| 84 | + title: (row: DataRaptorAssessmentInfo): string => row.name, |
| 85 | + }, |
| 86 | + { |
| 87 | + key: 'type', |
| 88 | + cell: (row: DataRaptorAssessmentInfo): string => row.type, |
| 89 | + filterValue: (row: DataRaptorAssessmentInfo): string => row.type, |
| 90 | + title: (row: DataRaptorAssessmentInfo): string => row.type, |
| 91 | + }, |
| 92 | + { |
| 93 | + key: 'summary', |
| 94 | + cell: (row: DataRaptorAssessmentInfo): string => reportingHelper.convertToBuletedList(row.warnings || []), |
| 95 | + filterValue: (row: DataRaptorAssessmentInfo): string => (row.warnings ? row.warnings.join(', ') : ''), |
| 96 | + title: (row: DataRaptorAssessmentInfo): string => (row.warnings ? row.warnings.join(', ') : ''), |
| 97 | + }, |
| 98 | + { |
| 99 | + key: 'customFunctionChanges', |
| 100 | + cell: (row: DataRaptorAssessmentInfo): string => |
| 101 | + reportingHelper.decorateChanges(row.formulaChanges, 'Formula') || '', |
| 102 | + filterValue: (row: DataRaptorAssessmentInfo): typeof row.formulaChanges => row.formulaChanges, |
| 103 | + }, |
| 104 | + { |
| 105 | + key: 'apexDependencies', |
| 106 | + cell: (row: DataRaptorAssessmentInfo): string => |
| 107 | + reportingHelper.convertToBuletedList(row.apexDependencies || []), |
| 108 | + filterValue: (row: DataRaptorAssessmentInfo): string[] => row.apexDependencies, |
| 109 | + }, |
| 110 | + ]; |
34 | 111 |
|
35 | | - return DRAssessmentReporter.getDRAssessmentReport(tableBody); |
36 | | - } |
37 | | - |
38 | | - private static getDRAssessmentReport(tableContent: string): string { |
39 | | - const tableBody = ` |
40 | | - <div style="margin-block:15px"> |
41 | | - <table style="width: 100%; table-layout: auto;" class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped slds-table_col-bordered" aria-label="Results for Data Mapper updates"> |
42 | | - <thead> |
43 | | - <tr class="slds-line-height_reset"> |
44 | | - <th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;"> |
45 | | - <div class="slds-truncate" title="Name">Name</div> |
46 | | - </th> |
47 | | - <th class="" scope="col" style="width: 10%; word-wrap: break-word; white-space: normal; text-align: left;"> |
48 | | - <div class="slds-truncate" title="ID">ID</div> |
49 | | - </th> |
50 | | - <th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;"> |
51 | | - <div class="slds-truncate" title="Summary">Summary</div> |
52 | | - </th> |
53 | | - <th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;"> |
54 | | - <div class="slds-truncate" title="Custom Function Change">Custom Function Changes</div> |
55 | | - </th> |
56 | | - <th class="" scope="col" style="width: 20%; word-wrap: break-word; white-space: normal; text-align: left;"> |
57 | | - <div class="slds-truncate" title="Apex dependencies">Apex dependencies</div> |
58 | | - </th> |
59 | | - </tr> |
60 | | - </thead> |
61 | | - <tbody> |
62 | | - ${tableContent} |
63 | | - </tbody> |
64 | | - </table> |
65 | | - </div>`; |
66 | | - return tableBody; |
| 112 | + const filters: Filter[] = []; |
| 113 | + // Render table |
| 114 | + const tableHtml = generateHtmlTable( |
| 115 | + headerColumn, |
| 116 | + columns, |
| 117 | + dataRaptorAssessmentInfos, |
| 118 | + org, |
| 119 | + filters, |
| 120 | + undefined, |
| 121 | + 'Data Mapper Assessment' |
| 122 | + ); |
| 123 | + return `<div class="slds-text-heading_large">Data Mapper Assessment Report</div>${tableHtml}`; |
67 | 124 | } |
68 | 125 | } |
0 commit comments