@openshift-assisted/ui-lib 2.9.14-cim → 2.9.15-cim

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 (114) hide show
  1. package/build/@types/cim/components/Agent/AgentStatus.d.ts.map +1 -1
  2. package/build/@types/cim/components/Agent/AgentTable.d.ts.map +1 -1
  3. package/build/@types/cim/components/Agent/AgentsSelectionTable.d.ts.map +1 -1
  4. package/build/@types/cim/components/Agent/tableUtils.d.ts +11 -6
  5. package/build/@types/cim/components/Agent/tableUtils.d.ts.map +1 -1
  6. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentDetailsTable.d.ts.map +1 -1
  7. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentHostDiscoveryTable.d.ts.map +1 -1
  8. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentHostsNetworkTable.d.ts.map +1 -1
  9. package/build/@types/cim/components/Hypershift/utils/status.d.ts.map +1 -1
  10. package/build/@types/cim/components/InfraEnv/InfraEnvAgentTable.d.ts.map +1 -1
  11. package/build/@types/cim/components/InfraEnv/InfraEnvHostsTabAgentsWarning.d.ts.map +1 -1
  12. package/build/@types/cim/components/InfraEnv/InfraTableToolbar.d.ts.map +1 -1
  13. package/build/@types/cim/components/helpers/agentStatus.d.ts +3 -2
  14. package/build/@types/cim/components/helpers/agentStatus.d.ts.map +1 -1
  15. package/build/@types/cim/components/helpers/agents.d.ts.map +1 -1
  16. package/build/@types/cim/components/helpers/status.d.ts +5 -2
  17. package/build/@types/cim/components/helpers/status.d.ts.map +1 -1
  18. package/build/@types/cim/components/modals/MassApproveAgentModal.d.ts.map +1 -1
  19. package/build/@types/cim/components/modals/MassDeleteAgentModal.d.ts.map +1 -1
  20. package/build/@types/common/components/hosts/HostRowDetail.d.ts.map +1 -1
  21. package/build/@types/common/components/hosts/HostStatus.d.ts.map +1 -1
  22. package/build/@types/common/components/hosts/status.d.ts +2 -1
  23. package/build/@types/common/components/hosts/status.d.ts.map +1 -1
  24. package/build/@types/common/components/hosts/tableUtils.d.ts +1 -1
  25. package/build/@types/common/components/hosts/tableUtils.d.ts.map +1 -1
  26. package/build/@types/common/components/storage/StorageDetail.d.ts.map +1 -1
  27. package/build/@types/ocm/components/clusterDetail/HostInventoryExpandable.d.ts.map +1 -1
  28. package/build/@types/ocm/components/hosts/HardwareStatus.d.ts.map +1 -1
  29. package/build/@types/ocm/components/hosts/NetworkingStatus.d.ts.map +1 -1
  30. package/build/cjs/cim/components/Agent/AgentStatus.js +4 -3
  31. package/build/cjs/cim/components/Agent/AgentStatus.js.map +1 -1
  32. package/build/cjs/cim/components/Agent/AgentTable.js +4 -1
  33. package/build/cjs/cim/components/Agent/AgentTable.js.map +1 -1
  34. package/build/cjs/cim/components/Agent/AgentsSelectionTable.js +4 -0
  35. package/build/cjs/cim/components/Agent/AgentsSelectionTable.js.map +1 -1
  36. package/build/cjs/cim/components/Agent/tableUtils.js +35 -37
  37. package/build/cjs/cim/components/Agent/tableUtils.js.map +1 -1
  38. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentDetailsTable.js +4 -1
  39. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentDetailsTable.js.map +1 -1
  40. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentHostDiscoveryTable.js +19 -2
  41. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentHostDiscoveryTable.js.map +1 -1
  42. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentHostsNetworkTable.js +18 -3
  43. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentHostsNetworkTable.js.map +1 -1
  44. package/build/cjs/cim/components/Hypershift/utils/status.js +3 -1
  45. package/build/cjs/cim/components/Hypershift/utils/status.js.map +1 -1
  46. package/build/cjs/cim/components/InfraEnv/InfraEnvAgentTable.js +20 -7
  47. package/build/cjs/cim/components/InfraEnv/InfraEnvAgentTable.js.map +1 -1
  48. package/build/cjs/cim/components/InfraEnv/InfraEnvHostsTabAgentsWarning.js +5 -2
  49. package/build/cjs/cim/components/InfraEnv/InfraEnvHostsTabAgentsWarning.js.map +1 -1
  50. package/build/cjs/cim/components/InfraEnv/InfraTableToolbar.js +17 -10
  51. package/build/cjs/cim/components/InfraEnv/InfraTableToolbar.js.map +1 -1
  52. package/build/cjs/cim/components/helpers/agentStatus.js +17 -15
  53. package/build/cjs/cim/components/helpers/agentStatus.js.map +1 -1
  54. package/build/cjs/cim/components/helpers/agents.js +2 -2
  55. package/build/cjs/cim/components/helpers/agents.js.map +1 -1
  56. package/build/cjs/cim/components/helpers/status.js +40 -22
  57. package/build/cjs/cim/components/helpers/status.js.map +1 -1
  58. package/build/cjs/cim/components/helpers/toAssisted.js +2 -2
  59. package/build/cjs/cim/components/helpers/toAssisted.js.map +1 -1
  60. package/build/cjs/cim/components/modals/MassApproveAgentModal.js +8 -5
  61. package/build/cjs/cim/components/modals/MassApproveAgentModal.js.map +1 -1
  62. package/build/cjs/cim/components/modals/MassDeleteAgentModal.js +40 -33
  63. package/build/cjs/cim/components/modals/MassDeleteAgentModal.js.map +1 -1
  64. package/build/cjs/common/components/clusterWizard/networkingSteps/ManagedNetworkingControlGroup.js +1 -1
  65. package/build/cjs/common/components/clusterWizard/networkingSteps/ManagedNetworkingControlGroup.js.map +1 -1
  66. package/build/cjs/common/components/hosts/HostRowDetail.js +14 -14
  67. package/build/cjs/common/components/hosts/HostRowDetail.js.map +1 -1
  68. package/build/cjs/common/components/hosts/HostStatus.js +2 -1
  69. package/build/cjs/common/components/hosts/HostStatus.js.map +1 -1
  70. package/build/cjs/common/components/hosts/status.js +54 -53
  71. package/build/cjs/common/components/hosts/status.js.map +1 -1
  72. package/build/cjs/common/components/hosts/tableUtils.js +3 -3
  73. package/build/cjs/common/components/hosts/tableUtils.js.map +1 -1
  74. package/build/cjs/common/components/storage/DisksTable.js +8 -8
  75. package/build/cjs/common/components/storage/DisksTable.js.map +1 -1
  76. package/build/cjs/common/components/storage/StorageDetail.js +3 -1
  77. package/build/cjs/common/components/storage/StorageDetail.js.map +1 -1
  78. package/build/cjs/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfigurationTableBase.js +1 -1
  79. package/build/cjs/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfigurationTableBase.js.map +1 -1
  80. package/build/cjs/ocm/components/clusterDetail/HostInventoryExpandable.js +3 -1
  81. package/build/cjs/ocm/components/clusterDetail/HostInventoryExpandable.js.map +1 -1
  82. package/build/cjs/ocm/components/hosts/HardwareStatus.js +3 -1
  83. package/build/cjs/ocm/components/hosts/HardwareStatus.js.map +1 -1
  84. package/build/cjs/ocm/components/hosts/NetworkingStatus.js +3 -1
  85. package/build/cjs/ocm/components/hosts/NetworkingStatus.js.map +1 -1
  86. package/lib/cim/components/Agent/AgentStatus.tsx +4 -3
  87. package/lib/cim/components/Agent/AgentTable.tsx +4 -1
  88. package/lib/cim/components/Agent/AgentsSelectionTable.tsx +4 -0
  89. package/lib/cim/components/Agent/tableUtils.tsx +70 -36
  90. package/lib/cim/components/ClusterDeployment/ClusterDeploymentDetailsTable.tsx +4 -1
  91. package/lib/cim/components/ClusterDeployment/ClusterDeploymentHostDiscoveryTable.tsx +21 -2
  92. package/lib/cim/components/ClusterDeployment/ClusterDeploymentHostsNetworkTable.tsx +18 -3
  93. package/lib/cim/components/Hypershift/utils/status.tsx +3 -1
  94. package/lib/cim/components/InfraEnv/InfraEnvAgentTable.tsx +20 -7
  95. package/lib/cim/components/InfraEnv/InfraEnvHostsTabAgentsWarning.tsx +5 -2
  96. package/lib/cim/components/InfraEnv/InfraTableToolbar.tsx +21 -11
  97. package/lib/cim/components/helpers/agentStatus.tsx +17 -16
  98. package/lib/cim/components/helpers/agents.ts +3 -4
  99. package/lib/cim/components/helpers/status.ts +44 -24
  100. package/lib/cim/components/helpers/toAssisted.ts +3 -3
  101. package/lib/cim/components/modals/MassApproveAgentModal.tsx +13 -5
  102. package/lib/cim/components/modals/MassDeleteAgentModal.tsx +63 -56
  103. package/lib/common/components/clusterWizard/networkingSteps/ManagedNetworkingControlGroup.tsx +3 -3
  104. package/lib/common/components/hosts/HostRowDetail.tsx +20 -17
  105. package/lib/common/components/hosts/HostStatus.tsx +3 -1
  106. package/lib/common/components/hosts/status.tsx +227 -212
  107. package/lib/common/components/hosts/tableUtils.tsx +3 -3
  108. package/lib/common/components/storage/DisksTable.tsx +8 -8
  109. package/lib/common/components/storage/StorageDetail.tsx +4 -1
  110. package/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfigurationTableBase.tsx +1 -1
  111. package/lib/ocm/components/clusterDetail/HostInventoryExpandable.tsx +3 -1
  112. package/lib/ocm/components/hosts/HardwareStatus.tsx +3 -1
  113. package/lib/ocm/components/hosts/NetworkingStatus.tsx +3 -1
  114. package/package.json +3 -3
