@openshift-migration-advisor/shared-components 0.23.0 → 0.25.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 +6 -0
  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/FeatureStatusBadge.d.ts +7 -0
  7. package/dist/report/FeatureStatusBadge.d.ts.map +1 -0
  8. package/dist/report/FeatureStatusBadge.js +13 -0
  9. package/dist/report/HostPowerStates.d.ts +9 -0
  10. package/dist/report/HostPowerStates.d.ts.map +1 -0
  11. package/dist/report/HostPowerStates.js +11 -0
  12. package/dist/report/InfrastructureSummary.d.ts +7 -0
  13. package/dist/report/InfrastructureSummary.d.ts.map +1 -0
  14. package/dist/report/InfrastructureSummary.js +5 -0
  15. package/dist/report/OSDistribution.d.ts.map +1 -1
  16. package/dist/report/OSDistribution.js +5 -13
  17. package/dist/report/OsSupportTiersHelpPopover.d.ts.map +1 -1
  18. package/dist/report/OsSupportTiersHelpPopover.js +2 -31
  19. package/dist/report/OsUpgradeNotice.d.ts.map +1 -1
  20. package/dist/report/OsUpgradeNotice.js +1 -5
  21. package/dist/report/PowerStateCard.d.ts +17 -0
  22. package/dist/report/PowerStateCard.d.ts.map +1 -0
  23. package/dist/report/PowerStateCard.js +7 -0
  24. package/dist/report/SupportTierBadge.d.ts.map +1 -1
  25. package/dist/report/SupportTierBadge.js +4 -2
  26. package/dist/report/VCenterClusterDetails.d.ts +10 -0
  27. package/dist/report/VCenterClusterDetails.d.ts.map +1 -0
  28. package/dist/report/VCenterClusterDetails.js +26 -0
  29. package/dist/report/VmPowerStates.d.ts +9 -0
  30. package/dist/report/VmPowerStates.d.ts.map +1 -0
  31. package/dist/report/VmPowerStates.js +11 -0
  32. package/dist/report/constants.d.ts +2 -0
  33. package/dist/report/constants.d.ts.map +1 -1
  34. package/dist/report/constants.js +2 -0
  35. package/dist/report/index.d.ts +10 -0
  36. package/dist/report/index.d.ts.map +1 -1
  37. package/dist/report/index.js +8 -0
  38. package/dist/report/infrastructureSummaryModel.d.ts +82 -0
  39. package/dist/report/infrastructureSummaryModel.d.ts.map +1 -0
  40. package/dist/report/infrastructureSummaryModel.js +139 -0
  41. package/dist/report/powerStates.d.ts +11 -0
  42. package/dist/report/powerStates.d.ts.map +1 -0
  43. package/dist/report/powerStates.js +113 -0
  44. package/package.json +1 -1
  45. package/src/charts/index.ts +1 -0
  46. package/src/forms/RadioButtonFormGroup.tsx +10 -3
  47. package/src/report/FeatureStatusBadge.tsx +30 -0
  48. package/src/report/HostPowerStates.tsx +41 -0
  49. package/src/report/InfrastructureSummary.tsx +56 -0
  50. package/src/report/OSDistribution.tsx +60 -67
  51. package/src/report/OsSupportTiersHelpPopover.tsx +32 -62
  52. package/src/report/OsUpgradeNotice.tsx +1 -7
  53. package/src/report/PowerStateCard.tsx +73 -0
  54. package/src/report/SupportTierBadge.tsx +4 -2
  55. package/src/report/VCenterClusterDetails.tsx +211 -0
  56. package/src/report/VmPowerStates.tsx +41 -0
  57. package/src/report/__tests__/HostPowerStates.test.tsx +47 -0
  58. package/src/report/__tests__/InfrastructureSummary.test.tsx +148 -0
  59. package/src/report/__tests__/infrastructureSummaryModel.test.ts +224 -0
  60. package/src/report/__tests__/powerStates.test.ts +70 -0
  61. package/src/report/constants.ts +2 -0
  62. package/src/report/index.ts +56 -0
  63. package/src/report/infrastructureSummaryModel.ts +281 -0
  64. package/src/report/powerStates.ts +169 -0
@@ -0,0 +1,139 @@
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
+ };
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,113 @@
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openshift-migration-advisor/shared-components",
3
- "version": "0.23.0",
3
+ "version": "0.25.0",
4
4
  "description": "Shared React UI components for Migration Advisor apps (report charts, forms, OS support tiers)",
