@openshift-migration-advisor/shared-components 0.25.0-fce5293f01c1 → 0.27.0-5d313f88dc52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/report/ChartExportProvider.d.ts +3 -2
  2. package/dist/report/ChartExportProvider.d.ts.map +1 -1
  3. package/dist/report/ChartExportProvider.js +3 -3
  4. package/dist/report/ErrorTable.d.ts +18 -0
  5. package/dist/report/ErrorTable.d.ts.map +1 -0
  6. package/dist/report/ErrorTable.js +20 -0
  7. package/dist/report/HostsOverview.d.ts +13 -0
  8. package/dist/report/HostsOverview.d.ts.map +1 -0
  9. package/dist/report/HostsOverview.js +84 -0
  10. package/dist/report/ReportTable.d.ts +14 -0
  11. package/dist/report/ReportTable.d.ts.map +1 -0
  12. package/dist/report/ReportTable.js +23 -0
  13. package/dist/report/WarningsTable.d.ts +9 -0
  14. package/dist/report/WarningsTable.d.ts.map +1 -0
  15. package/dist/report/WarningsTable.js +20 -0
  16. package/dist/report/captureChartElement.d.ts.map +1 -1
  17. package/dist/report/captureChartElement.js +28 -8
  18. package/dist/report/chartExport.d.ts +23 -0
  19. package/dist/report/chartExport.d.ts.map +1 -1
  20. package/dist/report/chartExport.js +20 -0
  21. package/dist/report/chartExportContext.d.ts +6 -2
  22. package/dist/report/chartExportContext.d.ts.map +1 -1
  23. package/dist/report/constants.d.ts +2 -0
  24. package/dist/report/constants.d.ts.map +1 -1
  25. package/dist/report/constants.js +2 -0
  26. package/dist/report/index.d.ts +6 -2
  27. package/dist/report/index.d.ts.map +1 -1
  28. package/dist/report/index.js +4 -0
  29. package/dist/report/pdfExport.d.ts +2 -2
  30. package/dist/report/pdfExport.d.ts.map +1 -1
  31. package/dist/report/pdfExport.js +52 -3
  32. package/package.json +2 -2
  33. package/src/report/ChartExportProvider.tsx +13 -5
  34. package/src/report/ErrorTable.tsx +85 -0
  35. package/src/report/HostsOverview.tsx +185 -0
  36. package/src/report/ReportTable.tsx +81 -0
  37. package/src/report/WarningsTable.tsx +75 -0
  38. package/src/report/__tests__/ChartExportProvider.test.tsx +110 -2
  39. package/src/report/__tests__/HostsOverview.test.tsx +145 -0
  40. package/src/report/__tests__/captureChartElement.test.ts +73 -0
  41. package/src/report/__tests__/chartExportPackagers.test.ts +75 -0
  42. package/src/report/captureChartElement.ts +37 -7
  43. package/src/report/chartExport.ts +40 -0
  44. package/src/report/chartExportContext.tsx +9 -1
  45. package/src/report/constants.ts +2 -0
  46. package/src/report/index.ts +18 -0
  47. package/src/report/pdfExport.ts +81 -2
@@ -9,6 +9,7 @@ export {
9
9
  } from "./ChartDownloadButton.js";
