@openshift-migration-advisor/shared-components 0.23.0-e6249b8ada7d → 0.24.0

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 (64) hide show
  1. package/README.md +0 -6
  2. package/dist/charts/index.d.ts +1 -1
  3. package/dist/charts/index.d.ts.map +1 -1
  4. package/dist/forms/RadioButtonFormGroup.d.ts.map +1 -1
  5. package/dist/forms/RadioButtonFormGroup.js +2 -2
  6. package/dist/report/OSDistribution.d.ts.map +1 -1
  7. package/dist/report/OSDistribution.js +13 -5
  8. package/dist/report/OsSupportTiersHelpPopover.d.ts.map +1 -1
  9. package/dist/report/OsSupportTiersHelpPopover.js +31 -2
  10. package/dist/report/OsUpgradeNotice.d.ts.map +1 -1
  11. package/dist/report/OsUpgradeNotice.js +5 -1
  12. package/dist/report/SupportTierBadge.d.ts.map +1 -1
  13. package/dist/report/SupportTierBadge.js +2 -4
  14. package/dist/report/constants.d.ts +0 -2
  15. package/dist/report/constants.d.ts.map +1 -1
  16. package/dist/report/constants.js +0 -2
  17. package/dist/report/index.d.ts +0 -10
  18. package/dist/report/index.d.ts.map +1 -1
  19. package/dist/report/index.js +0 -8
  20. package/package.json +1 -1
  21. package/src/charts/index.ts +0 -1
  22. package/src/forms/RadioButtonFormGroup.tsx +3 -10
  23. package/src/report/OSDistribution.tsx +67 -60
  24. package/src/report/OsSupportTiersHelpPopover.tsx +62 -32
  25. package/src/report/OsUpgradeNotice.tsx +7 -1
  26. package/src/report/SupportTierBadge.tsx +2 -4
  27. package/src/report/constants.ts +0 -2
  28. package/src/report/index.ts +0 -56
  29. package/dist/report/FeatureStatusBadge.d.ts +0 -7
  30. package/dist/report/FeatureStatusBadge.d.ts.map +0 -1
  31. package/dist/report/FeatureStatusBadge.js +0 -13
  32. package/dist/report/HostPowerStates.d.ts +0 -9
  33. package/dist/report/HostPowerStates.d.ts.map +0 -1
  34. package/dist/report/HostPowerStates.js +0 -11
  35. package/dist/report/InfrastructureSummary.d.ts +0 -7
  36. package/dist/report/InfrastructureSummary.d.ts.map +0 -1
  37. package/dist/report/InfrastructureSummary.js +0 -5
  38. package/dist/report/PowerStateCard.d.ts +0 -17
  39. package/dist/report/PowerStateCard.d.ts.map +0 -1
  40. package/dist/report/PowerStateCard.js +0 -7
  41. package/dist/report/VCenterClusterDetails.d.ts +0 -10
  42. package/dist/report/VCenterClusterDetails.d.ts.map +0 -1
  43. package/dist/report/VCenterClusterDetails.js +0 -26
  44. package/dist/report/VmPowerStates.d.ts +0 -9
  45. package/dist/report/VmPowerStates.d.ts.map +0 -1
  46. package/dist/report/VmPowerStates.js +0 -11
  47. package/dist/report/infrastructureSummaryModel.d.ts +0 -82
  48. package/dist/report/infrastructureSummaryModel.d.ts.map +0 -1
  49. package/dist/report/infrastructureSummaryModel.js +0 -139
  50. package/dist/report/powerStates.d.ts +0 -11
  51. package/dist/report/powerStates.d.ts.map +0 -1
  52. package/dist/report/powerStates.js +0 -113
  53. package/src/report/FeatureStatusBadge.tsx +0 -30
  54. package/src/report/HostPowerStates.tsx +0 -41
  55. package/src/report/InfrastructureSummary.tsx +0 -56
  56. package/src/report/PowerStateCard.tsx +0 -73
  57. package/src/report/VCenterClusterDetails.tsx +0 -211
  58. package/src/report/VmPowerStates.tsx +0 -41
  59. package/src/report/__tests__/HostPowerStates.test.tsx +0 -47
  60. package/src/report/__tests__/InfrastructureSummary.test.tsx +0 -148
  61. package/src/report/__tests__/infrastructureSummaryModel.test.ts +0 -224
  62. package/src/report/__tests__/powerStates.test.ts +0 -70
  63. package/src/report/infrastructureSummaryModel.ts +0 -281
  64. package/src/report/powerStates.ts +0 -169
