@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
@@ -9,15 +9,13 @@ import {
9
9
  type SupportTier,
10
10
  } from "./osSupportTier.js";
11
11
 
12
- const exportBadgeStyle = (backgroundColor: string, color: string) => css`
12
+ const exportBadgeStyle = css`
13
13
  display: inline-block;
14
14
  padding: var(--pf-t--global--spacer--xs) var(--pf-t--global--spacer--sm);
15
15
  border-radius: var(--pf-t--global--border--radius--pill);
16
16
  font-size: var(--pf-t--global--font--size--body--sm);
17
17
  line-height: var(--pf-t--global--font--line-height--body);
18
18
  white-space: nowrap;
19
- background-color: ${backgroundColor};
20
- color: ${color};
21
19
  `;
22
20
 
23
21
  interface SupportTierBadgeProps {
@@ -29,7 +27,7 @@ const ExportSupportTierBadge: FC<{ tier: SupportTier }> = ({ tier }) => {
29
27
  const { backgroundColor, color } = getSupportTierBadgeInlineStyle(tier);
30
28
 
31
29
  return (
32
- <span className={exportBadgeStyle(backgroundColor, color)}>
30
+ <span className={exportBadgeStyle} style={{ backgroundColor, color }}>
33
31
  {getSupportTierLegendLabel(tier)}
34
32
  </span>
35
33
  );
@@ -25,6 +25,4 @@ 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
- hostPowerStates: "Host power state data not collected",
29
- vmPowerStates: "VM power state data not collected",
30
28
  } as const;
@@ -17,43 +17,6 @@ export {
17
17
  EmptySearchResults,
18
18
  type EmptySearchResultsProps,
19
19
  } from "./EmptySearchResults.js";
20
- export {
21
- FeatureStatusBadge,
22
- type FeatureStatusBadgeProps,
23
- } from "./FeatureStatusBadge.js";
24
- export {
25
- HostPowerStates,
26
- type HostPowerStatesProps,
27
- } from "./HostPowerStates.js";
28
- export {
29
- InfrastructureSummary,
30
- type InfrastructureSummaryProps,
31
- } from "./InfrastructureSummary.js";
32
- export type {
33
- ClusterDetailRow,
34
- ClusterDetailsModel,
35
- FeatureStatus,
36
- HostCapability,
37
- InfrastructureSummaryModel,
38
- InventoryCluster,
39
- InventoryDatastore,
40
- InventoryHost,
41
- InventoryInfra,
42
- InventoryNetwork,
43
- InventoryVms,
44
- NetworkLabel,
45
- } from "./infrastructureSummaryModel.js";
46
- export {
47
- booleanToFeatureStatus,
48
- buildClusterDetailRows,
49
- buildClusterDetails,
50
- buildInfrastructureSummary,
51
- countVCenters,
52
- formatVSphereVersion,
53
- hostCapabilityStatus,
54
- visibleNetworks,
55
- vsanStatus,
56
- } from "./infrastructureSummaryModel.js";
57
20
  export { OSBarChart, OSDistribution } from "./OSDistribution.js";
58
21
  export { OsSupportTiersHelpPopover } from "./OsSupportTiersHelpPopover.js";
59
22
  export { OsUpgradeNotice } from "./OsUpgradeNotice.js";
@@ -82,17 +45,6 @@ export {
82
45
  SupportTier,
83
46
  } from "./osSupportTier.js";
84
47
  export { default as PopoverIcon } from "./PopoverIcon.js";
85
- export {
86
- PowerStateCard,
87
- type PowerStateCardProps,
88
- } from "./PowerStateCard.js";
89
- export type { PowerStateChartModel } from "./powerStates.js";
90
- export {
91
- buildHostPowerStateChart,
92
- buildVmPowerStateChart,
93
- HOST_POWER_COLORS,
94
- VM_POWER_COLORS,
95
- } from "./powerStates.js";
96
48
  export { SupportTierBadge } from "./SupportTierBadge.js";
97
49
  export {
98
50
  ALL_TIERS_FILTER,
@@ -100,11 +52,3 @@ export {
100
52
  type OsTableRow,
101
53
  useOsBarChartViewModel,
102
54
  } from "./useOsBarChartViewModel.js";
103
- export {
104
- VCenterClusterDetails,
105
- type VCenterClusterDetailsProps,
106
- } from "./VCenterClusterDetails.js";
107
- export {
108
- VmPowerStates,
109
- type VmPowerStatesProps,
110
- } from "./VmPowerStates.js";
@@ -1,7 +0,0 @@
1
- import type { FC } from "react";
2
- import type { FeatureStatus } from "./infrastructureSummaryModel.js";
3
- export interface FeatureStatusBadgeProps {
4
- status: FeatureStatus;
5
- }
6
- export declare const FeatureStatusBadge: FC<FeatureStatusBadgeProps>;
7
- //# sourceMappingURL=FeatureStatusBadge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FeatureStatusBadge.d.ts","sourceRoot":"","sources":["../../src/report/FeatureStatusBadge.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAkB1D,CAAC"}
@@ -1,13 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Label } from "@patternfly/react-core";
3
- import { CheckCircleIcon, TimesCircleIcon } from "@patternfly/react-icons";
4
- export const FeatureStatusBadge = ({ status }) => {
5
- if (status === "unknown") {
6
- return _jsx("span", { children: "\u2014" });
7
- }
8
- if (status === "enabled") {
9
- return (_jsx(Label, { color: "green", isCompact: true, icon: _jsx(CheckCircleIcon, {}), children: "Enabled" }));
10
- }
11
- return (_jsx(Label, { color: "grey", isCompact: true, icon: _jsx(TimesCircleIcon, {}), children: "Disabled" }));
12
- };
13
- FeatureStatusBadge.displayName = "FeatureStatusBadge";
@@ -1,9 +0,0 @@
1
- import type { FC } from "react";
2
- import type { MigrationDonutChartLegendVariant } from "../charts/MigrationDonutChart.js";
3
- export interface HostPowerStatesProps {
4
- hostPowerStates?: Record<string, number>;
5
- isExportMode?: boolean;
6
- legendVariant?: MigrationDonutChartLegendVariant;
7
- }
8
- export declare const HostPowerStates: FC<HostPowerStatesProps>;
9
- //# sourceMappingURL=HostPowerStates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HostPowerStates.d.ts","sourceRoot":"","sources":["../../src/report/HostPowerStates.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAKzF,MAAM,WAAW,oBAAoB;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,gCAAgC,CAAC;CAClD;AAED,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAwBpD,CAAC"}
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ServerIcon } from "@patternfly/react-icons";
3
- import { useMemo } from "react";
4
- import { REPORT_CARD_EMPTY_STATE_TITLES } from "./constants.js";
5
- import { PowerStateCard } from "./PowerStateCard.js";
6
- import { buildHostPowerStateChart } from "./powerStates.js";
7
- export const HostPowerStates = ({ hostPowerStates, isExportMode = false, legendVariant, }) => {
8
- const chart = useMemo(() => buildHostPowerStateChart(hostPowerStates), [hostPowerStates]);
9
- return (_jsx(PowerStateCard, { id: "esxi-host-power-states", title: "ESXi host power states", icon: _jsx(ServerIcon, {}), emptyTitle: REPORT_CARD_EMPTY_STATE_TITLES.hostPowerStates, slices: chart.slices, legend: chart.legend, total: chart.total, subTitle: "Hosts", isExportMode: isExportMode, legendVariant: legendVariant }));
10
- };
11
- HostPowerStates.displayName = "HostPowerStates";
@@ -1,7 +0,0 @@
1
- import type { FC } from "react";
2
- import type { InfrastructureSummaryModel } from "./infrastructureSummaryModel.js";
3
- export interface InfrastructureSummaryProps {
4
- summary: InfrastructureSummaryModel;
5
- }
6
- export declare const InfrastructureSummary: FC<InfrastructureSummaryProps>;
7
- //# sourceMappingURL=InfrastructureSummary.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InfrastructureSummary.d.ts","sourceRoot":"","sources":["../../src/report/InfrastructureSummary.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAElF,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,0BAA0B,CAAC;CACrC;AAKD,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CAkChE,CAAC"}
@@ -1,5 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Card, CardBody, CardTitle, DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm, } from "@patternfly/react-core";
3
- const formatCount = (value) => typeof value === "number" ? String(value) : "—";
4
- export const InfrastructureSummary = ({ summary, }) => (_jsxs(Card, { isFullHeight: true, id: "infrastructure-summary", children: [_jsx(CardTitle, { children: "Infrastructure summary" }), _jsx(CardBody, { children: _jsxs(DescriptionList, { isAutoFit: true, displaySize: "lg", children: [_jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: "VMware version" }), _jsx(DescriptionListDescription, { children: summary.vmwareVersion })] }), _jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: "Datacenters" }), _jsx(DescriptionListDescription, { children: formatCount(summary.datacenters) })] }), _jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: "vCenters" }), _jsx(DescriptionListDescription, { children: formatCount(summary.vCenters) })] }), _jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: "ESXi hosts" }), _jsx(DescriptionListDescription, { children: formatCount(summary.esxiHosts) })] })] }) })] }));
5
- InfrastructureSummary.displayName = "InfrastructureSummary";
@@ -1,17 +0,0 @@
1
- import type { FC, ReactNode } from "react";
2
- import { type MigrationDonutChartDatum, type MigrationDonutChartLegendVariant } from "../charts/MigrationDonutChart.js";
3
- export interface PowerStateCardProps {
4
- id: string;
5
- title: string;
6
- icon: ReactNode;
7
- emptyTitle: string;
8
- slices: MigrationDonutChartDatum[];
9
- legend: Record<string, string>;
10
- total: number;
11
- subTitle: string;
12
- isExportMode?: boolean;
13
- itemsPerRow?: number;
14
- legendVariant?: MigrationDonutChartLegendVariant;
15
- }
16
- export declare const PowerStateCard: FC<PowerStateCardProps>;
17
- //# sourceMappingURL=PowerStateCard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PowerStateCard.d.ts","sourceRoot":"","sources":["../../src/report/PowerStateCard.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,gCAAgC,EACtC,MAAM,kCAAkC,CAAC;AAI1C,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,wBAAwB,EAAE,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,gCAAgC,CAAC;CAClD;AAED,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CA8ClD,CAAC"}
@@ -1,7 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { Card, CardBody, CardTitle } from "@patternfly/react-core";
3
- import { MigrationDonutChart, } from "../charts/MigrationDonutChart.js";
4
- import { CardEmptyState } from "./CardEmptyState.js";
5
- import { dashboardStyles } from "./dashboardStyles.js";
6
- export const PowerStateCard = ({ id, title, icon, emptyTitle, slices, legend, total, subTitle, isExportMode = false, itemsPerRow = 2, legendVariant = "html", }) => (_jsxs(Card, { className: isExportMode ? dashboardStyles.cardPrint : dashboardStyles.card, id: id, children: [_jsxs(CardTitle, { children: [icon, " ", title] }), _jsx(CardBody, { children: total === 0 ? (_jsx(CardEmptyState, { title: emptyTitle })) : (_jsx(MigrationDonutChart, { legendVariant: legendVariant, data: slices, legend: legend, height: 300, width: 420, donutThickness: 18, padAngle: 1, title: `${total}`, subTitle: subTitle, subTitleColor: "var(--pf-t--global--text--color--subtle)", titleFontSize: 34, labelFontSize: 16, itemsPerRow: itemsPerRow, marginLeft: "0%", tooltipLabelFormatter: ({ datum, percent }) => `${datum.countDisplay}\n${percent.toFixed(1)}%` })) })] }));
7
- PowerStateCard.displayName = "PowerStateCard";
@@ -1,10 +0,0 @@
1
- import type { FC } from "react";
2
- import type { ClusterDetailRow, ClusterDetailsModel } from "./infrastructureSummaryModel.js";
3
- export interface VCenterClusterDetailsProps {
4
- isAggregateView: boolean;
5
- rows: ClusterDetailRow[];
6
- details?: ClusterDetailsModel;
7
- isExportMode?: boolean;
8
- }
9
- export declare const VCenterClusterDetails: FC<VCenterClusterDetailsProps>;
10
- //# sourceMappingURL=VCenterClusterDetails.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VCenterClusterDetails.d.ts","sourceRoot":"","sources":["../../src/report/VCenterClusterDetails.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EAEpB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,WAAW,0BAA0B;IACzC,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAmKD,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CAgBhE,CAAC"}
@@ -1,26 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { css } from "@emotion/css";
3
- import { Card, CardBody, CardTitle, Content, DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm, Grid, GridItem, Label, LabelGroup, } from "@patternfly/react-core";
4
- import { Table, Tbody, Td, Th, Thead, Tr } from "@patternfly/react-table";
5
- import { FeatureStatusBadge } from "./FeatureStatusBadge.js";
6
- const clusterDetailsTableScrollStyle = css `
7
- max-height: 320px;
8
- overflow: auto;
9
- `;
10
- const FeatureList = ({ items }) => (_jsx(DescriptionList, { isHorizontal: true, isCompact: true, children: items.map((item) => (_jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: item.label }), _jsx(DescriptionListDescription, { children: _jsx(FeatureStatusBadge, { status: item.status }) })] }, item.label))) }));
11
- const AggregateClusterTable = ({ rows }) => (_jsxs(Table, { variant: "compact", borders: false, isStickyHeader: true, "data-testid": "vcenter-cluster-details-table", children: [_jsx(Thead, { children: _jsxs(Tr, { children: [_jsx(Th, { children: "Cluster name" }), _jsx(Th, { children: "Hosts" }), _jsx(Th, { children: "VMs" }), _jsx(Th, { children: "vMotion" }), _jsx(Th, { children: "DRS" }), _jsx(Th, { children: "vSAN" })] }) }), _jsx(Tbody, { children: rows.map((row) => (_jsxs(Tr, { children: [_jsx(Td, { dataLabel: "Cluster name", children: row.name }), _jsx(Td, { dataLabel: "Hosts", children: row.hosts }), _jsx(Td, { dataLabel: "VMs", children: row.vms }), _jsx(Td, { dataLabel: "vMotion", children: _jsx(FeatureStatusBadge, { status: row.vmotion }) }), _jsx(Td, { dataLabel: "DRS", children: _jsx(FeatureStatusBadge, { status: row.drs }) }), _jsx(Td, { dataLabel: "vSAN", children: _jsx(FeatureStatusBadge, { status: row.vsan }) })] }, row.id))) })] }));
12
- const AggregateCluster = ({ rows, isExportMode }) => {
13
- if (rows.length === 0) {
14
- return _jsx(Content, { component: "p", children: "No vSphere clusters detected" });
15
- }
16
- return (_jsx("div", { className: isExportMode ? undefined : clusterDetailsTableScrollStyle, "data-scroll-constrained": isExportMode ? undefined : "true", children: _jsx(AggregateClusterTable, { rows: rows }) }));
17
- };
18
- const DetailedClusterView = ({ details, }) => (_jsxs(Grid, { hasGutter: true, children: [_jsx(GridItem, { span: 12, children: _jsxs(DescriptionList, { isAutoFit: true, displaySize: "lg", children: [_jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: "Hosts" }), _jsx(DescriptionListDescription, { children: details.hosts })] }), _jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: "VMs" }), _jsx(DescriptionListDescription, { children: details.vms })] }), _jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: "Networks detected" }), _jsx(DescriptionListDescription, { children: details.networksDetected })] })] }) }), _jsx(GridItem, { md: 4, span: 12, children: _jsxs(Card, { isFullHeight: true, children: [_jsx(CardTitle, { children: "Core infrastructure" }), _jsx(CardBody, { children: _jsx(FeatureList, { items: [
19
- { label: "vMotion", status: details.vmotion },
20
- { label: "DRS", status: details.drs },
21
- { label: "HA", status: details.ha },
22
- ] }) })] }) }), _jsx(GridItem, { md: 4, span: 12, children: _jsxs(Card, { isFullHeight: true, children: [_jsx(CardTitle, { children: "vSAN capabilities" }), _jsx(CardBody, { children: _jsx(FeatureList, { items: [{ label: "vSAN", status: details.vsan }] }) })] }) }), _jsx(GridItem, { md: 4, span: 12, children: _jsxs(Card, { isFullHeight: true, children: [_jsx(CardTitle, { children: "Network topology" }), _jsx(CardBody, { children: details.networks.length === 0 ? (_jsx(Content, { component: "p", children: "No networks detected" })) : (_jsxs(_Fragment, { children: [_jsxs(Content, { component: "p", children: [details.networksDetected, " ", details.networksDetected === 1
23
- ? "network detected"
24
- : "networks detected"] }), _jsx(LabelGroup, { isCompact: true, numLabels: details.networks.length, "aria-label": "Detected networks", children: details.networks.map((network, index) => (_jsx(Label, { color: "blue", isCompact: true, children: network.displayName }, `${network.name}-${network.vlanId ?? index}`))) })] })) })] }) })] }));
25
- export const VCenterClusterDetails = ({ isAggregateView, rows, details, isExportMode = false, }) => (_jsxs(Card, { isFullHeight: true, id: "vcenter-cluster-details", children: [_jsx(CardTitle, { children: "vCenter cluster details" }), _jsx(CardBody, { children: isAggregateView || !details ? (_jsx(AggregateCluster, { rows: rows, isExportMode: isExportMode })) : (_jsx(DetailedClusterView, { details: details })) })] }));
26
- VCenterClusterDetails.displayName = "VCenterClusterDetails";
@@ -1,9 +0,0 @@
1
- import type { FC } from "react";
2
- import type { MigrationDonutChartLegendVariant } from "../charts/MigrationDonutChart.js";
3
- export interface VmPowerStatesProps {
4
- powerStates?: Record<string, number>;
5
- isExportMode?: boolean;
6
- legendVariant?: MigrationDonutChartLegendVariant;
7
- }
8
- export declare const VmPowerStates: FC<VmPowerStatesProps>;
9
- //# sourceMappingURL=VmPowerStates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VmPowerStates.d.ts","sourceRoot":"","sources":["../../src/report/VmPowerStates.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAKzF,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,gCAAgC,CAAC;CAClD;AAED,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAwBhD,CAAC"}
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { VirtualMachineIcon } from "@patternfly/react-icons";
3
- import { useMemo } from "react";
4
- import { REPORT_CARD_EMPTY_STATE_TITLES } from "./constants.js";
5
- import { PowerStateCard } from "./PowerStateCard.js";
6
- import { buildVmPowerStateChart } from "./powerStates.js";
7
- export const VmPowerStates = ({ powerStates, isExportMode = false, legendVariant, }) => {
8
- const chart = useMemo(() => buildVmPowerStateChart(powerStates), [powerStates]);
9
- return (_jsx(PowerStateCard, { id: "vm-power-states", title: "VM power states", icon: _jsx(VirtualMachineIcon, {}), emptyTitle: REPORT_CARD_EMPTY_STATE_TITLES.vmPowerStates, slices: chart.slices, legend: chart.legend, total: chart.total, subTitle: "VMs", isExportMode: isExportMode, legendVariant: legendVariant }));
10
- };
11
- VmPowerStates.displayName = "VmPowerStates";
@@ -1,82 +0,0 @@
1
- export type FeatureStatus = "enabled" | "disabled" | "unknown";
2
- export type HostCapability = "vmotionSupported" | "storageVmotionSupported";
3
- export type InventoryHost = {
4
- vmotionSupported?: boolean;
5
- storageVmotionSupported?: boolean;
6
- };
7
- export type InventoryDatastore = {
8
- type?: string;
9
- };
10
- export type InventoryNetwork = {
11
- name: string;
12
- type?: string;
13
- vlanId?: string;
14
- };
15
- export type InventoryInfra = {
16
- totalHosts?: number;
17
- totalDatacenters?: number;
18
- hosts?: InventoryHost[];
19
- clustersPerDatacenter?: number[];
20
- networks?: InventoryNetwork[];
21
- datastores?: InventoryDatastore[];
22
- };
23
- export type InventoryVms = {
24
- total?: number;
25
- diskTypes?: Record<string, unknown>;
26
- };
27
- export type InventoryCluster = {
28
- infra?: InventoryInfra;
29
- vms?: InventoryVms;
30
- vcenter?: {
31
- id?: string;
32
- };
33
- clusterFeatures?: {
34
- drsEnabled?: boolean;
35
- haEnabled?: boolean;
36
- };
37
- };
38
- export type InfrastructureSummaryModel = {
39
- vmwareVersion: string;
40
- datacenters: number | undefined;
41
- vCenters: number | undefined;
42
- esxiHosts: number | undefined;
43
- };
44
- export type NetworkLabel = {
45
- name: string;
46
- vlanId?: string;
47
- displayName: string;
48
- };
49
- export type ClusterDetailRow = {
50
- id: string;
51
- name: string;
52
- hosts: number;
53
- vms: number;
54
- vmotion: FeatureStatus;
55
- drs: FeatureStatus;
56
- vsan: FeatureStatus;
57
- };
58
- export type ClusterDetailsModel = {
59
- hosts: number;
60
- vms: number;
61
- networksDetected: number;
62
- vmotion: FeatureStatus;
63
- drs: FeatureStatus;
64
- ha: FeatureStatus;
65
- vsan: FeatureStatus;
66
- networks: NetworkLabel[];
67
- };
68
- export declare const formatVSphereVersion: (version?: string) => string;
69
- export declare const booleanToFeatureStatus: (value: boolean | undefined) => FeatureStatus;
70
- export declare const hostCapabilityStatus: (hosts: InventoryHost[] | undefined, capability: HostCapability) => FeatureStatus;
71
- export declare const vsanStatus: (infra?: InventoryInfra, vms?: InventoryVms) => FeatureStatus;
72
- export declare const countVCenters: (clusters?: Record<string, InventoryCluster>, vcenterId?: string) => number | undefined;
73
- export declare const visibleNetworks: (infra?: InventoryInfra) => NetworkLabel[];
74
- export declare const buildInfrastructureSummary: ({ infra, vcenterVersion, vcenterId, clusters, }: {
75
- infra?: InventoryInfra;
76
- vcenterVersion?: string;
77
- vcenterId?: string;
78
- clusters?: Record<string, InventoryCluster>;
79
- }) => InfrastructureSummaryModel;
80
- export declare const buildClusterDetailRows: (clusters?: Record<string, InventoryCluster>) => ClusterDetailRow[];
81
- export declare const buildClusterDetails: (cluster?: InventoryCluster) => ClusterDetailsModel | undefined;
82
- //# sourceMappingURL=infrastructureSummaryModel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"infrastructureSummaryModel.d.ts","sourceRoot":"","sources":["../../src/report/infrastructureSummaryModel.ts"],"names":[],"mappings":"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"}
@@ -1,139 +0,0 @@
1
- const VSAN_TYPE_PATTERN = /vsan/i;
2
- export const formatVSphereVersion = (version) => {
3
- if (!version?.trim()) {
4
- return "—";
5
- }
6
- const withoutPrefix = version.trim().replace(/^vSphere\s+/i, "");
7
- const parts = withoutPrefix.split(".");
8
- while (parts.length > 3 && parts[parts.length - 1] === "0") {
9
- parts.pop();
10
- }
11
- return `vSphere ${parts.join(".")}`;
12
- };
13
- export const booleanToFeatureStatus = (value) => {
14
- if (value === true) {
15
- return "enabled";
16
- }
17
- if (value === false) {
18
- return "disabled";
19
- }
20
- return "unknown";
21
- };
22
- export const hostCapabilityStatus = (hosts, capability) => {
23
- if (!hosts || hosts.length === 0) {
24
- return "unknown";
25
- }
26
- const known = hosts
27
- .map((host) => host[capability])
28
- .filter((value) => typeof value === "boolean");
29
- if (known.length === 0) {
30
- return "unknown";
31
- }
32
- return known.some(Boolean) ? "enabled" : "disabled";
33
- };
34
- export const vsanStatus = (infra, vms) => {
35
- const datastoreMatch = infra?.datastores?.some((datastore) => VSAN_TYPE_PATTERN.test(datastore.type ?? ""));
36
- const diskTypeMatch = Object.keys(vms?.diskTypes ?? {}).some((type) => VSAN_TYPE_PATTERN.test(type));
37
- if (datastoreMatch || diskTypeMatch) {
38
- return "enabled";
39
- }
40
- if (infra?.datastores || vms?.diskTypes) {
41
- return "disabled";
42
- }
43
- return "unknown";
44
- };
45
- const hostCount = (infra) => {
46
- if (typeof infra?.totalHosts === "number") {
47
- return infra.totalHosts;
48
- }
49
- if (infra?.hosts) {
50
- return infra.hosts.length;
51
- }
52
- return undefined;
53
- };
54
- const datacenterCount = (infra) => {
55
- if (typeof infra?.totalDatacenters === "number") {
56
- return infra.totalDatacenters;
57
- }
58
- if (infra?.clustersPerDatacenter && infra.clustersPerDatacenter.length > 0) {
59
- return infra.clustersPerDatacenter.length;
60
- }
61
- return undefined;
62
- };
63
- export const countVCenters = (clusters, vcenterId) => {
64
- const ids = new Set();
65
- if (vcenterId) {
66
- ids.add(vcenterId);
67
- }
68
- for (const cluster of Object.values(clusters ?? {})) {
69
- if (cluster.vcenter?.id) {
70
- ids.add(cluster.vcenter.id);
71
- }
72
- }
73
- return ids.size > 0 ? ids.size : undefined;
74
- };
75
- const toNetworkLabel = (network) => {
76
- const vlanId = network.vlanId?.trim();
77
- return {
78
- name: network.name,
79
- vlanId: vlanId || undefined,
80
- displayName: vlanId ? `${network.name} (VLAN ${vlanId})` : network.name,
81
- };
82
- };
83
- export const visibleNetworks = (infra) => (infra?.networks ?? [])
84
- .filter((network) => Boolean(network.name?.trim()) && network.type !== "dvswitch")
85
- .map(toNetworkLabel);
86
- export const buildInfrastructureSummary = ({ infra, vcenterVersion, vcenterId, clusters, }) => ({
87
- vmwareVersion: formatVSphereVersion(vcenterVersion),
88
- datacenters: datacenterCount(infra),
89
- vCenters: countVCenters(clusters, vcenterId),
90
- esxiHosts: hostCount(infra),
91
- });
92
- const clusterFeatureStatus = (cluster) => ({
93
- vmotion: hostCapabilityStatus(cluster.infra?.hosts, "vmotionSupported"),
94
- drs: booleanToFeatureStatus(cluster.clusterFeatures?.drsEnabled),
95
- ha: booleanToFeatureStatus(cluster.clusterFeatures?.haEnabled),
96
- vsan: vsanStatus(cluster.infra, cluster.vms),
97
- });
98
- const compareClustersByVmCount = (a, b, clusters) => {
99
- const vmsA = clusters[a]?.vms?.total ?? 0;
100
- const vmsB = clusters[b]?.vms?.total ?? 0;
101
- return vmsB - vmsA || a.localeCompare(b);
102
- };
103
- export const buildClusterDetailRows = (clusters) => {
104
- if (!clusters) {
105
- return [];
106
- }
107
- return Object.keys(clusters)
108
- .sort((a, b) => compareClustersByVmCount(a, b, clusters))
109
- .map((id) => {
110
- const cluster = clusters[id];
111
- const features = clusterFeatureStatus(cluster);
112
- return {
113
- id,
114
- name: id,
115
- hosts: hostCount(cluster.infra) ?? 0,
116
- vms: cluster.vms?.total ?? 0,
117
- vmotion: features.vmotion,
118
- drs: features.drs,
119
- vsan: features.vsan,
120
- };
121
- });
122
- };
123
- export const buildClusterDetails = (cluster) => {
124
- if (!cluster) {
125
- return undefined;
126
- }
127
- const networks = visibleNetworks(cluster.infra);
128
- const features = clusterFeatureStatus(cluster);
129
- return {
130
- hosts: hostCount(cluster.infra) ?? 0,
131
- vms: cluster.vms?.total ?? 0,
132
- networksDetected: networks.length,
133
- vmotion: features.vmotion,
134
- drs: features.drs,
135
- ha: features.ha,
136
- vsan: features.vsan,
137
- networks,
138
- };
139
- };
@@ -1,11 +0,0 @@
1
- import type { MigrationDonutChartDatum } from "../charts/MigrationDonutChart.js";
2
- export type PowerStateChartModel = {
3
- slices: MigrationDonutChartDatum[];
4
- legend: Record<string, string>;
5
- total: number;
6
- };
7
- export declare const HOST_POWER_COLORS: Record<string, string>;
8
- export declare const VM_POWER_COLORS: Record<string, string>;
9
- export declare const buildHostPowerStateChart: (hostPowerStates?: Record<string, number>) => PowerStateChartModel;
10
- export declare const buildVmPowerStateChart: (powerStates?: Record<string, number>) => PowerStateChartModel;
11
- //# sourceMappingURL=powerStates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"powerStates.d.ts","sourceRoot":"","sources":["../../src/report/powerStates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAEjF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,wBAAwB,EAAE,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA8BF,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMpD,CAAC;AAcF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAIlD,CAAC;AAmCF,eAAO,MAAM,wBAAwB,GACnC,kBAAkB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACvC,oBAgCF,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,cAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACnC,oBAmCF,CAAC"}
@@ -1,113 +0,0 @@
1
- const HOST_POWER_CATEGORIES = [
2
- "Powered on",
3
- "Powered off",
4
- "Standby",
5
- "Not responding",
6
- "Maintenance",
7
- ];
8
- const HOST_POWER_KEY_ALIASES = {
9
- poweredon: "Powered on",
10
- powered_on: "Powered on",
11
- green: "Powered on",
12
- poweredoff: "Powered off",
13
- powered_off: "Powered off",
14
- standby: "Standby",
15
- stand_by: "Standby",
16
- notresponding: "Not responding",
17
- not_responding: "Not responding",
18
- gray: "Not responding",
19
- grey: "Not responding",
20
- red: "Not responding",
21
- maintenance: "Maintenance",
22
- inmaintenance: "Maintenance",
23
- inmaintenancemode: "Maintenance",
24
- };
25
- export const HOST_POWER_COLORS = {
26
- "Powered on": "#0066cc",
27
- "Powered off": "#dca614",
28
- Standby: "#f0ab00",
29
- "Not responding": "#c9190b",
30
- Maintenance: "#002f5d",
31
- };
32
- const VM_POWER_CATEGORIES = ["Powered off", "Powered on", "Suspended"];
33
- const VM_POWER_KEY_ALIASES = {
34
- poweredoff: "Powered off",
35
- powered_off: "Powered off",
36
- poweredon: "Powered on",
37
- powered_on: "Powered on",
38
- suspended: "Suspended",
39
- };
40
- export const VM_POWER_COLORS = {
41
- "Powered off": "#0066cc",
42
- "Powered on": "#dca614",
43
- Suspended: "#5e40be",
44
- };
45
- const OTHER_COLOR = "#6a6e73";
46
- const normalizeKey = (key) => key
47
- .trim()
48
- .toLowerCase()
49
- .replace(/[\s-]+/g, "");
50
- const formatUnknownLabel = (key) => {
51
- const spaced = key
52
- .replace(/[_-]+/g, " ")
53
- .replace(/([a-z])([A-Z])/g, "$1 $2")
54
- .trim();
55
- if (!spaced) {
56
- return "Unknown";
57
- }
58
- return spaced.charAt(0).toUpperCase() + spaced.slice(1);
59
- };
60
- const toSlice = (name, count, unit) => ({
61
- name,
62
- count,
63
- legendCategory: name,
64
- countDisplay: `${count} ${count === 1 ? unit.replace(/s$/, "") : unit}`,
65
- });
66
- const sumCounts = (counts) => Object.values(counts).reduce((total, count) => total + (count || 0), 0);
67
- export const buildHostPowerStateChart = (hostPowerStates) => {
68
- const counts = Object.fromEntries(HOST_POWER_CATEGORIES.map((category) => [category, 0]));
69
- for (const [key, count] of Object.entries(hostPowerStates ?? {})) {
70
- const mapped = HOST_POWER_KEY_ALIASES[normalizeKey(key)];
71
- const label = mapped ?? formatUnknownLabel(key);
72
- counts[label] = (counts[label] ?? 0) + (count || 0);
73
- }
74
- const orderedLabels = [
75
- ...HOST_POWER_CATEGORIES,
76
- ...Object.keys(counts).filter((label) => !HOST_POWER_CATEGORIES.includes(label)),
77
- ];
78
- const slices = orderedLabels.map((label) => toSlice(label, counts[label] ?? 0, "hosts"));
79
- const legend = {};
80
- for (const label of orderedLabels) {
81
- legend[label] = HOST_POWER_COLORS[label] ?? OTHER_COLOR;
82
- }
83
- return {
84
- slices,
85
- legend,
86
- total: sumCounts(counts),
87
- };
88
- };
89
- export const buildVmPowerStateChart = (powerStates) => {
90
- const counts = {
91
- "Powered off": 0,
92
- "Powered on": 0,
93
- };
94
- for (const [key, count] of Object.entries(powerStates ?? {})) {
95
- const mapped = VM_POWER_KEY_ALIASES[normalizeKey(key)];
96
- const label = mapped ?? formatUnknownLabel(key);
97
- counts[label] = (counts[label] ?? 0) + (count || 0);
98
- }
99
- const orderedLabels = [
100
- ...VM_POWER_CATEGORIES.filter((category) => category !== "Suspended" || (counts[category] ?? 0) > 0),
101
- ...Object.keys(counts).filter((label) => !VM_POWER_CATEGORIES.includes(label)),
102
- ];
103
- const slices = orderedLabels.map((label) => toSlice(label, counts[label] ?? 0, "VMs"));
104
- const legend = {};
105
- for (const label of orderedLabels) {
106
- legend[label] = VM_POWER_COLORS[label] ?? OTHER_COLOR;
107
- }
108
- return {
109
- slices,
110
- legend,
111
- total: sumCounts(counts),
112
- };
113
- };