@openshift-migration-advisor/shared-components 0.25.0 → 0.27.0-3f8ae10b086b

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 (138) hide show
  1. package/README.md +25 -0
  2. package/dist/report/ChartDownloadButton.d.ts +11 -0
  3. package/dist/report/ChartDownloadButton.d.ts.map +1 -0
  4. package/dist/report/ChartDownloadButton.js +24 -0
  5. package/dist/report/ChartExportProvider.d.ts +23 -0
  6. package/dist/report/ChartExportProvider.d.ts.map +1 -0
  7. package/dist/report/ChartExportProvider.js +222 -0
  8. package/dist/report/ChartExportSurface.d.ts +12 -0
  9. package/dist/report/ChartExportSurface.d.ts.map +1 -0
  10. package/dist/report/ChartExportSurface.js +32 -0
  11. package/dist/report/ClustersOverview.d.ts +24 -0
  12. package/dist/report/ClustersOverview.d.ts.map +1 -0
  13. package/dist/report/ClustersOverview.js +228 -0
  14. package/dist/report/ClustersOverviewStyles.d.ts +12 -0
  15. package/dist/report/ClustersOverviewStyles.d.ts.map +1 -0
  16. package/dist/report/ClustersOverviewStyles.js +101 -0
  17. package/dist/report/CpuAndMemoryOverview.d.ts +19 -0
  18. package/dist/report/CpuAndMemoryOverview.d.ts.map +1 -0
  19. package/dist/report/CpuAndMemoryOverview.js +112 -0
  20. package/dist/report/ErrorTable.d.ts +18 -0
  21. package/dist/report/ErrorTable.d.ts.map +1 -0
  22. package/dist/report/ErrorTable.js +20 -0
  23. package/dist/report/HostPowerStates.d.ts +0 -1
  24. package/dist/report/HostPowerStates.d.ts.map +1 -1
  25. package/dist/report/HostPowerStates.js +2 -2
  26. package/dist/report/HostsOverview.d.ts +13 -0
  27. package/dist/report/HostsOverview.d.ts.map +1 -0
  28. package/dist/report/HostsOverview.js +84 -0
  29. package/dist/report/InfrastructureSummary.d.ts.map +1 -1
  30. package/dist/report/InfrastructureSummary.js +6 -2
  31. package/dist/report/NetworkOverview.d.ts +31 -0
  32. package/dist/report/NetworkOverview.d.ts.map +1 -0
  33. package/dist/report/NetworkOverview.js +201 -0
  34. package/dist/report/OSDistribution.d.ts +0 -2
  35. package/dist/report/OSDistribution.d.ts.map +1 -1
  36. package/dist/report/OSDistribution.js +8 -5
  37. package/dist/report/OsUpgradeRecommendationPopover.d.ts +0 -1
  38. package/dist/report/OsUpgradeRecommendationPopover.d.ts.map +1 -1
  39. package/dist/report/OsUpgradeRecommendationPopover.js +4 -3
  40. package/dist/report/PowerStateCard.d.ts +0 -1
  41. package/dist/report/PowerStateCard.d.ts.map +1 -1
  42. package/dist/report/PowerStateCard.js +4 -2
  43. package/dist/report/ReportExportMenu.d.ts +19 -0
  44. package/dist/report/ReportExportMenu.d.ts.map +1 -0
  45. package/dist/report/ReportExportMenu.js +31 -0
  46. package/dist/report/ReportTable.d.ts +14 -0
  47. package/dist/report/ReportTable.d.ts.map +1 -0
  48. package/dist/report/ReportTable.js +23 -0
  49. package/dist/report/SupportTierBadge.d.ts +0 -1
  50. package/dist/report/SupportTierBadge.d.ts.map +1 -1
  51. package/dist/report/SupportTierBadge.js +1 -21
  52. package/dist/report/VCenterClusterDetails.d.ts +0 -1
  53. package/dist/report/VCenterClusterDetails.d.ts.map +1 -1
  54. package/dist/report/VCenterClusterDetails.js +9 -4
  55. package/dist/report/VmPowerStates.d.ts +0 -1
  56. package/dist/report/VmPowerStates.d.ts.map +1 -1
  57. package/dist/report/VmPowerStates.js +2 -2
  58. package/dist/report/WarningsTable.d.ts +9 -0
  59. package/dist/report/WarningsTable.d.ts.map +1 -0
  60. package/dist/report/WarningsTable.js +20 -0
  61. package/dist/report/captureChartElement.d.ts +8 -0
  62. package/dist/report/captureChartElement.d.ts.map +1 -0
  63. package/dist/report/captureChartElement.js +304 -0
  64. package/dist/report/chartExport.d.ts +80 -0
  65. package/dist/report/chartExport.d.ts.map +1 -0
  66. package/dist/report/chartExport.js +182 -0
  67. package/dist/report/chartExportContext.d.ts +32 -0
  68. package/dist/report/chartExportContext.d.ts.map +1 -0
  69. package/dist/report/chartExportContext.js +36 -0
  70. package/dist/report/chartExportFilenames.d.ts +4 -0
  71. package/dist/report/chartExportFilenames.d.ts.map +1 -0
  72. package/dist/report/chartExportFilenames.js +16 -0
  73. package/dist/report/constants.d.ts +2 -0
  74. package/dist/report/constants.d.ts.map +1 -1
  75. package/dist/report/constants.js +2 -0
  76. package/dist/report/dashboardStyles.d.ts +0 -4
  77. package/dist/report/dashboardStyles.d.ts.map +1 -1
  78. package/dist/report/dashboardStyles.js +0 -19
  79. package/dist/report/htmlExport.d.ts +9 -0
  80. package/dist/report/htmlExport.d.ts.map +1 -0
  81. package/dist/report/htmlExport.js +65 -0
  82. package/dist/report/index.d.ts +20 -0
  83. package/dist/report/index.d.ts.map +1 -1
  84. package/dist/report/index.js +20 -0
  85. package/dist/report/pdfExport.d.ts +3 -0
  86. package/dist/report/pdfExport.d.ts.map +1 -0
  87. package/dist/report/pdfExport.js +131 -0
  88. package/dist/report/pdfPage.d.ts +15 -0
  89. package/dist/report/pdfPage.d.ts.map +1 -0
  90. package/dist/report/pdfPage.js +44 -0
  91. package/dist/report/reportExportOptions.d.ts +17 -0
  92. package/dist/report/reportExportOptions.d.ts.map +1 -0
  93. package/dist/report/reportExportOptions.js +31 -0
  94. package/dist/report/zipChartPngs.d.ts +3 -0
  95. package/dist/report/zipChartPngs.d.ts.map +1 -0
  96. package/dist/report/zipChartPngs.js +8 -0
  97. package/package.json +7 -2
  98. package/src/report/ChartDownloadButton.tsx +59 -0
  99. package/src/report/ChartExportProvider.tsx +392 -0
  100. package/src/report/ChartExportSurface.tsx +60 -0
  101. package/src/report/ClustersOverview.tsx +451 -0
  102. package/src/report/ClustersOverviewStyles.ts +110 -0
  103. package/src/report/CpuAndMemoryOverview.tsx +277 -0
  104. package/src/report/ErrorTable.tsx +85 -0
  105. package/src/report/HostPowerStates.tsx +0 -3
  106. package/src/report/HostsOverview.tsx +185 -0
  107. package/src/report/InfrastructureSummary.tsx +48 -31
  108. package/src/report/NetworkOverview.tsx +405 -0
  109. package/src/report/OSDistribution.tsx +46 -42
  110. package/src/report/OsUpgradeRecommendationPopover.tsx +3 -4
  111. package/src/report/PowerStateCard.tsx +49 -36
  112. package/src/report/ReportExportMenu.tsx +119 -0
  113. package/src/report/ReportTable.tsx +81 -0
  114. package/src/report/SupportTierBadge.tsx +12 -40
  115. package/src/report/VCenterClusterDetails.tsx +38 -16
  116. package/src/report/VmPowerStates.tsx +0 -3
  117. package/src/report/WarningsTable.tsx +75 -0
  118. package/src/report/__tests__/ChartExportProvider.test.tsx +582 -0
  119. package/src/report/__tests__/ClustersOverview.test.tsx +241 -0
  120. package/src/report/__tests__/CpuAndMemoryOverview.test.tsx +200 -0
  121. package/src/report/__tests__/HostsOverview.test.tsx +145 -0
  122. package/src/report/__tests__/InfrastructureSummary.test.tsx +0 -22
  123. package/src/report/__tests__/NetworkOverview.test.tsx +269 -0
  124. package/src/report/__tests__/OSDistribution.test.tsx +10 -11
  125. package/src/report/__tests__/captureChartElement.test.ts +205 -0
  126. package/src/report/__tests__/chartExportPackagers.test.ts +299 -0
  127. package/src/report/captureChartElement.ts +398 -0
  128. package/src/report/chartExport.ts +277 -0
  129. package/src/report/chartExportContext.tsx +92 -0
  130. package/src/report/chartExportFilenames.ts +21 -0
  131. package/src/report/constants.ts +2 -0
  132. package/src/report/dashboardStyles.ts +0 -23
  133. package/src/report/htmlExport.ts +83 -0
  134. package/src/report/index.ts +107 -0
  135. package/src/report/pdfExport.ts +233 -0
  136. package/src/report/pdfPage.ts +83 -0
  137. package/src/report/reportExportOptions.ts +53 -0
  138. package/src/report/zipChartPngs.ts +10 -0