@@ -1,169 +0,0 @@
1
- import type { MigrationDonutChartDatum } from "../charts/MigrationDonutChart.js";
2
-
3
- export type PowerStateChartModel = {
4
- slices: MigrationDonutChartDatum[];
5
- legend: Record<string, string>;
6
- total: number;
7
- };
8
-
9
- const HOST_POWER_CATEGORIES = [
10
- "Powered on",
11
- "Powered off",
12
- "Standby",
13
- "Not responding",
14
- "Maintenance",
15
- ] as const;
16
-
17
- type HostPowerCategory = (typeof HOST_POWER_CATEGORIES)[number];
18
-
19
- const HOST_POWER_KEY_ALIASES: Record<string, HostPowerCategory> = {
20
- poweredon: "Powered on",
21
- powered_on: "Powered on",
22
- green: "Powered on",
23
- poweredoff: "Powered off",
24
- powered_off: "Powered off",
25
- standby: "Standby",
26
- stand_by: "Standby",
27
- notresponding: "Not responding",
28
- not_responding: "Not responding",
29
- gray: "Not responding",
30
- grey: "Not responding",
31
- red: "Not responding",
32
- maintenance: "Maintenance",
33
- inmaintenance: "Maintenance",
34
- inmaintenancemode: "Maintenance",
35
- };
36
-
37
- export const HOST_POWER_COLORS: Record<string, string> = {
38
- "Powered on": "#0066cc",
39
- "Powered off": "#dca614",
40
- Standby: "#f0ab00",
41
- "Not responding": "#c9190b",
42
- Maintenance: "#002f5d",
43
- };
44
-
45
- const VM_POWER_CATEGORIES = ["Powered off", "Powered on", "Suspended"] as const;
46
-
47
- type VmPowerCategory = (typeof VM_POWER_CATEGORIES)[number];
48
-
49
- const VM_POWER_KEY_ALIASES: Record<string, VmPowerCategory> = {
50
- poweredoff: "Powered off",
51
- powered_off: "Powered off",
52
- poweredon: "Powered on",
53
- powered_on: "Powered on",
54
- suspended: "Suspended",
55
- };
56
-
57
- export const VM_POWER_COLORS: Record<string, string> = {
58
- "Powered off": "#0066cc",
59
- "Powered on": "#dca614",
60
- Suspended: "#5e40be",
61
- };
62
-
63
- const OTHER_COLOR = "#6a6e73";
64
-
65
- const normalizeKey = (key: string): string =>
66
- key
67
- .trim()
68
- .toLowerCase()
69
- .replace(/[\s-]+/g, "");
70
-
71
- const formatUnknownLabel = (key: string): string => {
72
- const spaced = key
73
- .replace(/[_-]+/g, " ")
74
- .replace(/([a-z])([A-Z])/g, "$1 $2")
75
- .trim();
76
- if (!spaced) {
77
- return "Unknown";
78
- }
79
- return spaced.charAt(0).toUpperCase() + spaced.slice(1);
80
- };
81
-
82
- const toSlice = (
83
- name: string,
84
- count: number,
85
- unit: string,
86
- ): MigrationDonutChartDatum => ({
87
- name,
88
- count,
89
- legendCategory: name,
90
- countDisplay: `${count} ${count === 1 ? unit.replace(/s$/, "") : unit}`,
91
- });
92
-
93
- const sumCounts = (counts: Record<string, number>): number =>
94
- Object.values(counts).reduce((total, count) => total + (count || 0), 0);
95
-
96
- export const buildHostPowerStateChart = (
97
- hostPowerStates?: Record<string, number>,
98
- ): PowerStateChartModel => {
99
- const counts: Record<string, number> = Object.fromEntries(
100
- HOST_POWER_CATEGORIES.map((category) => [category, 0]),
101
- );
102
-
103
- for (const [key, count] of Object.entries(hostPowerStates ?? {})) {
104
- const mapped = HOST_POWER_KEY_ALIASES[normalizeKey(key)];
105
- const label = mapped ?? formatUnknownLabel(key);
106
- counts[label] = (counts[label] ?? 0) + (count || 0);
107
- }
108
-
109
- const orderedLabels = [
110
- ...HOST_POWER_CATEGORIES,
111
- ...Object.keys(counts).filter(
112
- (label) => !HOST_POWER_CATEGORIES.includes(label as HostPowerCategory),
113
- ),
114
- ];
115
-
116
- const slices = orderedLabels.map((label) =>
117
- toSlice(label, counts[label] ?? 0, "hosts"),
118
- );
119
-
120
- const legend: Record<string, string> = {};
121
- for (const label of orderedLabels) {
122
- legend[label] = HOST_POWER_COLORS[label] ?? OTHER_COLOR;
123
- }
124
-
125
- return {
126
- slices,
127
- legend,
128
- total: sumCounts(counts),
129
- };
130
- };
131
-
132
- export const buildVmPowerStateChart = (
133
- powerStates?: Record<string, number>,
134
- ): PowerStateChartModel => {
135
- const counts: Record<string, number> = {
136
- "Powered off": 0,
137
- "Powered on": 0,
138
- };
139
-
140
- for (const [key, count] of Object.entries(powerStates ?? {})) {
141
- const mapped = VM_POWER_KEY_ALIASES[normalizeKey(key)];
142
- const label = mapped ?? formatUnknownLabel(key);
143
- counts[label] = (counts[label] ?? 0) + (count || 0);
144
- }
145
-
146
- const orderedLabels = [
147
- ...VM_POWER_CATEGORIES.filter(
148
- (category) => category !== "Suspended" || (counts[category] ?? 0) > 0,
149
- ),
150
- ...Object.keys(counts).filter(
151
- (label) => !VM_POWER_CATEGORIES.includes(label as VmPowerCategory),
152
- ),
153
- ];
154
-
155
- const slices = orderedLabels.map((label) =>
156
- toSlice(label, counts[label] ?? 0, "VMs"),
157
- );
158
-
159
- const legend: Record<string, string> = {};
160
- for (const label of orderedLabels) {
161
- legend[label] = VM_POWER_COLORS[label] ?? OTHER_COLOR;
162
- }
163
-
164
- return {
165
- slices,
166
- legend,
167
- total: sumCounts(counts),
168
- };
169
- };