@@ -3,60 +3,61 @@ import { ConnectedIcon, ExclamationCircleIcon } from '@patternfly/react-icons';
3
3
  import { global_danger_color_100 as dangerColor } from '@patternfly/react-tokens';
4
4
  import { hostStatus } from '../../../common';
5
5
  import { HostStatus } from '../../../common/components/hosts/types';
6
+ import { TFunction } from 'i18next';
6
7
 
7
- export const bmhStatus: HostStatus<string> = {
8
+ export const bmhStatus = (t: TFunction): HostStatus<string> => ({
8
9
  'bmh-error': {
9
10
  key: 'bmh-error',
10
- title: 'Error',
11
+ title: t('ai:Error'),
11
12
  category: 'Bare Metal Host related',
12
13
  },
13
14
  registering: {
14
15
  key: 'registering',
15
- title: 'Registering',
16
+ title: t('ai:Registering'),
16
17
  category: 'Bare Metal Host related',
17
18
  },
18
19
  provisioning: {
19
20
  key: 'provisioning',
20
- title: 'Provisioning',
21
+ title: t('ai:Provisioning'),
21
22
  category: 'Bare Metal Host related',
22
23
  },
23
24
  provisioned: {
24
25
  key: 'provisioned',
25
- title: 'Provisioned',
26
+ title: t('ai:Provisioned'),
26
27
  category: 'Bare Metal Host related',
27
28
  },
28
29
  deprovisioning: {
29
30
  key: 'deprovisioning',
30
- title: 'Deprovisioning',
31
+ title: t('ai:Deprovisioning'),
31
32
  category: 'Bare Metal Host related',
32
33
  },
33
34
  inspecting: {
34
35
  key: 'inspecting',
35
- title: 'Inspecting',
36
+ title: t('ai:Inspecting'),
36
37
  category: 'Bare Metal Host related',
37
38
  },
38
39
  pending: {
39
40
  key: 'pending',
40
- title: 'Pending',
41
+ title: t('ai:Pending'),
41
42
  category: 'Bare Metal Host related',
42
43
  },
43
- };
44
+ });
44
45
 