10
10
  export {
11
11
  type BuildChartDocument,
12
+ type BuildPdfDocument,
12
13
  type CaptureChartElement,
13
14
  ChartExportProvider,
14
15
  type ChartExportProviderProps,
@@ -32,6 +33,8 @@ export {
32
33
  chartExportViewsFromLabels,
33
34
  chartPngFilename,
34
35
  downloadBlob,
36
+ type PdfTextPage,
37
+ type PdfTextPageItem,
35
38
  type RegisteredChart,
36
39
  releaseCanvas,
37
40
  restoreChartExportViews,
@@ -65,6 +68,11 @@ export {
65
68
  EmptySearchResults,
66
69
  type EmptySearchResultsProps,
67
70
  } from "./EmptySearchResults.js";
71
+ export {
72
+ ErrorTable,
73
+ type ErrorTableProps,
74
+ type MigrationIssueLike,
75
+ } from "./ErrorTable.js";
68
76
  export {
69
77
  FeatureStatusBadge,
70
78
  type FeatureStatusBadgeProps,
@@ -73,6 +81,11 @@ export {
73
81
  HostPowerStates,
74
82
  type HostPowerStatesProps,
75
83
  } from "./HostPowerStates.js";
84
+ export {
85
+ type HostLike,
86
+ HostsOverview,
87
+ type HostsOverviewProps,
88
+ } from "./HostsOverview.js";
76
89
  export {
77
90
  buildHtmlFromCharts,
78
91
  buildHtmlReport,
@@ -167,6 +180,7 @@ export {
167
180
  ReportExportMenu,
168
181
  type ReportExportMenuProps,
169
182
  } from "./ReportExportMenu.js";
183
+ export { ReportTable, type ReportTableProps } from "./ReportTable.js";
170
184
  export {
171
185
  type ReportExportOption,
172
186
  type StandardReportExportHandlers,
@@ -187,4 +201,8 @@ export {
187
201
  VmPowerStates,
188
202
  type VmPowerStatesProps,
189
203
  } from "./VmPowerStates.js";
204
+ export {
205
+ WarningsTable,
206
+ type WarningsTableProps,
207
+ } from "./WarningsTable.js";
190
208
  export { zipChartPngs } from "./zipChartPngs.js";
@@ -1,5 +1,9 @@
1
1
  import jsPDF from "jspdf";
2
- import { type ChartCaptureSource, releaseCanvas } from "./chartExport.js";
2
+ import {
3
+ type ChartCaptureSource,
4
+ type PdfTextPage,
5
+ releaseCanvas,
6
+ } from "./chartExport.js";
3
7
  import { fitPdfImageSize, placePdfBlock, sliceCanvas } from "./pdfPage.js";
4
8
 
5
9
  const MARGIN_MM = 10;
@@ -10,6 +14,7 @@ const PAGE_BACKGROUND = "#ffffff";
10
14
  export async function buildPdfFromCharts(
11
15
  charts: ChartCaptureSource[],
12
16
  documentTitle: string,
17
+ extraPages: PdfTextPage[] = [],
13
18
  ): Promise<Blob> {
14
19
  const pdf = new jsPDF("p", "mm", "a4");
15
20
  const pageWidth = pdf.internal.pageSize.getWidth();
@@ -22,7 +27,7 @@ export async function buildPdfFromCharts(
22
27
  addCoverPage(
23
28
  pdf,
24
29
  documentTitle,
25
- charts.map((chart) => chart.title),
30
+ [...charts.map((chart) => chart.title), ...extraPages.map((p) => p.title)],
26
31
  pageWidth,
27
32
  pageHeight,
28
33
  );
@@ -63,6 +68,10 @@ export async function buildPdfFromCharts(
63
68
  }
64
69
  }
65
70
 
71
+ if (extraPages.length > 0) {
72
+ addExtraPages(pdf, extraPages, pageWidth, pageHeight);
73
+ }
74
+
66
75
  addPageNumbers(pdf, pageWidth, pageHeight);
67
76
  return pdf.output("blob");
68
77
  }
@@ -138,6 +147,76 @@ function addChartImage(
138
147
  }
139
148
  }
140
149
 
150
+ /**
151
+ * Append one native-text PDF page per entry in `extraPages`, rendered as
152
+ * label/value rows rather than a captured image. Each page starts fresh so
153
+ * its content never bleeds into a chart page.
154
+ */
155
+ function addExtraPages(
156
+ pdf: jsPDF,
157
+ extraPages: PdfTextPage[],
158
+ pageWidth: number,
159
+ pageHeight: number,
160
+ ): void {
161
+ const LABEL_COL_WIDTH = 68; // mm — enough for the longest label
162
+ const VALUE_COL_X = MARGIN_MM + LABEL_COL_WIDTH;
163
+ const VALUE_COL_WIDTH = pageWidth - MARGIN_MM - LABEL_COL_WIDTH;
164
+ const LINE_HEIGHT = 7; // mm between rows
165
+
166
+ for (const page of extraPages) {
167
+ pdf.addPage();
168
+ let y = MARGIN_MM + 8;
169
+
170
+ pdf.setFontSize(16);
171
+ pdf.setFont("helvetica", "bold");
172
+ pdf.text(page.title, MARGIN_MM, y);
173
+ y += 10;
174
+
175
+ pdf.setDrawColor(0, 103, 187);
176
+ pdf.setLineWidth(0.5);
177
+ pdf.line(MARGIN_MM, y, pageWidth - MARGIN_MM, y);
178
+ y += 10;
179
+
180
+ pdf.setFontSize(11);
181
+
182
+ for (const item of page.items) {
183
+ pdf.setFont("helvetica", "bold");
184
+ const labelLines = pdf.splitTextToSize(
185
+ item.label,
186
+ LABEL_COL_WIDTH - 4,
187
+ ) as string[];
188
+ pdf.text(labelLines, MARGIN_MM, y);
189
+
190
+ pdf.setFont("helvetica", "normal");
191
+ const valueLines = pdf.splitTextToSize(
192
+ item.value,
193
+ VALUE_COL_WIDTH,
194
+ ) as string[];
195
+ pdf.text(valueLines, VALUE_COL_X, y);
196
+
197
+ y += LINE_HEIGHT * Math.max(labelLines.length, valueLines.length);
198
+
199
+ if (y > pageHeight - MARGIN_MM - 25) {
200
+ pdf.addPage();
201
+ y = MARGIN_MM + 10;
202
+ }
203
+ }
204
+
205
+ if (page.footer) {
206
+ y += 4;
207
+ pdf.setFontSize(9);
208
+ pdf.setFont("helvetica", "bolditalic");
209
+ const footerLines = pdf.splitTextToSize(
210
+ page.footer,
211
+ pageWidth - MARGIN_MM * 2,
212
+ ) as string[];
213
+ pdf.text(footerLines, MARGIN_MM, y);
214
+ pdf.setFont("helvetica", "normal");
215
+ pdf.setFontSize(11);
216
+ }
217
+ }
218
+ }
219
+
141
220
  function addPageNumbers(
142
221
  pdf: jsPDF,
143
222
  pageWidth: number,