@openshift-migration-advisor/shared-components 0.0.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.
- package/LICENSE +13 -0
- package/README.md +76 -0
- package/dist/charts/MigrationDonutChart.d.ts +53 -0
- package/dist/charts/MigrationDonutChart.d.ts.map +1 -0
- package/dist/charts/MigrationDonutChart.js +186 -0
- package/dist/charts/index.d.ts +2 -0
- package/dist/charts/index.d.ts.map +1 -0
- package/dist/charts/index.js +1 -0
- package/dist/forms/CheckboxFormGroup.d.ts +5 -0
- package/dist/forms/CheckboxFormGroup.d.ts.map +1 -0
- package/dist/forms/CheckboxFormGroup.js +14 -0
- package/dist/forms/FormFieldHelperText.d.ts +7 -0
- package/dist/forms/FormFieldHelperText.d.ts.map +1 -0
- package/dist/forms/FormFieldHelperText.js +8 -0
- package/dist/forms/RadioButtonFormGroup.d.ts +12 -0
- package/dist/forms/RadioButtonFormGroup.d.ts.map +1 -0
- package/dist/forms/RadioButtonFormGroup.js +12 -0
- package/dist/forms/SelectFormGroup.d.ts +8 -0
- package/dist/forms/SelectFormGroup.d.ts.map +1 -0
- package/dist/forms/SelectFormGroup.js +12 -0
- package/dist/forms/TextAreaFormGroup.d.ts +3 -0
- package/dist/forms/TextAreaFormGroup.d.ts.map +1 -0
- package/dist/forms/TextAreaFormGroup.js +12 -0
- package/dist/forms/TextInputFormGroup.d.ts +11 -0
- package/dist/forms/TextInputFormGroup.d.ts.map +1 -0
- package/dist/forms/TextInputFormGroup.js +16 -0
- package/dist/forms/index.d.ts +8 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/index.js +6 -0
- package/dist/forms/types.d.ts +11 -0
- package/dist/forms/types.d.ts.map +1 -0
- package/dist/forms/types.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/report/CardEmptyState.d.ts +8 -0
- package/dist/report/CardEmptyState.d.ts.map +1 -0
- package/dist/report/CardEmptyState.js +13 -0
- package/dist/report/DashboardEmptyStateBase.d.ts +8 -0
- package/dist/report/DashboardEmptyStateBase.d.ts.map +1 -0
- package/dist/report/DashboardEmptyStateBase.js +5 -0
- package/dist/report/EmptySearchResults.d.ts +7 -0
- package/dist/report/EmptySearchResults.d.ts.map +1 -0
- package/dist/report/EmptySearchResults.js +4 -0
- package/dist/report/OSDistribution.d.ts +14 -0
- package/dist/report/OSDistribution.d.ts.map +1 -0
- package/dist/report/OSDistribution.js +37 -0
- package/dist/report/OsSupportTiersHelpPopover.d.ts +3 -0
- package/dist/report/OsSupportTiersHelpPopover.d.ts.map +1 -0
- package/dist/report/OsSupportTiersHelpPopover.js +37 -0
- package/dist/report/OsUpgradeNotice.d.ts +3 -0
- package/dist/report/OsUpgradeNotice.d.ts.map +1 -0
- package/dist/report/OsUpgradeNotice.js +9 -0
- package/dist/report/OsUpgradeRecommendationPopover.d.ts +13 -0
- package/dist/report/OsUpgradeRecommendationPopover.d.ts.map +1 -0
- package/dist/report/OsUpgradeRecommendationPopover.js +24 -0
- package/dist/report/PopoverIcon.d.ts +11 -0
- package/dist/report/PopoverIcon.d.ts.map +1 -0
- package/dist/report/PopoverIcon.js +8 -0
- package/dist/report/SupportTierBadge.d.ts +9 -0
- package/dist/report/SupportTierBadge.d.ts.map +1 -0
- package/dist/report/SupportTierBadge.js +23 -0
- package/dist/report/constants.d.ts +11 -0
- package/dist/report/constants.d.ts.map +1 -0
- package/dist/report/constants.js +12 -0
- package/dist/report/dashboardStyles.d.ts +20 -0
- package/dist/report/dashboardStyles.d.ts.map +1 -0
- package/dist/report/dashboardStyles.js +99 -0
- package/dist/report/index.d.ts +15 -0
- package/dist/report/index.d.ts.map +1 -0
- package/dist/report/index.js +13 -0
- package/dist/report/osSupportTier.d.ts +42 -0
- package/dist/report/osSupportTier.d.ts.map +1 -0
- package/dist/report/osSupportTier.js +106 -0
- package/dist/report/useOsBarChartViewModel.d.ts +26 -0
- package/dist/report/useOsBarChartViewModel.d.ts.map +1 -0
- package/dist/report/useOsBarChartViewModel.js +59 -0
- package/package.json +63 -0
- package/src/charts/MigrationDonutChart.tsx +398 -0
- package/src/charts/index.ts +5 -0
- package/src/forms/CheckboxFormGroup.tsx +53 -0
- package/src/forms/FormFieldHelperText.tsx +32 -0
- package/src/forms/RadioButtonFormGroup.tsx +62 -0
- package/src/forms/SelectFormGroup.tsx +57 -0
- package/src/forms/TextAreaFormGroup.tsx +43 -0
- package/src/forms/TextInputFormGroup.tsx +63 -0
- package/src/forms/index.ts +7 -0
- package/src/forms/types.ts +11 -0
- package/src/index.ts +3 -0
- package/src/report/CardEmptyState.tsx +30 -0
- package/src/report/DashboardEmptyStateBase.tsx +30 -0
- package/src/report/EmptySearchResults.tsx +14 -0
- package/src/report/OSDistribution.tsx +206 -0
- package/src/report/OsSupportTiersHelpPopover.tsx +87 -0
- package/src/report/OsUpgradeNotice.tsx +29 -0
- package/src/report/OsUpgradeRecommendationPopover.tsx +78 -0
- package/src/report/PopoverIcon.tsx +46 -0
- package/src/report/SupportTierBadge.tsx +55 -0
- package/src/report/__tests__/OSDistribution.test.tsx +236 -0
- package/src/report/__tests__/osSupportTier.test.ts +101 -0
- package/src/report/constants.ts +14 -0
- package/src/report/dashboardStyles.ts +116 -0
- package/src/report/index.ts +54 -0
- package/src/report/osSupportTier.ts +161 -0
- package/src/report/useOsBarChartViewModel.ts +115 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { LabelProps } from "@patternfly/react-core";
|
|
2
|
+
import { t_color_blue_20 } from "@patternfly/react-tokens/dist/esm/t_color_blue_20";
|
|
3
|
+
import { t_color_blue_60 } from "@patternfly/react-tokens/dist/esm/t_color_blue_60";
|
|
4
|
+
import { t_color_green_20 } from "@patternfly/react-tokens/dist/esm/t_color_green_20";
|
|
5
|
+
import { t_color_green_60 } from "@patternfly/react-tokens/dist/esm/t_color_green_60";
|
|
6
|
+
import { t_color_orange_20 } from "@patternfly/react-tokens/dist/esm/t_color_orange_20";
|
|
7
|
+
import { t_color_orange_60 } from "@patternfly/react-tokens/dist/esm/t_color_orange_60";
|
|
8
|
+
import { t_color_yellow_20 } from "@patternfly/react-tokens/dist/esm/t_color_yellow_20";
|
|
9
|
+
import { t_color_yellow_60 } from "@patternfly/react-tokens/dist/esm/t_color_yellow_60";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Guest OS support tiers (matches agent-sdk / planner-sdk `OsInfoSupportTierEnum` values).
|
|
13
|
+
* Defined locally so this package stays SDK-agnostic.
|
|
14
|
+
*/
|
|
15
|
+
export const SupportTier = {
|
|
16
|
+
Certified: "certified",
|
|
17
|
+
VendorSupported: "vendor_supported",
|
|
18
|
+
CommunitySupported: "community_supported",
|
|
19
|
+
SpecialHandling: "special_handling",
|
|
20
|
+
} as const;
|
|
21
|
+
|
|
22
|
+
export type SupportTier = (typeof SupportTier)[keyof typeof SupportTier];
|
|
23
|
+
|
|
24
|
+
export const SUPPORT_TIER_LEARN_MORE_URL =
|
|
25
|
+
"https://access.redhat.com/articles/4234591";
|
|
26
|
+
|
|
27
|
+
export interface OSDistributionEntry {
|
|
28
|
+
count: number;
|
|
29
|
+
supported: boolean;
|
|
30
|
+
supportTier?: SupportTier;
|
|
31
|
+
upgradeRecommendation: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const SUPPORT_TIER_SORT_ORDER: Record<SupportTier, number> = {
|
|
35
|
+
[SupportTier.Certified]: 1,
|
|
36
|
+
[SupportTier.VendorSupported]: 2,
|
|
37
|
+
[SupportTier.CommunitySupported]: 3,
|
|
38
|
+
[SupportTier.SpecialHandling]: 4,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const SUPPORT_TIER_LABELS: Record<SupportTier, string> = {
|
|
42
|
+
[SupportTier.Certified]: "Certified",
|
|
43
|
+
[SupportTier.VendorSupported]: "Commercial Vendor Supported",
|
|
44
|
+
[SupportTier.CommunitySupported]: "Community supported",
|
|
45
|
+
[SupportTier.SpecialHandling]: "Special handling",
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Official tier definitions from Red Hat KCS 4234591. */
|
|
49
|
+
export const SUPPORT_TIER_DEFINITIONS: Record<SupportTier, string> = {
|
|
50
|
+
[SupportTier.Certified]:
|
|
51
|
+
"Red Hat has tested, certified and will support this combination of hypervisor and guest operating system. Customers with valid subscriptions may contact Red Hat for support. Red Hat will work with the vendor if the guest operating system issue is related to a hypervisor issue.",
|
|
52
|
+
[SupportTier.VendorSupported]:
|
|
53
|
+
"Red Hat will provide hypervisor support for this combination of certified hypervisor and commercial vendor supported guest operating system. Contact Red Hat for hypervisor support and your vendor for guest operating system support.",
|
|
54
|
+
[SupportTier.CommunitySupported]:
|
|
55
|
+
"Red Hat will provide hypervisor support for this combination of hypervisor and guest operating system. Contact Red Hat for hypervisor support and use available community channels for guest operating system support.",
|
|
56
|
+
[SupportTier.SpecialHandling]:
|
|
57
|
+
'Red Hat will provide hypervisor support for this combination ("Known to work" in the certified guest OS article), or the guest OS is not listed and support follows Red Hat\'s third-party software support policy. Review vendor and end-of-life policies before migrating.',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const ORDERED_SUPPORT_TIERS: SupportTier[] = [
|
|
61
|
+
SupportTier.Certified,
|
|
62
|
+
SupportTier.VendorSupported,
|
|
63
|
+
SupportTier.CommunitySupported,
|
|
64
|
+
SupportTier.SpecialHandling,
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
export const SUPPORT_TIER_BADGE_COLORS: Record<
|
|
68
|
+
SupportTier,
|
|
69
|
+
NonNullable<LabelProps["color"]>
|
|
70
|
+
> = {
|
|
71
|
+
[SupportTier.Certified]: "blue",
|
|
72
|
+
[SupportTier.VendorSupported]: "green",
|
|
73
|
+
[SupportTier.CommunitySupported]: "orange",
|
|
74
|
+
[SupportTier.SpecialHandling]: "yellow",
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export interface SupportTierBadgeStyle {
|
|
78
|
+
backgroundColor: string;
|
|
79
|
+
color: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Explicit colors for html2canvas PDF export (CSS variables are not captured reliably). */
|
|
83
|
+
export const SUPPORT_TIER_BADGE_INLINE_STYLES: Record<
|
|
84
|
+
SupportTier,
|
|
85
|
+
SupportTierBadgeStyle
|
|
86
|
+
> = {
|
|
87
|
+
[SupportTier.Certified]: {
|
|
88
|
+
backgroundColor: t_color_blue_20.value,
|
|
89
|
+
color: t_color_blue_60.value,
|
|
90
|
+
},
|
|
91
|
+
[SupportTier.VendorSupported]: {
|
|
92
|
+
backgroundColor: t_color_green_20.value,
|
|
93
|
+
color: t_color_green_60.value,
|
|
94
|
+
},
|
|
95
|
+
[SupportTier.CommunitySupported]: {
|
|
96
|
+
backgroundColor: t_color_orange_20.value,
|
|
97
|
+
color: t_color_orange_60.value,
|
|
98
|
+
},
|
|
99
|
+
[SupportTier.SpecialHandling]: {
|
|
100
|
+
backgroundColor: t_color_yellow_20.value,
|
|
101
|
+
color: t_color_yellow_60.value,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Resolves the effective support tier for an OS entry.
|
|
107
|
+
* Falls back to the legacy `supported` boolean when the API omits `supportTier`.
|
|
108
|
+
*/
|
|
109
|
+
export function resolveSupportTier(
|
|
110
|
+
supportTier: SupportTier | undefined,
|
|
111
|
+
supported: boolean,
|
|
112
|
+
): SupportTier {
|
|
113
|
+
if (supportTier) {
|
|
114
|
+
return supportTier;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return supported ? SupportTier.Certified : SupportTier.SpecialHandling;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function hasOsUpgradeNotice(
|
|
121
|
+
osData: Record<string, OSDistributionEntry>,
|
|
122
|
+
): boolean {
|
|
123
|
+
return Object.entries(osData).some(([osName, entry]) => {
|
|
124
|
+
if (!osName.trim()) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (entry.upgradeRecommendation.trim() !== "") {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
resolveSupportTier(entry.supportTier, entry.supported) !==
|
|
134
|
+
SupportTier.Certified
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function getSupportTierSortOrder(tier: SupportTier): number {
|
|
140
|
+
return SUPPORT_TIER_SORT_ORDER[tier];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function getSupportTierLegendLabel(tier: SupportTier): string {
|
|
144
|
+
return SUPPORT_TIER_LABELS[tier];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function getSupportTierDefinition(tier: SupportTier): string {
|
|
148
|
+
return SUPPORT_TIER_DEFINITIONS[tier];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function getSupportTierBadgeColor(
|
|
152
|
+
tier: SupportTier,
|
|
153
|
+
): NonNullable<LabelProps["color"]> {
|
|
154
|
+
return SUPPORT_TIER_BADGE_COLORS[tier];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function getSupportTierBadgeInlineStyle(
|
|
158
|
+
tier: SupportTier,
|
|
159
|
+
): SupportTierBadgeStyle {
|
|
160
|
+
return SUPPORT_TIER_BADGE_INLINE_STYLES[tier];
|
|
161
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { MouseEvent as ReactMouseEvent } from "react";
|
|
2
|
+
import { useMemo, useState } from "react";
|
|
3
|
+
import {
|
|
4
|
+
getSupportTierLegendLabel,
|
|
5
|
+
getSupportTierSortOrder,
|
|
6
|
+
hasOsUpgradeNotice,
|
|
7
|
+
type OSDistributionEntry,
|
|
8
|
+
resolveSupportTier,
|
|
9
|
+
type SupportTier,
|
|
10
|
+
} from "./osSupportTier.js";
|
|
11
|
+
|
|
12
|
+
export const ALL_TIERS_FILTER = "all";
|
|
13
|
+
|
|
14
|
+
export interface OsTableRow {
|
|
15
|
+
osName: string;
|
|
16
|
+
tier: SupportTier;
|
|
17
|
+
count: number;
|
|
18
|
+
upgradeRecommendation?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface OsBarChartViewModel {
|
|
22
|
+
osFilter: string;
|
|
23
|
+
tierFilter: string;
|
|
24
|
+
isTierSelectOpen: boolean;
|
|
25
|
+
tableRows: OsTableRow[];
|
|
26
|
+
filteredRows: OsTableRow[];
|
|
27
|
+
tierFilterLabel: string;
|
|
28
|
+
showNoResults: boolean;
|
|
29
|
+
showUpgradeNotice: boolean;
|
|
30
|
+
setOsFilter: (value: string) => void;
|
|
31
|
+
clearOsFilter: () => void;
|
|
32
|
+
setIsTierSelectOpen: (open: boolean) => void;
|
|
33
|
+
toggleTierSelectOpen: () => void;
|
|
34
|
+
handleTierSelect: (
|
|
35
|
+
_event?: ReactMouseEvent<Element>,
|
|
36
|
+
value?: string | number,
|
|
37
|
+
) => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function buildOsTableRows(
|
|
41
|
+
osData: Record<string, OSDistributionEntry>,
|
|
42
|
+
): OsTableRow[] {
|
|
43
|
+
return Object.entries(osData)
|
|
44
|
+
.filter(([osName]) => osName.trim() !== "")
|
|
45
|
+
.map(([osName, entry]) => ({
|
|
46
|
+
osName,
|
|
47
|
+
tier: resolveSupportTier(entry.supportTier, entry.supported),
|
|
48
|
+
count: entry.count,
|
|
49
|
+
upgradeRecommendation: entry.upgradeRecommendation || undefined,
|
|
50
|
+
}))
|
|
51
|
+
.sort((a, b) => {
|
|
52
|
+
const tierOrder =
|
|
53
|
+
getSupportTierSortOrder(a.tier) - getSupportTierSortOrder(b.tier);
|
|
54
|
+
if (tierOrder !== 0) {
|
|
55
|
+
return tierOrder;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return b.count - a.count;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function useOsBarChartViewModel(
|
|
63
|
+
osData: Record<string, OSDistributionEntry>,
|
|
64
|
+
): OsBarChartViewModel {
|
|
65
|
+
const [osFilter, setOsFilter] = useState("");
|
|
66
|
+
const [tierFilter, setTierFilter] = useState<string>(ALL_TIERS_FILTER);
|
|
67
|
+
const [isTierSelectOpen, setIsTierSelectOpen] = useState(false);
|
|
68
|
+
|
|
69
|
+
const tableRows = useMemo(() => buildOsTableRows(osData), [osData]);
|
|
70
|
+
|
|
71
|
+
const filteredRows = useMemo(() => {
|
|
72
|
+
const normalizedFilter = osFilter.trim().toLowerCase();
|
|
73
|
+
|
|
74
|
+
return tableRows.filter((row) => {
|
|
75
|
+
const matchesOs =
|
|
76
|
+
normalizedFilter === "" ||
|
|
77
|
+
row.osName.toLowerCase().includes(normalizedFilter);
|
|
78
|
+
const matchesTier =
|
|
79
|
+
tierFilter === ALL_TIERS_FILTER || row.tier === tierFilter;
|
|
80
|
+
|
|
81
|
+
return matchesOs && matchesTier;
|
|
82
|
+
});
|
|
83
|
+
}, [osFilter, tableRows, tierFilter]);
|
|
84
|
+
|
|
85
|
+
const tierFilterLabel =
|
|
86
|
+
tierFilter === ALL_TIERS_FILTER
|
|
87
|
+
? "Filter by tier"
|
|
88
|
+
: getSupportTierLegendLabel(tierFilter as SupportTier);
|
|
89
|
+
|
|
90
|
+
const handleTierSelect = (
|
|
91
|
+
_event?: ReactMouseEvent<Element>,
|
|
92
|
+
value?: string | number,
|
|
93
|
+
): void => {
|
|
94
|
+
if (typeof value === "string") {
|
|
95
|
+
setTierFilter(value);
|
|
96
|
+
}
|
|
97
|
+
setIsTierSelectOpen(false);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
osFilter,
|
|
102
|
+
tierFilter,
|
|
103
|
+
isTierSelectOpen,
|
|
104
|
+
tableRows,
|
|
105
|
+
filteredRows,
|
|
106
|
+
tierFilterLabel,
|
|
107
|
+
showNoResults: filteredRows.length === 0,
|
|
108
|
+
showUpgradeNotice: hasOsUpgradeNotice(osData),
|
|
109
|
+
setOsFilter,
|
|
110
|
+
clearOsFilter: () => setOsFilter(""),
|
|
111
|
+
setIsTierSelectOpen,
|
|
112
|
+
toggleTierSelectOpen: () => setIsTierSelectOpen((open) => !open),
|
|
113
|
+
handleTierSelect,
|
|
114
|
+
};
|
|
115
|
+
}
|