45
- export const agentStatus: HostStatus<string> = {
46
- ...hostStatus,
46
+ export const agentStatus = (t: TFunction): HostStatus<string> => ({
47
+ ...hostStatus(t),
47
48
  discovered: {
48
49
  key: 'discovered',
49
- title: 'Discovered',
50
+ title: t('ai:Discovered'),
50
51
  icon: <ConnectedIcon />,
51
52
  noPopover: true,
52
53
  category: 'Discovery related',
53
- details: 'The host has been discovered and needs to be approved to before further use.',
54
+ details: t('ai:The host has been discovered and needs to be approved to before further use.'),
54
55
  },
55
- ...bmhStatus,
56
+ ...bmhStatus(t),
56
57
  specSyncErr: {
57
58
  key: 'spec-sync-err',
58
- title: 'Sync error',
59
+ title: t('ai:Sync error'),
59
60
  icon: <ExclamationCircleIcon color={dangerColor.value} />,
60
61
  category: 'Discovery related',
61
62
  },
62
- };
63
+ });
@@ -1,7 +1,6 @@
1
- import { AgentStatus } from './status';
1
+ import { AgentStatus, getAgentStatusKey } from './status';
2
2
  import { Host } from '@openshift-assisted/types/assisted-installer-service';
3
3
  import { AgentK8sResource, BareMetalHostK8sResource } from '../../types';