@@ -0,0 +1,277 @@
1
+ import type { CSSProperties } from "react";
2
+
3
+ export const CHART_EXPORT_HIDE_ATTR = "data-chart-export-hide";
4
+ export const CHART_EXPORT_SCROLL_ATTR = "data-chart-export-scroll";
5
+ export const CHART_EXPORT_CAPTURING_ATTR = "data-chart-capturing";
6
+
7
+ export const chartExportHideProps = {
8
+ [CHART_EXPORT_HIDE_ATTR]: "",
9
+ } as const;
10
+
11
+ export const chartExportScrollProps = {
12
+ [CHART_EXPORT_SCROLL_ATTR]: "",
13
+ } as const;
14
+
15
+ export const chartExportRootStyle: CSSProperties = {
16
+ width: "100%",
17
+ height: "100%",
18
+ };
19
+
20
+ export type ChartExportMeta = {
21
+ id: string;
22
+ title: string;
23
+ filename?: string;
24
+ };
25
+
26
+ export type ChartExportView = {
27
+ id: string;
28
+ title: string;
29
+ filename?: string;
30
+ };
31
+
32
+ export type RegisteredChart = {
33
+ id: string;
34
+ title: string;
35
+ filename: string;
36
+ element: HTMLElement;
37
+ exportViews?: ChartExportView[];
38
+ activeExportViewId?: string;
39
+ setExportView?: (viewId: string) => Promise<void>;
40
+ };
41
+
42
+ export type ChartExportFile = {
43
+ filename: string;
44
+ blob: Blob;
45
+ };
46
+
47
+ export type ChartCaptureSource = {
48
+ id: string;
49
+ title: string;
50
+ filename: string;
51
+ capture: () => Promise<HTMLCanvasElement>;
52
+ };
53
+
54
+ /** One label/value row rendered on a {@link PdfTextPage}. */
55
+ export type PdfTextPageItem = {
56
+ label: string;
57
+ value: string;
58
+ };
59
+
60
+ /**
61
+ * A native-text PDF page appended after the captured chart images.
62
+ *
63
+ * Used for content that is not a chart/card (e.g. calculated recommendations)
64
+ * but still needs to be part of the exported PDF.
65
+ */
66
+ export type PdfTextPage = {
67
+ title: string;
68
+ items: PdfTextPageItem[];
69
+ footer?: string;
70
+ };
71
+
72
+ export function releaseCanvas(canvas: HTMLCanvasElement): void {
73
+ canvas.width = 0;
74
+ canvas.height = 0;
75
+ }
76
+
77
+ export function waitForChartExportPaint(): Promise<void> {
78
+ if (typeof requestAnimationFrame !== "function") {
79
+ return Promise.resolve();
80
+ }
81
+ return new Promise((resolve) => {
82
+ requestAnimationFrame(() => {
83
+ requestAnimationFrame(() => resolve());
84
+ });
85
+ });
86
+ }
87
+
88
+ /** PatternFly applies dark tokens when this class is on `:root`. */
89
+ export const PATTERNFLY_DARK_THEME_CLASSES = [
90
+ "pf-v6-theme-dark",
91
+ "pf-v5-theme-dark",
92
+ ] as const;
93
+
94
+ /**
95
+ * Force PatternFly light tokens on a document (the html2canvas clone).
96
+ * Does not touch the live page.
97
+ */
98
+ export function applyLightThemeToDocument(root: Document): void {
99
+ for (const node of [root.documentElement, root.body]) {
100
+ if (!node) {
101
+ continue;
102
+ }
103
+ for (const className of PATTERNFLY_DARK_THEME_CLASSES) {
104
+ node.classList.remove(className);
105
+ }
106
+ node.style.colorScheme = "light";
107
+ }
108
+ }
109
+
110
+ export function chartExportViewsFromLabels(
111
+ titlePrefix: string,
112
+ labels: Record<string, string>,
113
+ ): ChartExportView[] {
114
+ return Object.entries(labels).map(([id, label]) => ({
115
+ id,
116
+ title: `${titlePrefix} — ${label}`,
117
+ }));
118
+ }
119
+
120
+ function shouldCycleExportViews(chart: RegisteredChart): boolean {
121
+ return Boolean(
122
+ chart.exportViews && chart.exportViews.length > 1 && chart.setExportView,
123
+ );
124
+ }
125
+
126
+ function bulkExportViews(chart: RegisteredChart): ChartExportView[] {
127
+ if (shouldCycleExportViews(chart) && chart.exportViews) {
128
+ return chart.exportViews;
129
+ }
130
+ return [
131
+ {
132
+ id: chart.id,
133
+ title: chart.title,
134
+ filename: chart.filename,
135
+ },
136
+ ];
137
+ }
138
+
139
+ export function toBulkChartCaptureSources(
140
+ charts: RegisteredChart[],
141
+ capture: (element: HTMLElement) => Promise<HTMLCanvasElement>,
142
+ prepareElement?: (element: HTMLElement) => () => void,
143
+ ): ChartCaptureSource[] {
144
+ return charts.flatMap((chart) => {
145
+ const views = bulkExportViews(chart);
146
+ const cyclesViews = shouldCycleExportViews(chart);
147
+ return views.map((view) => ({
148
+ id: cyclesViews ? `${chart.id}--${view.id}` : chart.id,
149
+ title: view.title,
150
+ filename:
151
+ view.filename ??
152
+ (cyclesViews
153
+ ? chartPngFilename(view.title, `${chart.id}-${view.id}`)
154
+ : chart.filename),
155
+ capture: async () => {
156
+ const restore = prepareElement?.(chart.element);
157
+ try {
158
+ if (cyclesViews && chart.setExportView) {
159
+ await chart.setExportView(view.id);
160
+ }
161
+ return await capture(chart.element);
162
+ } finally {
163
+ restore?.();
164
+ }
165
+ },
166
+ }));
167
+ });
168
+ }
169
+
170
+ export async function restoreChartExportViews(
171
+ charts: RegisteredChart[],
172
+ ): Promise<void> {
173
+ for (const chart of charts) {
174
+ if (
175
+ shouldCycleExportViews(chart) &&
176
+ chart.setExportView &&
177
+ chart.activeExportViewId
178
+ ) {
179
+ try {
180
+ await chart.setExportView(chart.activeExportViewId);
181
+ } catch (error) {
182
+ console.error("Failed to restore the selected chart view:", error);
183
+ }
184
+ }
185
+ }
186
+ }
187
+
188
+ export function sortRegisteredChartsByDocumentOrder(
189
+ charts: RegisteredChart[],
190
+ ): RegisteredChart[] {
191
+ return [...charts].sort((left, right) => {
192
+ if (left.element === right.element) {
193
+ return 0;
194
+ }
195
+ const position = left.element.compareDocumentPosition(right.element);
196
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
197
+ return -1;
198
+ }
199
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) {
200
+ return 1;
201
+ }
202
+ return 0;
203
+ });
204
+ }
205
+
206
+ export function canvasToBlob(canvas: HTMLCanvasElement): Promise<Blob> {
207
+ return new Promise((resolve, reject) => {
208
+ if (canvas.width < 1 || canvas.height < 1) {
209
+ reject(new Error("Failed to encode canvas as PNG"));
210
+ return;
211
+ }
212
+ canvas.toBlob((blob) => {
213
+ if (blob) {
214
+ resolve(blob);
215
+ return;
216
+ }
217
+ reject(new Error("Failed to encode canvas as PNG"));
218
+ }, "image/png");
219
+ });
220
+ }
221
+
222
+ export function slugifyExportName(value: string): string {
223
+ const slug = value
224
+ .toLowerCase()
225
+ .replace(/[^a-z0-9]+/g, "-")
226
+ .replace(/^-|-$/g, "");
227
+ return slug || "chart";
228
+ }
229
+
230
+ export function chartPngFilename(title: string, id = "chart"): string {
231
+ return `${slugifyExportName(title) || slugifyExportName(id)}.png`;
232
+ }
233
+
234
+ const KEEP_TAGS = new Set(["HTML", "HEAD", "BODY", "STYLE", "LINK"]);
235
+
236
+ function isHiddenForChartExport(node: Element): boolean {
237
+ return (
238
+ node.hasAttribute(CHART_EXPORT_HIDE_ATTR) ||
239
+ Boolean(node.closest(`[${CHART_EXPORT_HIDE_ATTR}]`))
240
+ );
241
+ }
242
+
243
+ /**
244
+ * html2canvas clones the whole document for every capture. Ignore everything
245
+ * except the target card (and ancestors / stylesheet nodes) so zip-all does
246
+ * not re-render every other chart.
247
+ */
248
+ export function shouldIgnoreChartExportElement(
249
+ node: Element,
250
+ captureRoot?: Element | null,
251
+ ): boolean {
252
+ if (!captureRoot) {
253
+ return isHiddenForChartExport(node);
254
+ }
255
+ if (KEEP_TAGS.has(node.tagName)) {
256
+ return false;
257
+ }
258
+ if (
259
+ node !== captureRoot &&
260
+ !captureRoot.contains(node) &&
261
+ !node.contains(captureRoot)
262
+ ) {
263
+ return true;
264
+ }
265
+ return isHiddenForChartExport(node);
266
+ }
267
+
268
+ export function downloadBlob(blob: Blob, filename: string): void {
269
+ const url = URL.createObjectURL(blob);
270
+ const link = document.createElement("a");
271
+ link.href = url;
272
+ link.download = filename;
273
+ document.body.appendChild(link);
274
+ link.click();
275
+ document.body.removeChild(link);
276
+ URL.revokeObjectURL(url);
277
+ }
@@ -0,0 +1,92 @@
1
+ import {
2
+ createContext,
3
+ type RefCallback,
4
+ useContext,
5
+ useEffect,
6
+ useState,
7
+ } from "react";
8
+ import {
9
+ type ChartExportMeta,
10
+ type ChartExportView,
11
+ chartPngFilename,
12
+ type PdfTextPage,
13
+ type RegisteredChart,
14
+ } from "./chartExport.js";
15
+
16
+ export type ChartExportFormat = "pdf" | "png" | "html";
17
+
18
+ export type ChartExportApi = {
19
+ downloadChart: (id: string) => Promise<void>;
20
+ downloadAll: () => Promise<void>;
21
+ /**
22
+ * @param extraPages - Native-text pages appended after the captured chart
23
+ * images (e.g. calculated recommendations that aren't rendered as charts).
24
+ */
25
+ downloadPdf: (
26
+ documentTitle: string,
27
+ extraPages?: PdfTextPage[],
28
+ ) => Promise<void>;
29
+ downloadHtml: (documentTitle: string) => Promise<void>;
30
+ downloadingChartId: string | null;
31
+ exportingFormat: ChartExportFormat | null;
32
+ exportLoadingLabel: string | null;
33
+ isExportingAll: boolean;
34
+ isBusy: boolean;
35
+ exportError: string | null;
36
+ clearExportError: () => void;
37
+ };
38
+
39
+ export type ChartExportRegistry = {
40
+ register: (chart: RegisteredChart) => () => void;
41
+ };
42
+
43
+ export const ChartExportRegistryContext =
44
+ createContext<ChartExportRegistry | null>(null);
45
+ export const ChartExportApiContext = createContext<ChartExportApi | null>(null);
46
+
47
+ export function useChartExport(): ChartExportApi | null {
48
+ return useContext(ChartExportApiContext);
49
+ }
50
+
51
+ export function useRegisterChart({
52
+ id,
53
+ title,
54
+ filename,
55
+ exportViews,
56
+ activeExportViewId,
57
+ setExportView,
58
+ }: ChartExportMeta & {
59
+ exportViews?: ChartExportView[];
60
+ activeExportViewId?: string;
61
+ setExportView?: (viewId: string) => Promise<void>;
62
+ }): RefCallback<HTMLElement> {
63
+ const registry = useContext(ChartExportRegistryContext);
64
+ const [element, setElement] = useState<HTMLElement | null>(null);
65
+ const resolvedFilename = filename ?? chartPngFilename(title, id);
66
+
67
+ useEffect(() => {
68
+ if (!registry || !element) {
69
+ return;
70
+ }
71
+ return registry.register({
72
+ id,
73
+ title,
74
+ filename: resolvedFilename,
75
+ element,
76
+ exportViews,
77
+ activeExportViewId,
78
+ setExportView,
79
+ });
80
+ }, [
81
+ activeExportViewId,
82
+ element,
83
+ exportViews,
84
+ id,
85
+ registry,
86
+ resolvedFilename,
87
+ setExportView,
88
+ title,
89
+ ]);
90
+
91
+ return setElement;
92
+ }
@@ -0,0 +1,21 @@
1
+ export function getDatedChartExportBasename(date = new Date()): string {
2
+ const year = date.getFullYear();
3
+ const month = String(date.getMonth() + 1).padStart(2, "0");
4
+ const day = String(date.getDate()).padStart(2, "0");
5
+ return `migration-export-${year}-${month}-${day}`;
6
+ }
7
+
8
+ export function getChartExportFilename(
9
+ format: "pdf" | "html" | "zip",
10
+ date = new Date(),
11
+ ): string {
12
+ const base = getDatedChartExportBasename(date);
13
+ if (format === "zip") {
14
+ return `${base}-charts.zip`;
15
+ }
16
+ return `${base}.${format}`;
17
+ }
18
+
19
+ export function getChartZipFilename(date = new Date()): string {
20
+ return getChartExportFilename("zip", date);
21
+ }
@@ -25,6 +25,8 @@ export const REPORT_CARD_EMPTY_STATE_TITLES = {
25
25
  operatingSystems: "Operating system data not collected",
26
26
  migrationStatus: "Migration status data not collected",
27
27
  issuesBreakdown: "Issues breakdown data not collected",
28
+ errors: "Error data not collected",
29
+ warnings: "Warning data not collected",
28
30
  hostPowerStates: "Host power state data not collected",
29
31
  vmPowerStates: "VM power state data not collected",
30
32
  } as const;