5
5
  "author": "Montse Ortega <mortegag@redhat.com>",
6
6
  "license": "Apache-2.0",
@@ -1,5 +1,6 @@
1
1
  export {
2
2
  MigrationDonutChart,
3
3
  type MigrationDonutChartDatum,
4
+ type MigrationDonutChartLegendVariant,
4
5
  type MigrationDonutChartProps,
5
6
  } from "./MigrationDonutChart.js";
@@ -33,12 +33,19 @@ export default function RadioButtonFormGroup({
33
33
  const showError = error && (isTouched || isSubmitted);
34
34
 
35
35
  return (
36
- <FormGroup label={label} isRequired={isRequired} fieldId={id} {...props}>
36
+ <FormGroup
37
+ label={label}
38
+ isRequired={isRequired}
39
+ fieldId={id}
40
+ role="radiogroup"
41
+ isInline
42
+ {...props}
43
+ >
37
44
  <Controller
38
45
  name={name}
39
46
  control={methods.control}
40
47
  render={({ field }) => (
41
- <div style={{ display: "flex", gap: "16px" }} role="radiogroup">
48
+ <>
42
49
  {options.map((option) => (
43
50
  <Radio
44
51
  key={option.value}
@@ -50,7 +57,7 @@ export default function RadioButtonFormGroup({
50
57
  onBlur={field.onBlur}
51
58
  />
52
59
  ))}
53
- </div>
60
+ </>
54
61
  )}
55
62
  />
56
63
  <FormFieldHelperText
@@ -0,0 +1,30 @@
1
+ import { Label } from "@patternfly/react-core";
2
+ import { CheckCircleIcon, TimesCircleIcon } from "@patternfly/react-icons";
3
+ import type { FC } from "react";
4
+ import type { FeatureStatus } from "./infrastructureSummaryModel.js";
5
+
6
+ export interface FeatureStatusBadgeProps {
7
+ status: FeatureStatus;
8
+ }
9
+
10
+ export const FeatureStatusBadge: FC<FeatureStatusBadgeProps> = ({ status }) => {
11
+ if (status === "unknown") {
12
+ return <span>—</span>;
13
+ }
14
+
15
+ if (status === "enabled") {
16
+ return (
17
+ <Label color="green" isCompact icon={<CheckCircleIcon />}>
18
+ Enabled
19
+ </Label>
20
+ );
21
+ }
22
+
23
+ return (
24
+ <Label color="grey" isCompact icon={<TimesCircleIcon />}>
25
+ Disabled
26
+ </Label>
27
+ );
28
+ };
29
+
30
+ FeatureStatusBadge.displayName = "FeatureStatusBadge";
@@ -0,0 +1,41 @@
1
+ import { ServerIcon } from "@patternfly/react-icons";
2
+ import type { FC } from "react";
3
+ import { useMemo } from "react";
4
+ import type { MigrationDonutChartLegendVariant } from "../charts/MigrationDonutChart.js";
5
+ import { REPORT_CARD_EMPTY_STATE_TITLES } from "./constants.js";
6
+ import { PowerStateCard } from "./PowerStateCard.js";
7
+ import { buildHostPowerStateChart } from "./powerStates.js";
8
+
9
+ export interface HostPowerStatesProps {
10
+ hostPowerStates?: Record<string, number>;
11
+ isExportMode?: boolean;
12
+ legendVariant?: MigrationDonutChartLegendVariant;
13
+ }
14
+
15
+ export const HostPowerStates: FC<HostPowerStatesProps> = ({
16
+ hostPowerStates,
17
+ isExportMode = false,
18
+ legendVariant,
19
+ }) => {
20
+ const chart = useMemo(
21
+ () => buildHostPowerStateChart(hostPowerStates),
22
+ [hostPowerStates],
23
+ );
24
+
25
+ return (
26
+ <PowerStateCard
27
+ id="esxi-host-power-states"
28
+ title="ESXi host power states"
29
+ icon={<ServerIcon />}
30
+ emptyTitle={REPORT_CARD_EMPTY_STATE_TITLES.hostPowerStates}
31
+ slices={chart.slices}
32
+ legend={chart.legend}
33
+ total={chart.total}
34
+ subTitle="Hosts"
35
+ isExportMode={isExportMode}
36
+ legendVariant={legendVariant}
37
+ />
38
+ );
39
+ };
40
+
41
+ HostPowerStates.displayName = "HostPowerStates";
@@ -0,0 +1,56 @@
1
+ import {
2
+ Card,
3
+ CardBody,
4
+ CardTitle,
5
+ DescriptionList,
6
+ DescriptionListDescription,
7
+ DescriptionListGroup,
8
+ DescriptionListTerm,
9
+ } from "@patternfly/react-core";
10
+ import type { FC } from "react";
11
+ import type { InfrastructureSummaryModel } from "./infrastructureSummaryModel.js";
12
+
13
+ export interface InfrastructureSummaryProps {
14
+ summary: InfrastructureSummaryModel;
15
+ }
16
+
17
+ const formatCount = (value: number | undefined): string =>
18
+ typeof value === "number" ? String(value) : "—";
19
+
20
+ export const InfrastructureSummary: FC<InfrastructureSummaryProps> = ({
21
+ summary,
22
+ }) => (
23
+ <Card isFullHeight id="infrastructure-summary">
24
+ <CardTitle>Infrastructure summary</CardTitle>
25
+ <CardBody>
26
+ <DescriptionList isAutoFit displaySize="lg">
27
+ <DescriptionListGroup>
28
+ <DescriptionListTerm>VMware version</DescriptionListTerm>
29
+ <DescriptionListDescription>
30
+ {summary.vmwareVersion}
31
+ </DescriptionListDescription>
32
+ </DescriptionListGroup>
33
+ <DescriptionListGroup>
34
+ <DescriptionListTerm>Datacenters</DescriptionListTerm>
35
+ <DescriptionListDescription>
36
+ {formatCount(summary.datacenters)}
37
+ </DescriptionListDescription>
38
+ </DescriptionListGroup>
39
+ <DescriptionListGroup>
40
+ <DescriptionListTerm>vCenters</DescriptionListTerm>
41
+ <DescriptionListDescription>
42
+ {formatCount(summary.vCenters)}
43
+ </DescriptionListDescription>
44
+ </DescriptionListGroup>
45
+ <DescriptionListGroup>
46
+ <DescriptionListTerm>ESXi hosts</DescriptionListTerm>
47
+ <DescriptionListDescription>
48
+ {formatCount(summary.esxiHosts)}
49
+ </DescriptionListDescription>
50
+ </DescriptionListGroup>
51
+ </DescriptionList>
52
+ </CardBody>
53
+ </Card>
54
+ );
55
+
56
+ InfrastructureSummary.displayName = "InfrastructureSummary";
@@ -11,6 +11,8 @@ import {
11
11
  Select,
12
12
  SelectList,
13
13
  SelectOption,
14
+ Stack,
15
+ StackItem,
14
16
  Toolbar,
15
17
  ToolbarContent,
16
18
  ToolbarItem,
@@ -36,22 +38,9 @@ import {
36
38
  useOsBarChartViewModel,
37
39
  } from "./useOsBarChartViewModel.js";
38
40
 
39
- const filterToolbarStyle = css`
40
- padding-left: 0;
41
- padding-right: 0;
42
- `;
43
-
44
- const filterItemStyle = css`
45
- flex: 1 1 0;
46
- min-width: 0;
47
- `;
48
-
49
- const vmsColumnStyle = css`
50
- text-align: right;
51
- `;
52
-
53
41
  const tableScrollStyle = css`
54
42
  overflow: auto;
43
+ max-height: 350px;
55
44
  `;
56
45
 
57
46
  interface OSDistributionProps {
@@ -106,9 +95,9 @@ export const OSBarChart: FC<OSBarChartProps> = ({
106
95
  return (
107
96
  <>
108
97
  {!isExportMode ? (
109
- <Toolbar className={filterToolbarStyle}>
98
+ <Toolbar hasNoPadding>
110
99
  <ToolbarContent>
111
- <ToolbarItem className={filterItemStyle}>
100
+ <ToolbarItem>
112
101
  <SearchInput
113
102
  placeholder="Filter by OS"
114
103
  value={vm.osFilter}
@@ -117,7 +106,7 @@ export const OSBarChart: FC<OSBarChartProps> = ({
117
106
  aria-label="Filter operating systems by name"
118
107
  />
119
108
  </ToolbarItem>
120
- <ToolbarItem className={filterItemStyle}>
109
+ <ToolbarItem>
121
110
  <Select
122
111
  isOpen={vm.isTierSelectOpen}
123
112
  selected={vm.tierFilter}
@@ -128,7 +117,7 @@ export const OSBarChart: FC<OSBarChartProps> = ({
128
117
  ref={toggleRef}
129
118
  isExpanded={vm.isTierSelectOpen}
130
119
  onClick={vm.toggleTierSelectOpen}
131
- style={{ width: "100%" }}
120
+ isFullWidth
132
121
  >
133
122
  {vm.tierFilterLabel}
134
123
  </MenuToggle>
@@ -151,56 +140,60 @@ export const OSBarChart: FC<OSBarChartProps> = ({
151
140
  </Toolbar>
152
141
  ) : null}
153
142
 
154
- {vm.showUpgradeNotice ? <OsUpgradeNotice /> : null}
155
-
156
- <div
157
- className={isExportMode ? undefined : tableScrollStyle}
158
- style={isExportMode ? undefined : { maxHeight: "350px" }}
159
- >
160
- <Table
161
- aria-label="Operating systems"
162
- variant="compact"
163
- className={tableFullWidthStyle}
164
- >
165
- <Thead>
166
- <Tr>
167
- <Th>OS</Th>
168
- <Th>Tier</Th>
169
- <Th className={vmsColumnStyle}>VMs</Th>
170
- </Tr>
171
- </Thead>
172
- <Tbody>
173
- {vm.showNoResults ? (
174
- <Tr>
175
- <Td colSpan={3}>
176
- <EmptySearchResults title="No matching operating system found" />
177
- </Td>
178
- </Tr>
179
- ) : (
180
- vm.filteredRows.map((row) => (
181
- <Tr key={row.osName}>
182
- <Td dataLabel="OS">
183
- <OsNameCell
184
- osName={row.osName}
185
- upgradeRecommendation={row.upgradeRecommendation}
186
- isExportMode={isExportMode}
187
- />
188
- </Td>
189
- <Td dataLabel="Tier">
190
- <SupportTierBadge
191
- tier={row.tier}
192
- isExportMode={isExportMode}
193
- />
194
- </Td>
195
- <Td dataLabel="VMs" className={vmsColumnStyle}>
196
- {row.count}
197
- </Td>
143
+ <Stack hasGutter>
144
+ {vm.showUpgradeNotice ? (
145
+ <StackItem>
146
+ <OsUpgradeNotice />
147
+ </StackItem>
148
+ ) : null}
149
+ <StackItem>
150
+ <div
151
+ className={
152
+ isExportMode
153
+ ? tableFullWidthStyle
154
+ : `${tableScrollStyle} ${tableFullWidthStyle}`
155
+ }
156
+ >
157
+ <Table aria-label="Operating systems" variant="compact">
158
+ <Thead>
159
+ <Tr>
160
+ <Th>OS</Th>
161
+ <Th>Tier</Th>
162
+ <Th>VMs</Th>
198
163
  </Tr>
199
- ))
200
- )}
201
- </Tbody>
202
- </Table>
203
- </div>
164
+ </Thead>
165
+ <Tbody>
166
+ {vm.showNoResults ? (
167
+ <Tr>
168
+ <Td colSpan={3}>
169
+ <EmptySearchResults title="No matching operating system found" />
170
+ </Td>
171
+ </Tr>
172
+ ) : (
173
+ vm.filteredRows.map((row) => (
174
+ <Tr key={row.osName}>
175
+ <Td dataLabel="OS">
176
+ <OsNameCell
177
+ osName={row.osName}
178
+ upgradeRecommendation={row.upgradeRecommendation}
179
+ isExportMode={isExportMode}
180
+ />
181
+ </Td>
182
+ <Td dataLabel="Tier">
183
+ <SupportTierBadge
184
+ tier={row.tier}
185
+ isExportMode={isExportMode}
186
+ />
187
+ </Td>
188
+ <Td dataLabel="VMs">{row.count}</Td>
189
+ </Tr>
190
+ ))
191
+ )}
192
+ </Tbody>
193
+ </Table>
194
+ </div>
195
+ </StackItem>
196
+ </Stack>
204
197
  </>
205
198
  );
206
199
  };