4
- import { getAgentStatus } from './status';
5
4
  import { INFRAENV_AGENTINSTALL_LABEL_KEY } from '../common/constants';
6
5
 
7
6
  const AGENT_FOR_SELECTION_STATUSES: AgentStatus[] = [
@@ -21,8 +20,8 @@ export const hostToAgent = (agents: AgentK8sResource[] = [], host: Host) =>
21
20
 
22
21
  export const getAgentsForSelection = (agents: AgentK8sResource[]) =>
23
22
  agents.filter((agent) => {
24
- const { status } = getAgentStatus(agent);
25
- return AGENT_FOR_SELECTION_STATUSES.includes(status.key as AgentStatus);
23
+ const key = getAgentStatusKey(agent);
24
+ return AGENT_FOR_SELECTION_STATUSES.includes(key as AgentStatus);
26
25
  });
27
26
 
28
27
  export const getAgentRole = (agent: AgentK8sResource) => agent.spec.role || agent.status?.role;
@@ -22,8 +22,9 @@ import {
22
22
  wizardStepsValidationsMap,
23
23
  } from '../ClusterDeployment/wizardTransition';
24
24
  import { HostStatusDef } from '../../../common';
25
- import { agentStatus, bmhStatus } from './agentStatus';
25
+ import { agentStatus } from './agentStatus';
26
26
  import { TFunction } from 'i18next';
27
+ import { HostStatus } from '../../../common/components/hosts/types';
27
28
 
28
29
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
30
  const conditionsByTypeReducer = <K>(
@@ -125,29 +126,40 @@ export type AgentStatus = Host['status'] | 'discovered';
125
126
  const getInsufficientState = (agent: AgentK8sResource) =>
126
127
  agent?.spec?.clusterDeploymentName?.name ? 'insufficient' : 'insufficient-unbound';
127
128
 
128
- export const getAgentStatus = (
129
- agent: AgentK8sResource,
130
- excludeDiscovered = false,
131
- ): { status: HostStatusDef; validationsInfo: ValidationsInfo; autoCSR?: boolean } => {
129
+ export const getAgentStatusKey = (agent: AgentK8sResource, excludeDiscovered = false) => {
132
130
  const specSyncErr = agent.status?.conditions?.find(
133
131
  (c) => c.type === 'SpecSynced' && c.status === 'False',
134
132
  );
135
-
136
- let status: HostStatusDef;
137
- let validationsInfo: ValidationsInfo = {};
138
133
  if (specSyncErr) {
139
- status = agentStatus['specSyncErr'];
134
+ return 'specSyncError';
140
135
  } else {
141
- status = agentStatus[agent.status?.debugInfo?.state || getInsufficientState(agent)];
142
- validationsInfo = agent.status?.validationsInfo || {};
143
136
  if (!excludeDiscovered && !agent.spec.approved) {
144
- status = agentStatus.discovered;
137
+ return 'discovered';
138
+ } else {
139
+ return agent.status?.debugInfo?.state || getInsufficientState(agent);
145
140
  }
146
- // TODO(jtomasek): Implement this
147
- // const sublabel = areOnlyClusterSoftValidationsFailing(agentStatus.validationsInfo)
148
- // ? 'Some validations failed'
149
- // : undefined;
150
141
  }
142
+ };
143
+
144
+ export const getAgentStatus = (
145
+ agent: AgentK8sResource,
146
+ agentStatuses: HostStatus<string>,
147
+ excludeDiscovered = false,
148
+ ): { status: HostStatusDef; validationsInfo: ValidationsInfo; autoCSR?: boolean } => {
149
+ const key = getAgentStatusKey(agent, excludeDiscovered);
150
+
151
+ let validationsInfo: ValidationsInfo = {};
152
+
153
+ const status = agentStatuses[key];
154
+ if (key !== 'specSyncError') {
155
+ validationsInfo = agent.status?.validationsInfo || {};
156
+ }
157
+
158
+ // TODO(jtomasek): Implement this
159
+ // const sublabel = areOnlyClusterSoftValidationsFailing(agentStatus.validationsInfo)
160
+ // ? 'Some validations failed'
161
+ // : undefined;
162
+
151
163
  return { status, validationsInfo };
152
164
  };
153
165
 
@@ -157,13 +169,15 @@ export const getWizardStepAgentStatus = (
157
169
  t: TFunction,
158
170
  excludeDiscovered = false,
159
171
  ): { status: HostStatusDef; validationsInfo: ValidationsInfo } => {
160
- const aStatus = getAgentStatus(agent, excludeDiscovered);
161
- if ([agentStatus.discovered, agentStatus.specSyncErr].includes(aStatus.status)) {
172
+ const agentStatuses = agentStatus(t);
173
+ const aStatus = getAgentStatus(agent, agentStatuses, excludeDiscovered);
174
+
175
+ if ([agentStatuses.discovered, agentStatuses.specSyncErr].includes(aStatus.status)) {
162
176
  return aStatus;
163
177
  }
164
178
 
165
179
  const status =
166
- agentStatus[
180
+ agentStatuses[
167
181
  getWizardStepHostStatus(wizardStepId, wizardStepsValidationsMap, {
168
182
  status: aStatus.status.key as Host['status'],
169
183
  validationsInfo: aStatus.validationsInfo,
@@ -188,13 +202,19 @@ export const getWizardStepAgentStatus = (
188
202
  };
189
203
  };
190
204
 
191
- export const getBMHStatus = (bmh: BareMetalHostK8sResource) => {
192
- let bmhState = bmhStatus.pending;
193
-
205
+ export const getBMHStatusKey = (bmh: BareMetalHostK8sResource) => {
194
206
  if (bmh.status?.errorType) {
195
- bmhState = bmhStatus['bmh-error'];
207
+ return 'bmh-error';
196
208
  } else if (bmh.status?.provisioning?.state) {
197
- bmhState = bmhStatus[bmh.status?.provisioning?.state] || bmhStatus.pending;
209
+ return bmh.status?.provisioning?.state;
210
+ }
211
+ };
212
+
213
+ export const getBMHStatus = (bmh: BareMetalHostK8sResource, bmhStatuses: HostStatus<string>) => {
214
+ let bmhState = bmhStatuses.pending;
215
+ const statusKey = getBMHStatusKey(bmh);
216
+ if (statusKey) {
217
+ bmhState = bmhStatuses[statusKey] || bmhState;
198
218
  }
199
219
 
200
220
  return {
@@ -3,7 +3,7 @@ import { AgentK8sResource } from '../../types/k8s/agent';
3
3
  import { Cluster, Host, Inventory } from '@openshift-assisted/types/assisted-installer-service';
4
4
  import { ClusterDeploymentK8sResource } from '../../types/k8s/cluster-deployment';
5
5
  import { AgentClusterInstallK8sResource } from '../../types/k8s/agent-cluster-install';
6
- import { getAgentStatus, getClusterStatus } from './status';
6
+ import { getAgentStatusKey, getClusterStatus } from './status';
7
7
  import { getHostNetworks } from './network';
8
8
  import { BareMetalHostK8sResource, InfraEnvK8sResource } from '../../types';
9
9
  import {
@@ -21,7 +21,7 @@ export const getAIHosts = (
21
21
  ) => {
22
22
  const bmhAgents: string[] = [];
23
23
  const hosts = agents.map((agent): Host => {
24
- const { status } = getAgentStatus(agent, true);
24
+ const statusKey = getAgentStatusKey(agent, true);
25
25
  const statusInfo = agent.status?.debugInfo?.stateInfo || '';
26
26
  // TODO(mlibra) Remove that workaround once https://issues.redhat.com/browse/MGMT-7052 is fixed
27
27
  const inventory: Inventory = cloneDeep(agent.status?.inventory || {});
@@ -50,7 +50,7 @@ export const getAIHosts = (
50
50
  kind: 'Host',
51
51
  id: agent.metadata?.uid || '',
52
52
  href: '',
53
- status: status.key as Host['status'],
53
+ status: statusKey as Host['status'],
54
54
  statusInfo,
55
55
  role: getAgentRole(agent),
56
56
  requestedHostname: agent.spec.hostname || inventory.hostname,
@@ -21,6 +21,7 @@ import { getErrorMessage } from '../../../common/utils';
21
21
  import { useTranslation } from '../../../common/hooks/use-translation-wrapper';
22
22
  import { TFunction } from 'i18next';
23
23
  import { Host } from '@openshift-assisted/types/assisted-installer-service';
24
+ import { HostStatus } from '../../../common/components/hosts/types';
24
25
 
25
26
  type ApproveTableRowProps = {
26
27
  agent?: AgentK8sResource;
@@ -51,7 +52,11 @@ const hostnameColumn = (agents: AgentK8sResource[], t: TFunction): TableRow<Host
51
52
  };
52
53
  };
53
54
 
54
- const statusColumn = (agents: AgentK8sResource[], t: TFunction): TableRow<Host> => {
55
+ const statusColumn = (
56
+ agents: AgentK8sResource[],
57
+ agentStatuses: HostStatus<string>,
58
+ t: TFunction,
59
+ ): TableRow<Host> => {
55
60
  return {
56
61
  header: {
57
62
  title: t('ai:Status'),
@@ -62,8 +67,10 @@ const statusColumn = (agents: AgentK8sResource[], t: TFunction): TableRow<Host>
62
67
  },
63
68
  cell: (host) => {
64
69
  const agent = agents.find((a) => a.metadata?.uid === host.id);
65
- const status = agent?.spec.approved ? t('ai:Already approved') : agentStatus.discovered.title;
66
- const icon = agentStatus.discovered.icon;
70
+ const status = agent?.spec.approved
71
+ ? t('ai:Already approved')
72
+ : agentStatuses.discovered.title;
73
+ const icon = agentStatuses.discovered.icon;
67
74
  return {
68
75
  title: (
69
76
  <ApproveTableRow agent={agent}>
@@ -99,6 +106,7 @@ const MassApproveAgentModal: React.FC<MassApproveAgentModalProps> = ({
99
106
  const [progress, setProgress] = React.useState<number | null>(null);
100
107
  const [error, setError] = React.useState<{ title: string; message: string }>();
101
108
  const { t } = useTranslation();
109
+ const agentStatuses = agentStatus(t);
102
110
  const onClick = async () => {
103
111
  setError(undefined);
104
112
  let i = 0;
@@ -122,10 +130,10 @@ const MassApproveAgentModal: React.FC<MassApproveAgentModalProps> = ({
122
130
  };
123
131
  const { content, hosts } = React.useMemo(
124
132
  () => ({
125
- content: [hostnameColumn(agents, t), statusColumn(agents, t)],
133
+ content: [hostnameColumn(agents, t), statusColumn(agents, agentStatuses, t)],
126
134
  hosts: getAIHosts(agents),
127
135
  }),
128
- [agents, t],
136
+ [agentStatuses, agents, t],
129
137
  );
130
138
 
131
139
  const paginationProps = usePagination(hosts.length);
@@ -26,6 +26,7 @@ import { usePagination } from '../../../common/components/hosts/usePagination';
26
26
  import { useTranslation } from '../../../common/hooks/use-translation-wrapper';
27
27
  import { TFunction } from 'i18next';
28
28
  import { Host } from '@openshift-assisted/types/assisted-installer-service';
29
+ import { agentStatus, bmhStatus } from '../helpers/agentStatus';
29
30
 
30
31
  const hostnameColumn = (agents: AgentK8sResource[], t: TFunction): TableRow<Host> => {
31
32
  return {
@@ -56,65 +57,71 @@ const statusColumn = (
56
57
  agents: AgentK8sResource[],
57
58
  bmhs: BareMetalHostK8sResource[],
58
59
  t: TFunction,
59
- ): TableRow<Host> => ({
60
- header: {
61
- title: t('ai:Status'),
62
- props: {
63
- id: 'col-header-status',
60
+ ): TableRow<Host> => {
61
+ const agentStatuses = agentStatus(t);
62
+ const bmhStatuses = bmhStatus(t);
63
+ return {
64
+ header: {
65
+ title: t('ai:Status'),
66
+ props: {
67
+ id: 'col-header-status',
68
+ },
69
+ transforms: [sortable],
64
70
  },
65
- transforms: [sortable],
66
- },
67
- cell: (host) => {
68
- const agent = agents.find((a) => a.metadata?.uid === host.id);
69
- const clusterName = agent?.spec.clusterDeploymentName?.name;
70
- const bmh = bmhs?.find((b) => b.metadata?.uid === host.id);
71
+ cell: (host) => {
72
+ const agent = agents.find((a) => a.metadata?.uid === host.id);
73
+ const clusterName = agent?.spec.clusterDeploymentName?.name;
74
+ const bmh = bmhs?.find((b) => b.metadata?.uid === host.id);
71
75
 
72
- let bmhStatus;
73
- let title: React.ReactNode = '--';
74
- if (agent) {
75
- title = clusterName ? (
76
- <Flex>
77
- <FlexItem>
78
- <AgentStatus agent={agent} zIndex={7000} />
79
- </FlexItem>
80
- <FlexItem align={{ default: 'alignRight' }}>
81
- <Popover
82
- aria-label={t('ai:Cluster popover')}
83
- headerContent={<div>{t('ai:Cannot be deleted')}</div>}
84
- bodyContent={
85
- <div>
86
- {t(
87
- 'ai:Hosts that are bound to a cluster cannot be deleted. Remove the host from the cluster and try again.',
88
- )}
89
- </div>
90
- }
91
- footerContent={
92
- <Link to={`/multicloud/infrastructure/clusters/details/${clusterName}/`}>
93
- {t('ai:Go to cluster {{clusterName}}', { clusterName })}
94
- </Link>
95
- }
96
- >
97
- <Button variant="link" icon={<InfoCircleIcon color={blueInfoColor.value} />}>
98
- {t('ai:Cannot be deleted')}
99
- </Button>
100
- </Popover>
101
- </FlexItem>
102
- </Flex>
103
- ) : (
104
- <AgentStatus agent={agent} />
105
- );
106
- } else if (bmh) {
107
- bmhStatus = getBMHStatus(bmh);
108
- title = <BMHStatus bmhStatus={bmhStatus} />;
109
- }
76
+ let bmhStatus;
77
+ let title: React.ReactNode = '--';
78
+ if (agent) {
79
+ title = clusterName ? (
80
+ <Flex>
81
+ <FlexItem>
82
+ <AgentStatus agent={agent} zIndex={7000} />
83
+ </FlexItem>
84
+ <FlexItem align={{ default: 'alignRight' }}>
85
+ <Popover
86
+ aria-label={t('ai:Cluster popover')}
87
+ headerContent={<div>{t('ai:Cannot be deleted')}</div>}
88
+ bodyContent={
89
+ <div>
90
+ {t(
91
+ 'ai:Hosts that are bound to a cluster cannot be deleted. Remove the host from the cluster and try again.',
92
+ )}
93
+ </div>
94
+ }
95
+ footerContent={
96
+ <Link to={`/multicloud/infrastructure/clusters/details/${clusterName}/`}>
97
+ {t('ai:Go to cluster {{clusterName}}', { clusterName })}
98
+ </Link>
99
+ }
100
+ >
101
+ <Button variant="link" icon={<InfoCircleIcon color={blueInfoColor.value} />}>
102
+ {t('ai:Cannot be deleted')}
103
+ </Button>
104
+ </Popover>
105
+ </FlexItem>
106
+ </Flex>
107
+ ) : (
108
+ <AgentStatus agent={agent} />
109
+ );
110
+ } else if (bmh) {
111
+ bmhStatus = getBMHStatus(bmh, bmhStatuses);
112
+ title = <BMHStatus bmhStatus={bmhStatus} />;
113
+ }
110
114
 
111
- return {
112
- title,
113
- props: { 'data-testid': 'host-status' },
114
- sortableValue: agent ? getAgentStatus(agent).status.title : bmhStatus?.state.title || '',
115
- };
116
- },
117
- });
115
+ return {
116
+ title,
117
+ props: { 'data-testid': 'host-status' },
118
+ sortableValue: agent
119
+ ? getAgentStatus(agent, agentStatuses).status.title
120
+ : bmhStatus?.state.title || '',
121
+ };
122
+ },
123
+ };
124
+ };
118
125
 
119
126
  const tableContent = (
120
127
  agents: AgentK8sResource[],
@@ -51,9 +51,9 @@ export const ManagedNetworkingControlGroup = ({
51
51
  <>
52
52
  <span>{t('ai:User-Managed Networking')}</span>{' '}
53
53
  <PopoverIcon
54
- bodyContent={
55
- "With User-Managed Networking, you'll need to provide and configure a load balancer for the API and ingress endpoints."
56
- }
54
+ bodyContent={t(
55
+ "ai:With User-Managed Networking, you'll need to provide and configure a load balancer for the API and ingress endpoints.",
56
+ )}
57
57
  />
58
58
  </>
59
59
  }
@@ -24,6 +24,7 @@ import SectionTitle from '../ui/SectionTitle';
24
24
  import { OnDiskRoleType } from './DiskRole';
25
25
  import StorageDetail from '../storage/StorageDetail';
26
26
  import { stringToJSON } from '../../utils';
27
+ import { TFunction } from 'i18next';
27
28
 
28
29
  type HostDetailProps = {
29
30
  host: Host;
@@ -53,12 +54,12 @@ const SectionColumn: React.FC<SectionColumnProps> = ({ children }) => (
53
54
  </GridItem>
54
55
  );
55
56
 
56
- const nicsColumns = [
57
- { title: 'Name' },
58
- { title: 'MAC address' },
59
- { title: 'IPv4 address' },
60
- { title: 'IPv6 address' },
61
- { title: 'Speed' },
57
+ const nicsColumns = (t: TFunction) => [
58
+ { title: t('ai:Name') },
59
+ { title: t('ai:MAC address') },
60
+ { title: t('ai:IPv4 address') },
61
+ { title: t('ai:IPv6 address') },
62
+ { title: t('ai:Speed') },
62
63
  // { title: 'Vendor' }, TODO(mlibra): search HW database for humanized values
63
64
  // { title: 'Product' },
64
65
  ];
@@ -71,6 +72,7 @@ const NICsTableRowWrapper = (props: RowWrapperProps) => (
71
72
  );
72
73
 
73
74
  const NicsTable: React.FC<NicsTableProps & WithTestID> = ({ interfaces, testId }) => {
75
+ const { t } = useTranslation();
74
76
  const rows: IRow[] = interfaces
75
77
  .sort((nicA, nicB) => nicA.name?.localeCompare(nicB.name || '') || 0)
76
78
  .map((nic) => ({
@@ -92,12 +94,12 @@ const NicsTable: React.FC<NicsTableProps & WithTestID> = ({ interfaces, testId }
92
94
  ],
93
95
  key: nic.name,
94
96
  }));
95
- const { t } = useTranslation();
97
+
96
98
  return (
97
99
  <Table
98
100
  data-testid={testId}
99
101
  rows={rows}
100
- cells={nicsColumns}
102
+ cells={nicsColumns(t)}
101
103
  variant={TableVariant.compact}
102
104
  aria-label={t("ai:Host's network interfaces table")}
103
105
  borders={false}
@@ -148,9 +150,9 @@ export const HostDetail = ({
148
150
 
149
151
  return (
150
152
  <Grid hasGutter>
151
- <SectionTitle testId={'host-details-section'} title="Host details" />
153
+ <SectionTitle testId={'host-details-section'} title={t('ai:Host details')} />
152
154
  <SectionColumn>
153
- <DetailItem testId={'uuid'} title="UUID" value={id} />
155
+ <DetailItem testId={'uuid'} title={t('ai:UUID')} value={id} />
154
156
  <DetailItem
155
157
  testId={'manufacturer'}
156
158
  title={t('ai:Manufacturer')}
@@ -161,7 +163,11 @@ export const HostDetail = ({
161
163
  title={t('ai:Product')}
162
164
  value={inventory.systemVendor?.productName || DASH}
163
165
  />
164
- <DetailItem testId={'serial-number'} title="Serial number" value={rowInfo.serialNumber} />
166
+ <DetailItem
167
+ testId={'serial-number'}
168
+ title={t('ai:Serial number')}
169
+ value={rowInfo.serialNumber}
170
+ />
165
171
  </SectionColumn>
166
172
  <SectionColumn>
167
173
  <DetailItem
@@ -186,8 +192,8 @@ export const HostDetail = ({
186
192
  />
187
193
  </SectionColumn>
188
194
  <SectionColumn>
189
- <DetailItem testId={'hw-type'} title="Hardware type" value={hardwareType} />
190
- <DetailItem testId={'bmc-address'} title="BMC address" value={bmcAddress} />
195
+ <DetailItem testId={'hw-type'} title={t('ai:Hardware type')} value={hardwareType} />
196
+ <DetailItem testId={'bmc-address'} title={t('ai:BMC address')} value={bmcAddress} />
191
197
  <DetailItem
192
198
  testId={'boot-mode'}
193
199
  title={t('ai:Boot mode')}
@@ -215,10 +221,7 @@ export const HostDetail = ({
215
221
  updateDiskSkipFormatting={updateDiskSkipFormatting}
216
222
  />
217
223
  )}
218
- <SectionTitle
219
- testId={'nics-section'}
220
- title={`${nics.length} NIC${nics.length === 1 ? '' : 's'}`}
221
- />
224
+ <SectionTitle testId={'nics-section'} title={t('ai:NIC', { count: nics.length })} />
222
225
  <GridItem>
223
226
  <NicsTable interfaces={nics} testId={'nics-table'} />
224
227
  </GridItem>
@@ -230,6 +230,8 @@ const HostStatus: React.FC<HostStatusProps> = ({
230
230
  onEditHostname?.();
231
231
  }, [keepOnOutsideClick, onEditHostname]);
232
232
 
233
+ const { t } = useTranslation();
234
+
233
235
  const { title, icon, sublabel, details, noPopover } = status;
234
236
  const titleWithProgress = getTitleWithProgress(host, status);
235
237
  const popoverProps: WithHostStatusPopoverProps = {
@@ -251,7 +253,7 @@ const HostStatus: React.FC<HostStatusProps> = ({
251
253
  {
252
254
  <FlexItem>
253
255
  {(autoCSR && status.key === 'added-to-existing-cluster'
254
- ? hostStatus.installed.icon
256
+ ? hostStatus(t).installed.icon
255
257
  : icon) || <UnknownIcon />}
256
258
  </FlexItem>
257
259
  }