@@ -47,23 +47,10 @@ export const dashboardStyles = {
47
47
  overflow: hidden !important;
48
48
  `,
49
49
 
50
- cardPrint: css`
51
- border: 1px solid #d2d2d2 !important;
52
- border-radius: 10px;
53
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
54
- min-height: unset;
55
- max-height: unset;
56
- page-break-inside: avoid;
57
- `,
58
-
59
50
  storageCardOverflowHidden: css`
60
51
  overflow: hidden;
61
52
  `,
62
53
 
63
- storageCardOverflowVisible: css`
64
- overflow: visible;
65
- `,
66
-
67
54
  storageChartWrapper: css`
68
55
  display: flex;
69
56
  justify-content: center;
@@ -72,16 +59,6 @@ export const dashboardStyles = {
72
59
  padding: 20px 0;
73
60
  `,
74
61
 
75
- storageExportSectionMargin: css`
76
- margin-bottom: 24px;
77
- `,
78
-
79
- storageExportSectionTitle: css`
80
- font-size: 14px;
81
- font-weight: 600;
82
- margin-bottom: 12px;
83
- `,
84
-
85
62
  storageFlexFullWidth: css`
86
63
  width: 100%;
87
64
  `,
@@ -0,0 +1,83 @@
1
+ import { type ChartCaptureSource, releaseCanvas } from "./chartExport.js";
2
+
3
+ export interface HtmlReportImage {
4
+ name: string;
5
+ dataUrl: string;
6
+ }
7
+
8
+ export function escapeHtml(value: string): string {
9
+ return value
10
+ .replace(/&/g, "&amp;")
11
+ .replace(/</g, "&lt;")
12
+ .replace(/>/g, "&gt;")
13
+ .replace(/"/g, "&quot;")
14
+ .replace(/'/g, "&#39;");
15
+ }
16
+
17
+ export function buildHtmlReport(
18
+ documentTitle: string,
19
+ images: HtmlReportImage[],
20
+ generatedAt = new Date(),
21
+ ): string {
22
+ const sections = images
23
+ .map(
24
+ (image) => `
25
+ <section>
26
+ <h2>${escapeHtml(image.name)}</h2>
27
+ <img src="${image.dataUrl}" alt="${escapeHtml(image.name)}" />
28
+ </section>`,
29
+ )
30
+ .join("\n");
31
+
32
+ return `<!DOCTYPE html>
33
+ <html lang="en">
34
+ <head>
35
+ <meta charset="utf-8" />
36
+ <title>${escapeHtml(documentTitle)}</title>
37
+ <style>
38
+ body {
39
+ font-family: RedHatText, Helvetica, Arial, sans-serif;
40
+ margin: 32px auto;
41
+ max-width: 1100px;
42
+ background: #fff;
43
+ color: #151515;
44
+ }
45
+ h1 { font-size: 28px; margin-bottom: 8px; }
46
+ h2 { font-size: 18px; margin: 32px 0 12px; }
47
+ .meta { color: #6a6e73; margin-bottom: 24px; }
48
+ img {
49
+ width: 100%;
50
+ height: auto;
51
+ }
52
+ </style>
53
+ </head>
54
+ <body>
55
+ <h1>${escapeHtml(documentTitle)}</h1>
56
+ <p class="meta">Generated ${escapeHtml(generatedAt.toLocaleString())}</p>
57
+ ${sections}
58
+ </body>
59
+ </html>
60
+ `;
61
+ }
62
+
63
+ export async function buildHtmlFromCharts(
64
+ charts: ChartCaptureSource[],
65
+ documentTitle: string,
66
+ ): Promise<Blob> {
67
+ const images: HtmlReportImage[] = [];
68
+ for (const chart of charts) {
69
+ const canvas = await chart.capture();
70
+ try {
71
+ images.push({
72
+ name: chart.title,
73
+ dataUrl: canvas.toDataURL("image/png"),
74
+ });
75
+ } finally {
76
+ releaseCanvas(canvas);
77
+ }
78
+ }
79
+
80
+ return new Blob([buildHtmlReport(documentTitle, images)], {
81
+ type: "text/html;charset=utf-8",
82
+ });
83
+ }
@@ -3,6 +3,66 @@ export {
3
3
  CardEmptyState,
4
4
  type CardEmptyStateProps,
5
5
  } from "./CardEmptyState.js";
6
+ export {
7
+ ChartDownloadButton,
8
+ ChartHeaderActions,
9
+ } from "./ChartDownloadButton.js";
10
+ export {
11
+ type BuildChartDocument,
12
+ type BuildPdfDocument,
13
+ type CaptureChartElement,
14
+ ChartExportProvider,
15
+ type ChartExportProviderProps,
16
+ type EncodeChartPng,
17
+ type ZipChartFiles,
18
+ } from "./ChartExportProvider.js";
19
+ export { ChartExportSurface } from "./ChartExportSurface.js";
20
+ export {
21
+ ClustersOverview,
22
+ type ClustersOverviewProps,
23
+ type InventoryDataLike,
24
+ } from "./ClustersOverview.js";
25
+ export {
26
+ CpuAndMemoryOverview,
27
+ type CpuAndMemoryOverviewProps,
28
+ } from "./CpuAndMemoryOverview.js";
29
+ export { captureChartElement } from "./captureChartElement.js";
30
+ export {
31
+ CHART_EXPORT_CAPTURING_ATTR,
32
+ CHART_EXPORT_HIDE_ATTR,
33
+ CHART_EXPORT_SCROLL_ATTR,
34
+ type ChartCaptureSource,
35
+ type ChartExportFile,
36
+ type ChartExportMeta,
37
+ type ChartExportView,
38
+ canvasToBlob,
39
+ chartExportHideProps,
40
+ chartExportRootStyle,
41
+ chartExportScrollProps,
42
+ chartExportViewsFromLabels,
43
+ chartPngFilename,
44
+ downloadBlob,
45
+ type PdfTextPage,
46
+ type PdfTextPageItem,
47
+ type RegisteredChart,
48
+ releaseCanvas,
49
+ restoreChartExportViews,
50
+ shouldIgnoreChartExportElement,
51
+ slugifyExportName,
52
+ sortRegisteredChartsByDocumentOrder,
53
+ toBulkChartCaptureSources,
54
+ } from "./chartExport.js";
55
+ export {
56
+ type ChartExportApi,
57
+ type ChartExportFormat,
58
+ useChartExport,
59
+ useRegisterChart,
60
+ } from "./chartExportContext.js";
61
+ export {
62
+ getChartExportFilename,
63
+ getChartZipFilename,
64
+ getDatedChartExportBasename,
65
+ } from "./chartExportFilenames.js";
6
66
  export {
7
67
  chartColorFailure,
8
68
  chartColorSuccess,
@@ -17,6 +77,11 @@ export {
17
77
  EmptySearchResults,
18
78
  type EmptySearchResultsProps,
19
79
  } from "./EmptySearchResults.js";
80
+ export {
81
+ ErrorTable,
82
+ type ErrorTableProps,
83
+ type MigrationIssueLike,
84
+ } from "./ErrorTable.js";
20
85
  export {
21
86
  FeatureStatusBadge,
22
87
  type FeatureStatusBadgeProps,
@@ -25,6 +90,17 @@ export {
25
90
  HostPowerStates,
26
91
  type HostPowerStatesProps,
27
92
  } from "./HostPowerStates.js";
93
+ export {
94
+ type HostLike,
95
+ HostsOverview,
96
+ type HostsOverviewProps,
97
+ } from "./HostsOverview.js";
98
+ export {
99
+ buildHtmlFromCharts,
100
+ buildHtmlReport,
101
+ escapeHtml,
102
+ type HtmlReportImage,
103
+ } from "./htmlExport.js";
28
104
  export {
29
105
  InfrastructureSummary,
30
106
  type InfrastructureSummaryProps,
@@ -54,6 +130,14 @@ export {
54
130
  visibleNetworks,
55
131
  vsanStatus,
56
132
  } from "./infrastructureSummaryModel.js";
133
+ export {
134
+ type NetworkInfraLike,
135
+ type NetworkLike,
136
+ NetworkOverview,
137
+ type NetworkOverviewProps,
138
+ type NicCountHistogram,
139
+ type NicCountSummary,
140
+ } from "./NetworkOverview.js";
57
141
  export { OSBarChart, OSDistribution } from "./OSDistribution.js";
58
142
  export { OsSupportTiersHelpPopover } from "./OsSupportTiersHelpPopover.js";
59
143
  export { OsUpgradeNotice } from "./OsUpgradeNotice.js";
@@ -86,6 +170,12 @@ export {
86
170
  PowerStateCard,
87
171
  type PowerStateCardProps,
88
172
  } from "./PowerStateCard.js";
173
+ export { buildPdfFromCharts } from "./pdfExport.js";
174
+ export {
175
+ type PdfExportSegment,
176
+ sliceCanvas,
177
+ splitSegmentForPageHeight,
178
+ } from "./pdfPage.js";
89
179
  export type { PowerStateChartModel } from "./powerStates.js";
90
180
  export {
91
181
  buildHostPowerStateChart,
@@ -93,6 +183,18 @@ export {
93
183
  HOST_POWER_COLORS,
94
184
  VM_POWER_COLORS,
95
185
  } from "./powerStates.js";
186
+ export {
187
+ ExportReportButton,
188
+ type ExportReportButtonProps,
189
+ ReportExportMenu,
190
+ type ReportExportMenuProps,
191
+ } from "./ReportExportMenu.js";
192
+ export { ReportTable, type ReportTableProps } from "./ReportTable.js";
193
+ export {
194
+ type ReportExportOption,
195
+ type StandardReportExportHandlers,
196
+ standardReportExportOptions,
197
+ } from "./reportExportOptions.js";
96
198
  export { SupportTierBadge } from "./SupportTierBadge.js";
97
199
  export {
98
200
  ALL_TIERS_FILTER,
@@ -108,3 +210,8 @@ export {
108
210
  VmPowerStates,
109
211
  type VmPowerStatesProps,
110
212
  } from "./VmPowerStates.js";
213
+ export {
214
+ WarningsTable,
215
+ type WarningsTableProps,
216
+ } from "./WarningsTable.js";
217
+ export { zipChartPngs } from "./zipChartPngs.js";