@openshift-assisted/ui-lib 2.14.1-cim → 2.14.2-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 (160) hide show
  1. package/build/@types/cim/components/ClusterDeployment/ACMClusterDeploymentDetailsStep.d.ts +2 -3
  2. package/build/@types/cim/components/ClusterDeployment/ACMClusterDeploymentDetailsStep.d.ts.map +1 -1
  3. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentDetailsForm.d.ts +3 -0
  4. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentDetailsForm.d.ts.map +1 -1
  5. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentDetailsStep.d.ts.map +1 -1
  6. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentHostDiscoveryTable.d.ts.map +1 -1
  7. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentHostSelectionStep.d.ts.map +1 -1
  8. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentHostsDiscovery.d.ts.map +1 -1
  9. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentHostsDiscoveryStep.d.ts +1 -1
  10. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentHostsDiscoveryStep.d.ts.map +1 -1
  11. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentNetworkingStep.d.ts +15 -2
  12. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentNetworkingStep.d.ts.map +1 -1
  13. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentReviewStep.d.ts +1 -2
  14. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentReviewStep.d.ts.map +1 -1
  15. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentWizard.d.ts +1 -2
  16. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentWizard.d.ts.map +1 -1
  17. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentWizardContext.d.ts +8 -7
  18. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentWizardContext.d.ts.map +1 -1
  19. package/build/@types/cim/components/ClusterDeployment/components/ClusterDeploymentHostsSelectionAdvanced.d.ts +17 -0
  20. package/build/@types/cim/components/ClusterDeployment/components/ClusterDeploymentHostsSelectionAdvanced.d.ts.map +1 -0
  21. package/build/@types/cim/components/ClusterDeployment/components/ClusterScaleUpAutoHostsSelection.d.ts +8 -0
  22. package/build/@types/cim/components/ClusterDeployment/components/ClusterScaleUpAutoHostsSelection.d.ts.map +1 -0
  23. package/build/@types/cim/components/ClusterDeployment/components/ValidationSection.d.ts +16 -0
  24. package/build/@types/cim/components/ClusterDeployment/components/ValidationSection.d.ts.map +1 -0
  25. package/build/@types/cim/components/ClusterDeployment/constants.d.ts +2 -0
  26. package/build/@types/cim/components/ClusterDeployment/constants.d.ts.map +1 -1
  27. package/build/@types/cim/components/ClusterDeployment/index.d.ts +1 -2
  28. package/build/@types/cim/components/ClusterDeployment/index.d.ts.map +1 -1
  29. package/build/@types/cim/components/ClusterDeployment/networkConfigurationValidation.d.ts +1 -11
  30. package/build/@types/cim/components/ClusterDeployment/networkConfigurationValidation.d.ts.map +1 -1
  31. package/build/@types/cim/components/ClusterDeployment/types.d.ts +7 -9
  32. package/build/@types/cim/components/ClusterDeployment/types.d.ts.map +1 -1
  33. package/build/@types/cim/components/ClusterDeployment/use-networking-formik.d.ts +8 -2
  34. package/build/@types/cim/components/ClusterDeployment/use-networking-formik.d.ts.map +1 -1
  35. package/build/@types/cim/components/Hypershift/DetailsPage/HypershiftKubeconfigDownload.d.ts.map +1 -1
  36. package/build/@types/cim/components/Hypershift/types.d.ts +6 -3
  37. package/build/@types/cim/components/Hypershift/types.d.ts.map +1 -1
  38. package/build/@types/cim/components/InfraEnv/InfraEnvAgentTable.d.ts.map +1 -1
  39. package/build/@types/cim/components/helpers/agents.d.ts +3 -0
  40. package/build/@types/cim/components/helpers/agents.d.ts.map +1 -1
  41. package/build/@types/cim/components/helpers/toAssisted.d.ts.map +1 -1
  42. package/build/@types/cim/components/modals/EditAgentModal.d.ts.map +1 -1
  43. package/build/@types/cim/components/modals/ScaleUpModal.d.ts +3 -0
  44. package/build/@types/cim/components/modals/ScaleUpModal.d.ts.map +1 -1
  45. package/build/@types/common/components/clusterWizard/networkingSteps/AvailableSubnetsControl.d.ts.map +1 -1
  46. package/build/@types/common/components/hosts/EditHostForm.d.ts.map +1 -1
  47. package/build/@types/common/components/ui/formik/validationSchemas.d.ts.map +1 -1
  48. package/build/cjs/cim/components/ClusterDeployment/ACMClusterDeploymentDetailsStep.js +9 -7
  49. package/build/cjs/cim/components/ClusterDeployment/ACMClusterDeploymentDetailsStep.js.map +1 -1
  50. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentDetailsForm.js +26 -1
  51. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentDetailsForm.js.map +1 -1
  52. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentDetailsStep.js +13 -29
  53. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentDetailsStep.js.map +1 -1
  54. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentHostDiscoveryTable.js +2 -12
  55. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentHostDiscoveryTable.js.map +1 -1
  56. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentHostSelectionStep.js +50 -26
  57. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentHostSelectionStep.js.map +1 -1
  58. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentHostsDiscovery.js +3 -3
  59. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentHostsDiscovery.js.map +1 -1
  60. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentHostsDiscoveryStep.js +39 -21
  61. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentHostsDiscoveryStep.js.map +1 -1
  62. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentNetworkingStep.js +58 -27
  63. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentNetworkingStep.js.map +1 -1
  64. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentReviewStep.js +24 -24
  65. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentReviewStep.js.map +1 -1
  66. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentWizard.js +26 -42
  67. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentWizard.js.map +1 -1
  68. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentWizardContext.js +12 -8
  69. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentWizardContext.js.map +1 -1
  70. package/build/cjs/cim/components/ClusterDeployment/NetworkConfiguration.js +5 -5
  71. package/build/cjs/cim/components/ClusterDeployment/NetworkConfiguration.js.map +1 -1
  72. package/build/cjs/cim/components/ClusterDeployment/components/ClusterDeploymentHostsSelectionAdvanced.js +50 -0
  73. package/build/cjs/cim/components/ClusterDeployment/components/ClusterDeploymentHostsSelectionAdvanced.js.map +1 -0
  74. package/build/cjs/cim/components/ClusterDeployment/components/ClusterScaleUpAutoHostsSelection.js +24 -0
  75. package/build/cjs/cim/components/ClusterDeployment/components/ClusterScaleUpAutoHostsSelection.js.map +1 -0
  76. package/build/cjs/cim/components/ClusterDeployment/components/ValidationSection.js +17 -0
  77. package/build/cjs/cim/components/ClusterDeployment/components/ValidationSection.js.map +1 -0
  78. package/build/cjs/cim/components/ClusterDeployment/constants.js +2 -0
  79. package/build/cjs/cim/components/ClusterDeployment/constants.js.map +1 -1
  80. package/build/cjs/cim/components/ClusterDeployment/index.js +2 -5
  81. package/build/cjs/cim/components/ClusterDeployment/index.js.map +1 -1
  82. package/build/cjs/cim/components/ClusterDeployment/networkConfigurationValidation.js +1 -14
  83. package/build/cjs/cim/components/ClusterDeployment/networkConfigurationValidation.js.map +1 -1
  84. package/build/cjs/cim/components/ClusterDeployment/use-networking-formik.js +2 -2
  85. package/build/cjs/cim/components/ClusterDeployment/use-networking-formik.js.map +1 -1
  86. package/build/cjs/cim/components/Hypershift/DetailsPage/HypershiftKubeconfigDownload.js +6 -4
  87. package/build/cjs/cim/components/Hypershift/DetailsPage/HypershiftKubeconfigDownload.js.map +1 -1
  88. package/build/cjs/cim/components/InfraEnv/InfraEnvAgentTable.js +2 -12
  89. package/build/cjs/cim/components/InfraEnv/InfraEnvAgentTable.js.map +1 -1
  90. package/build/cjs/cim/components/helpers/agents.js +19 -1
  91. package/build/cjs/cim/components/helpers/agents.js.map +1 -1
  92. package/build/cjs/cim/components/helpers/toAssisted.js +25 -23
  93. package/build/cjs/cim/components/helpers/toAssisted.js.map +1 -1
  94. package/build/cjs/cim/components/modals/EditAgentModal.js +2 -2
  95. package/build/cjs/cim/components/modals/EditAgentModal.js.map +1 -1
  96. package/build/cjs/cim/components/modals/ScaleUpModal.js +3 -2
  97. package/build/cjs/cim/components/modals/ScaleUpModal.js.map +1 -1
  98. package/build/cjs/common/components/clusterWizard/networkingSteps/AvailableSubnetsControl.js +14 -18
  99. package/build/cjs/common/components/clusterWizard/networkingSteps/AvailableSubnetsControl.js.map +1 -1
  100. package/build/cjs/common/components/clusterWizard/networkingSteps/VirtualIPControlGroup.js +4 -4
  101. package/build/cjs/common/components/clusterWizard/networkingSteps/VirtualIPControlGroup.js.map +1 -1
  102. package/build/cjs/common/components/hosts/EditHostForm.js +3 -3
  103. package/build/cjs/common/components/hosts/EditHostForm.js.map +1 -1
  104. package/build/cjs/common/components/ui/formik/validationSchemas.js +18 -15
  105. package/build/cjs/common/components/ui/formik/validationSchemas.js.map +1 -1
  106. package/build/cjs/common/config/constants.js +1 -1
  107. package/build/cjs/common/config/constants.js.map +1 -1
  108. package/lib/cim/components/ClusterDeployment/ACMClusterDeploymentDetailsStep.tsx +11 -9
  109. package/lib/cim/components/ClusterDeployment/ClusterDeploymentDetailsForm.tsx +63 -3
  110. package/lib/cim/components/ClusterDeployment/ClusterDeploymentDetailsStep.tsx +25 -53
  111. package/lib/cim/components/ClusterDeployment/ClusterDeploymentHostDiscoveryTable.tsx +7 -16
  112. package/lib/cim/components/ClusterDeployment/ClusterDeploymentHostSelectionStep.tsx +102 -59
  113. package/lib/cim/components/ClusterDeployment/ClusterDeploymentHostsDiscovery.tsx +16 -10
  114. package/lib/cim/components/ClusterDeployment/ClusterDeploymentHostsDiscoveryStep.tsx +84 -48
  115. package/lib/cim/components/ClusterDeployment/ClusterDeploymentNetworkingStep.tsx +106 -54
  116. package/lib/cim/components/ClusterDeployment/ClusterDeploymentReviewStep.tsx +96 -85
  117. package/lib/cim/components/ClusterDeployment/ClusterDeploymentWizard.tsx +109 -119
  118. package/lib/cim/components/ClusterDeployment/ClusterDeploymentWizardContext.tsx +27 -14
  119. package/lib/cim/components/ClusterDeployment/NetworkConfiguration.tsx +5 -5
  120. package/lib/cim/components/ClusterDeployment/components/ClusterDeploymentHostsSelectionAdvanced.tsx +107 -0
  121. package/lib/cim/components/ClusterDeployment/components/ClusterScaleUpAutoHostsSelection.tsx +49 -0
  122. package/lib/cim/components/ClusterDeployment/components/ValidationSection.tsx +41 -0
  123. package/lib/cim/components/ClusterDeployment/constants.ts +3 -1
  124. package/lib/cim/components/ClusterDeployment/index.ts +1 -3
  125. package/lib/cim/components/ClusterDeployment/networkConfigurationValidation.ts +1 -26
  126. package/lib/cim/components/ClusterDeployment/types.ts +7 -10
  127. package/lib/cim/components/ClusterDeployment/use-networking-formik.ts +3 -3
  128. package/lib/cim/components/Hypershift/DetailsPage/HypershiftKubeconfigDownload.tsx +4 -2
  129. package/lib/cim/components/Hypershift/types.ts +6 -3
  130. package/lib/cim/components/InfraEnv/InfraEnvAgentTable.tsx +7 -16
  131. package/lib/cim/components/helpers/agents.ts +30 -1
  132. package/lib/cim/components/helpers/toAssisted.ts +12 -8
  133. package/lib/cim/components/modals/EditAgentModal.tsx +2 -1
  134. package/lib/cim/components/modals/ScaleUpModal.tsx +12 -2
  135. package/lib/common/components/clusterWizard/networkingSteps/AvailableSubnetsControl.tsx +50 -61
  136. package/lib/common/components/clusterWizard/networkingSteps/VirtualIPControlGroup.tsx +4 -4
  137. package/lib/common/components/hosts/EditHostForm.tsx +16 -6
  138. package/lib/common/components/ui/formik/validationSchemas.ts +13 -10
  139. package/lib/common/config/constants.ts +1 -1
  140. package/package.json +4 -3
  141. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentCreateProgress.d.ts +0 -10
  142. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentCreateProgress.d.ts.map +0 -1
  143. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentWizardFooter.d.ts +0 -13
  144. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentWizardFooter.d.ts.map +0 -1
  145. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentWizardNavigation.d.ts +0 -4
  146. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentWizardNavigation.d.ts.map +0 -1
  147. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentWizardStep.d.ts +0 -7
  148. package/build/@types/cim/components/ClusterDeployment/ClusterDeploymentWizardStep.d.ts.map +0 -1
  149. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentCreateProgress.js +0 -31
  150. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentCreateProgress.js.map +0 -1
  151. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentWizardFooter.js +0 -50
  152. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentWizardFooter.js.map +0 -1
  153. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentWizardNavigation.js +0 -35
  154. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentWizardNavigation.js.map +0 -1
  155. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentWizardStep.js +0 -9
  156. package/build/cjs/cim/components/ClusterDeployment/ClusterDeploymentWizardStep.js.map +0 -1
  157. package/lib/cim/components/ClusterDeployment/ClusterDeploymentCreateProgress.tsx +0 -79
  158. package/lib/cim/components/ClusterDeployment/ClusterDeploymentWizardFooter.tsx +0 -128
  159. package/lib/cim/components/ClusterDeployment/ClusterDeploymentWizardNavigation.tsx +0 -81
  160. package/lib/cim/components/ClusterDeployment/ClusterDeploymentWizardStep.tsx +0 -13
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Formik } from 'formik';
3
3
  import { Lazy } from 'yup';
4
- import { Grid, GridItem } from '@patternfly/react-core';
4
+ import { Grid, GridItem, useWizardContext } from '@patternfly/react-core';
5
5
 
6
6
  import {
7
7
  useAlerts,
@@ -15,9 +15,6 @@ import {
15
15
  } from '../../../common';
16
16
 
17
17
  import { ClusterDeploymentDetailsStepProps, ClusterDeploymentDetailsValues } from './types';
18
- import ClusterDeploymentWizardFooter from './ClusterDeploymentWizardFooter';
19
- import ClusterDeploymentWizardContext from './ClusterDeploymentWizardContext';
20
- import ClusterDeploymentWizardStep from './ClusterDeploymentWizardStep';
21
18
  import { getAICluster, getNetworkType, getOCPVersions } from '../helpers';
22
19
  import {
23
20
  AgentClusterInstallK8sResource,
@@ -25,8 +22,10 @@ import {
25
22
  ClusterDeploymentK8sResource,
26
23
  InfraEnvK8sResource,
27
24
  } from '../../types';
28
- import ClusterDeploymentDetailsForm from './ClusterDeploymentDetailsForm';
29
- import { isCIMFlow, getGridSpans } from './helpers';
25
+ import ClusterDeploymentDetailsForm, {
26
+ ClusterDeploymentDetailsFormWrapper,
27
+ } from './ClusterDeploymentDetailsForm';
28
+ import { getGridSpans } from './helpers';
30
29
  import { useTranslation } from '../../../common/hooks/use-translation-wrapper';
31
30
 
32
31
  type UseDetailsFormikArgs = {
@@ -108,15 +107,16 @@ const ClusterDeploymentDetailsStep: React.FC<ClusterDeploymentDetailsStepProps>
108
107
  agents,
109
108
  usedClusterNames,
110
109
  onSaveDetails,
111
- onClose,
112
110
  isPreviewOpen,
113
111
  infraEnv,
114
112
  isNutanix,
115
113
  }) => {
116
- const { addAlert } = useAlerts();
117
- const { setCurrentStepId } = React.useContext(ClusterDeploymentWizardContext);
118
114
  const { t } = useTranslation();
115
+ const { addAlert } = useAlerts();
116
+ const { goToNextStep } = useWizardContext();
117
+
119
118
  const ocpVersions = getOCPVersions(clusterImages, isNutanix);
119
+ const gridSpans = getGridSpans(isPreviewOpen);
120
120
 
121
121
  const [initialValues, validationSchema] = useDetailsFormik({
122
122
  clusterDeployment,
@@ -126,15 +126,11 @@ const ClusterDeploymentDetailsStep: React.FC<ClusterDeploymentDetailsStepProps>
126
126
  usedClusterNames,
127
127
  infraEnv,
128
128
  });
129
- const next = () =>
130
- isCIMFlow(clusterDeployment)
131
- ? setCurrentStepId('hosts-selection')
132
- : setCurrentStepId('hosts-discovery');
133
129
 
134
130
  const handleSubmit = async (values: ClusterDeploymentDetailsValues) => {
135
131
  try {
136
132
  await onSaveDetails(values);
137
- next();
133
+ await goToNextStep();
138
134
  } catch (error) {
139
135
  addAlert({
140
136
  title: t('ai:Failed to save ClusterDeployment'),
@@ -149,45 +145,21 @@ const ClusterDeploymentDetailsStep: React.FC<ClusterDeploymentDetailsStepProps>
149
145
  validate={getRichTextValidation(validationSchema)}
150
146
  onSubmit={handleSubmit}
151
147
  >
152
- {({ submitForm, isSubmitting, isValid, isValidating, dirty }) => {
153
- const handleOnNext = () => {
154
- if (dirty) {
155
- void submitForm();
156
- } else {
157
- next();
158
- }
159
- };
160
-
161
- const footer = (
162
- <ClusterDeploymentWizardFooter
163
- agentClusterInstall={agentClusterInstall}
164
- isSubmitting={isSubmitting}
165
- isNextDisabled={!isValid || isValidating || isSubmitting}
166
- onNext={handleOnNext}
167
- onCancel={onClose}
168
- />
169
- );
170
-
171
- const gridSpans = getGridSpans(isPreviewOpen);
172
-
173
- return (
174
- <ClusterDeploymentWizardStep footer={footer}>
175
- <Grid hasGutter>
176
- <GridItem>
177
- <ClusterWizardStepHeader>Cluster Details</ClusterWizardStepHeader>
178
- </GridItem>
179
- <GridItem {...gridSpans}>
180
- <ClusterDeploymentDetailsForm
181
- agentClusterInstall={agentClusterInstall}
182
- clusterDeployment={clusterDeployment}
183
- clusterImages={clusterImages}
184
- isNutanix={isNutanix}
185
- />
186
- </GridItem>
187
- </Grid>
188
- </ClusterDeploymentWizardStep>
189
- );
190
- }}
148
+ <Grid hasGutter>
149
+ <GridItem>
150
+ <ClusterWizardStepHeader>Cluster Details</ClusterWizardStepHeader>
151
+ </GridItem>
152
+ <GridItem {...gridSpans}>
153
+ <ClusterDeploymentDetailsFormWrapper>
154
+ <ClusterDeploymentDetailsForm
155
+ agentClusterInstall={agentClusterInstall}
156
+ clusterDeployment={clusterDeployment}
157
+ clusterImages={clusterImages}
158
+ isNutanix={isNutanix}
159
+ />
160
+ </ClusterDeploymentDetailsFormWrapper>
161
+ </GridItem>
162
+ </Grid>
191
163
  </Formik>
192
164
  );
193
165
  };
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import noop from 'lodash-es/noop.js';
3
2
  import { Stack, StackItem } from '@patternfly/react-core';
4
3
  import { Host } from '@openshift-assisted/types/assisted-installer-service';
5
4
  import {
@@ -28,13 +27,13 @@ import {
28
27
  } from '../../../common';
29
28
  import { ClusterDeploymentHostDiscoveryTableProps } from '../ClusterDeployment/types';
30
29
  import MassApproveAgentModal from '../modals/MassApproveAgentModal';
31
- import { MassChangeHostnameModalProps } from '../../../common/components/hosts/MassChangeHostnameModal';
32
30
  import MassApproveAction from '../modals/MassApproveAction';
33
31
  import { usePagination } from '../../../common/components/hosts/usePagination';
34
32
  import { useTranslation } from '../../../common/hooks/use-translation-wrapper';
35
33
  import { ExpandComponent } from '../Agent/AgentsSelectionTable';
36
34
  import { HostsTableDetailContextProvider } from '../../../common/components/hosts/HostsTableDetailContext';
37
35
  import { agentStatus, bmhStatus } from '../helpers/agentStatus';
36
+ import { onAgentChangeHostname } from '../helpers';
38
37
 
39
38
  const ClusterDeploymentHostDiscoveryTable: React.FC<ClusterDeploymentHostDiscoveryTableProps> = ({
40
39
  agents,
@@ -126,19 +125,6 @@ const ClusterDeploymentHostDiscoveryTable: React.FC<ClusterDeploymentHostDiscove
126
125
  />,
127
126
  ];
128
127
 
129
- const onAgentChangeHostname: MassChangeHostnameModalProps['onChangeHostname'] = async (
130
- host,
131
- hostname,
132
- ) => {
133
- const agent = agents.find((a) => a.metadata?.uid === host.id);
134
- if (agent) {
135
- return onChangeHostname(agent, hostname);
136
- } else {
137
- const bmh = bareMetalHosts.find((bmh) => bmh.metadata?.uid === host.id);
138
- return bmh ? onChangeBMHHostname(bmh, hostname) : noop;
139
- }
140
- };
141
-
142
128
  const paginationProps = usePagination(hosts.length);
143
129
  const itemIDs = hosts.map((h) => h.id);
144
130
 
@@ -185,7 +171,12 @@ const ClusterDeploymentHostDiscoveryTable: React.FC<ClusterDeploymentHostDiscove
185
171
  isOpen={isMassChangeHostOpen}
186
172
  hosts={hosts}
187
173
  selectedHostIDs={selectedHostIDs}
188
- onChangeHostname={onAgentChangeHostname}
174
+ onChangeHostname={onAgentChangeHostname(
175
+ agents,
176
+ bareMetalHosts,
177
+ onChangeHostname,
178
+ onChangeBMHHostname,
179
+ )}
189
180
  onClose={() => setMassChangeHostOpen(false)}
190
181
  canChangeHostname={canChangeHostname(agents, agentStatuses, bareMetalHosts, t)}
191
182
  />
@@ -1,16 +1,21 @@
1
1
  import React from 'react';
2
2
  import * as Yup from 'yup';
3
3
  import { Formik, FormikConfig, useFormikContext } from 'formik';
4
- import { Alert, AlertVariant, Grid, GridItem } from '@patternfly/react-core';
5
- import { ClusterWizardStepHeader, useAlerts } from '../../../common';
4
+ import {
5
+ Alert,
6
+ AlertVariant,
7
+ Grid,
8
+ GridItem,
9
+ useWizardContext,
10
+ useWizardFooter,
11
+ WizardFooter,
12
+ } from '@patternfly/react-core';
13
+ import { Alerts, ClusterWizardStepHeader, useAlerts } from '../../../common';
6
14
  import {
7
15
  AgentClusterInstallK8sResource,
8
16
  AgentK8sResource,
9
17
  ClusterDeploymentK8sResource,
10
18
  } from '../../types';
11
- import ClusterDeploymentWizardContext from './ClusterDeploymentWizardContext';
12
- import ClusterDeploymentWizardFooter from './ClusterDeploymentWizardFooter';
13
- import ClusterDeploymentWizardStep from './ClusterDeploymentWizardStep';
14
19
  import ClusterDeploymentHostsSelection from './ClusterDeploymentHostsSelection';
15
20
  import {
16
21
  ClusterDeploymentHostSelectionStepProps,
@@ -25,6 +30,8 @@ import {
25
30
  import { canNextFromHostSelectionStep } from './wizardTransition';
26
31
  import { useTranslation } from '../../../common/hooks/use-translation-wrapper';
27
32
  import { TFunction } from 'i18next';
33
+ import { ValidationSection } from './components/ValidationSection';
34
+ import { ClusterDeploymentWizardContext } from './ClusterDeploymentWizardContext';
28
35
 
29
36
  const getInitialValues = ({
30
37
  agents,
@@ -138,14 +145,15 @@ type HostSelectionFormProps = Omit<ClusterDeploymentHostSelectionStepProps, 'onS
138
145
  const HostSelectionForm: React.FC<HostSelectionFormProps> = ({
139
146
  agents,
140
147
  agentClusterInstall,
141
- onClose,
142
148
  clusterDeployment,
143
149
  aiConfigMap,
144
150
  onEditRole: onEditRoleInit,
145
151
  onSetInstallationDiskId,
146
152
  isNutanix,
147
153
  }) => {
148
- const { setCurrentStepId } = React.useContext(ClusterDeploymentWizardContext);
154
+ const { activeStep, goToNextStep, goToPrevStep, close } = useWizardContext();
155
+ const { syncError } = React.useContext(ClusterDeploymentWizardContext);
156
+ const { alerts } = useAlerts();
149
157
  const [showClusterErrors, setShowClusterErrors] = React.useState(false);
150
158
  const {
151
159
  values,
@@ -186,7 +194,7 @@ const HostSelectionForm: React.FC<HostSelectionFormProps> = ({
186
194
  setShowClusterErrors(false);
187
195
  }, []);
188
196
 
189
- const onNext = async () => {
197
+ const onNext = React.useCallback(async () => {
190
198
  if (!showFormErrors) {
191
199
  setShowFormErrors(true);
192
200
  const errors = await validateForm();
@@ -202,7 +210,7 @@ const HostSelectionForm: React.FC<HostSelectionFormProps> = ({
202
210
  }
203
211
  void submitForm();
204
212
  setNextRequested(true);
205
- };
213
+ }, [setTouched, showFormErrors, submitForm, validateForm]);
206
214
 
207
215
  React.useEffect(() => {
208
216
  if (nextRequested && !isSubmitting) {
@@ -223,71 +231,106 @@ const HostSelectionForm: React.FC<HostSelectionFormProps> = ({
223
231
  ) {
224
232
  setShowClusterErrors(true);
225
233
  if (canNextFromHostSelectionStep(agentClusterInstall, selectedAgents)) {
226
- setCurrentStepId('networking');
234
+ void goToNextStep();
227
235
  }
228
236
  }
229
237
  }
230
- }, [nextRequested, selectedAgents, agentClusterInstall, setCurrentStepId, isSubmitting, t]);
231
-
232
- let submittingText: string | undefined = undefined;
238
+ }, [nextRequested, selectedAgents, agentClusterInstall, isSubmitting, t, goToNextStep]);
233
239
 
234
- if (isSubmitting) {
235
- submittingText = t('ai:Saving changes...');
236
- } else if (nextRequested && !showClusterErrors) {
237
- submittingText = t('ai:Binding hosts...');
238
- }
240
+ const submittingText = React.useMemo(() => {
241
+ if (isSubmitting) {
242
+ return t('ai:Saving changes...');
243
+ } else if (nextRequested && !showClusterErrors) {
244
+ return t('ai:Binding hosts...');
245
+ }
246
+ return undefined;
247
+ }, [isSubmitting, nextRequested, showClusterErrors, t]);
239
248
 
240
- const onSyncError = React.useCallback(() => setNextRequested(false), []);
249
+ React.useEffect(() => {
250
+ if (syncError) {
251
+ setNextRequested(false);
252
+ }
253
+ }, [syncError]);
241
254
 
242
- const footer = (
243
- <ClusterDeploymentWizardFooter
244
- agentClusterInstall={agentClusterInstall}
245
- agents={selectedAgents}
246
- isSubmitting={!!submittingText}
247
- submittingText={submittingText}
248
- isNextDisabled={
249
- nextRequested || isSubmitting || (showFormErrors ? !isValid || isValidating : false)
250
- }
251
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
252
- onNext={onNext}
253
- onBack={() => setCurrentStepId('cluster-details')}
254
- onCancel={onClose}
255
- showClusterErrors={showClusterErrors}
256
- onSyncError={onSyncError}
257
- >
258
- {showFormErrors && errors.selectedHostIds && touched.selectedHostIds && (
259
- <Alert
260
- variant={AlertVariant.danger}
261
- title={t('ai:Provided cluster configuration is not valid')}
262
- isInline
263
- >
264
- {errors.selectedHostIds}
255
+ const errorsSection = (
256
+ <ValidationSection currentStepId={'cluster-details'} hosts={[]}>
257
+ {syncError && (
258
+ <Alert variant={AlertVariant.danger} title={t('ai:An error occured')} isInline>
259
+ {syncError}
265
260
  </Alert>
266
261
  )}
267
- </ClusterDeploymentWizardFooter>
262
+ </ValidationSection>
268
263
  );
269
264
 
265
+ const footer = React.useMemo(
266
+ () => (
267
+ <WizardFooter
268
+ activeStep={activeStep}
269
+ onNext={onNext}
270
+ isNextDisabled={
271
+ nextRequested || isSubmitting || (showFormErrors ? !isValid || isValidating : false) // ||
272
+ // !!syncError
273
+ }
274
+ nextButtonText={submittingText || t('ai:Next')}
275
+ nextButtonProps={{ isLoading: !!submittingText }}
276
+ onBack={goToPrevStep}
277
+ onClose={close}
278
+ />
279
+ ),
280
+ [
281
+ activeStep,
282
+ onNext,
283
+ nextRequested,
284
+ isSubmitting,
285
+ showFormErrors,
286
+ isValid,
287
+ isValidating,
288
+ submittingText,
289
+ t,
290
+ goToPrevStep,
291
+ close,
292
+ ],
293
+ );
294
+
295
+ useWizardFooter(footer);
296
+
270
297
  return (
271
- <ClusterDeploymentWizardStep footer={footer}>
272
- <Grid hasGutter>
298
+ <Grid hasGutter>
299
+ <GridItem>
300
+ <ClusterWizardStepHeader>{t('ai:Cluster hosts')}</ClusterWizardStepHeader>
301
+ </GridItem>
302
+ <GridItem>
303
+ <ClusterDeploymentHostsSelection
304
+ agentClusterInstall={agentClusterInstall}
305
+ agents={agents}
306
+ clusterDeployment={clusterDeployment}
307
+ aiConfigMap={aiConfigMap}
308
+ onEditRole={onEditRole}
309
+ onSetInstallationDiskId={onSetInstallationDiskId}
310
+ onAutoSelectChange={onAutoSelectChange}
311
+ onHostSelect={onHostSelect}
312
+ isNutanix={isNutanix}
313
+ />
314
+ </GridItem>
315
+ {(showClusterErrors || showFormErrors) && !!alerts.length && (
273
316
  <GridItem>
274
- <ClusterWizardStepHeader>{t('ai:Cluster hosts')}</ClusterWizardStepHeader>
317
+ <Alerts />
275
318
  </GridItem>
319
+ )}
320
+
321
+ {syncError && <GridItem>{errorsSection}</GridItem>}
322
+ {showFormErrors && errors.selectedHostIds && touched.selectedHostIds && (
276
323
  <GridItem>
277
- <ClusterDeploymentHostsSelection
278
- agentClusterInstall={agentClusterInstall}
279
- agents={agents}
280
- clusterDeployment={clusterDeployment}
281
- aiConfigMap={aiConfigMap}
282
- onEditRole={onEditRole}
283
- onSetInstallationDiskId={onSetInstallationDiskId}
284
- onAutoSelectChange={onAutoSelectChange}
285
- onHostSelect={onHostSelect}
286
- isNutanix={isNutanix}
287
- />
324
+ <Alert
325
+ variant={AlertVariant.danger}
326
+ title={t('ai:Provided cluster configuration is not valid')}
327
+ isInline
328
+ >
329
+ {errors.selectedHostIds}
330
+ </Alert>
288
331
  </GridItem>
289
- </Grid>
290
- </ClusterDeploymentWizardStep>
332
+ )}
333
+ </Grid>
291
334
  );
292
335
  };
293
336
 
@@ -15,7 +15,7 @@ import {
15
15
  HostsNotShowingLink,
16
16
  VMRebootConfigurationInfo,
17
17
  } from '../../../common';
18
- import { getIsSNOCluster } from '../helpers';
18
+ import { getIsSNOCluster, onAgentChangeHostname } from '../helpers';
19
19
  import MinimalHWRequirements from '../Agent/MinimalHWRequirements';
20
20
  import { ClusterDeploymentHostsDiscoveryProps } from './types';
21
21
  import { EditBMHModal, EditAgentModal } from '../modals';
@@ -57,7 +57,7 @@ const ClusterDeploymentHostsDiscovery: React.FC<ClusterDeploymentHostsDiscoveryP
57
57
  infraEnv,
58
58
  infraNMStates,
59
59
  usedHostnames,
60
- onSaveAgent,
60
+ onChangeHostname,
61
61
  onEditRole,
62
62
  onSetInstallationDiskId,
63
63
  onSaveBMH,
@@ -119,7 +119,7 @@ const ClusterDeploymentHostsDiscovery: React.FC<ClusterDeploymentHostsDiscoveryP
119
119
  onEditRole={onEditRole}
120
120
  onSetInstallationDiskId={onSetInstallationDiskId}
121
121
  onEditBMH={setEditBMH}
122
- onChangeHostname={onSaveAgent}
122
+ onChangeHostname={onChangeHostname}
123
123
  onChangeBMHHostname={onChangeBMHHostname}
124
124
  onApprove={onApproveAgent}
125
125
  width={contentRect.bounds?.width}
@@ -138,13 +138,19 @@ const ClusterDeploymentHostsDiscovery: React.FC<ClusterDeploymentHostsDiscoveryP
138
138
  fetchSecret={fetchSecret}
139
139
  usedHostnames={usedHostnames || []}
140
140
  />
141
- <EditAgentModal
142
- isOpen={!!editAgent}
143
- onClose={() => setEditAgent(undefined)}
144
- usedHostnames={usedHostnames}
145
- agent={editAgent}
146
- onSave={onSaveAgent}
147
- />
141
+ {editAgent && (
142
+ <EditAgentModal
143
+ onClose={() => setEditAgent(undefined)}
144
+ usedHostnames={usedHostnames}
145
+ agent={editAgent}
146
+ onSave={onAgentChangeHostname(
147
+ agents,
148
+ bareMetalHosts,
149
+ onChangeHostname,
150
+ onChangeBMHHostname,
151
+ )}
152
+ />
153
+ )}
148
154
  </GridItem>
149
155
  <DiscoveryTroubleshootingModal
150
156
  isOpen={isDiscoveryHintModalOpen}
@@ -1,28 +1,37 @@
1
1
  import React from 'react';
2
2
  import uniq from 'lodash-es/uniq.js';
3
- import { Grid, GridItem, Alert, AlertVariant, List, ListItem } from '@patternfly/react-core';
3
+ import {
4
+ Grid,
5
+ GridItem,
6
+ Alert,
7
+ AlertVariant,
8
+ List,
9
+ ListItem,
10
+ useWizardFooter,
11
+ WizardFooter,
12
+ useWizardContext,
13
+ } from '@patternfly/react-core';
4
14
 
5
- import { ClusterWizardStepHeader } from '../../../common';
6
- import ClusterDeploymentWizardContext from './ClusterDeploymentWizardContext';
7
- import ClusterDeploymentWizardFooter from './ClusterDeploymentWizardFooter';
8
- import ClusterDeploymentWizardStep from './ClusterDeploymentWizardStep';
15
+ import { Alerts, ClusterWizardStepHeader } from '../../../common';
9
16
  import { ClusterDeploymentHostsDiscoveryStepProps } from './types';
10
17
  import ClusterDeploymentHostsDiscovery from './ClusterDeploymentHostsDiscovery';
11
18
  import { getAgentsHostsNames, isAgentOfInfraEnv } from './helpers';
12
19
  import { getIsSNOCluster, getWizardStepAgentStatus } from '../helpers';
13
20
  import { canNextFromHostDiscoveryStep } from './wizardTransition';
14
21
  import { useTranslation } from '../../../common/hooks/use-translation-wrapper';
22
+ import { ValidationSection } from './components/ValidationSection';
23
+ import { ClusterDeploymentWizardContext } from './ClusterDeploymentWizardContext';
15
24
 
16
- const ClusterDeploymentHostsDiscoveryStep: React.FC<ClusterDeploymentHostsDiscoveryStepProps> = ({
25
+ const ClusterDeploymentHostsDiscoveryStep = ({
17
26
  agentClusterInstall,
18
27
  agents: allAgents,
19
28
  infraEnv,
20
29
  onSaveHostsDiscovery,
21
- onClose,
22
30
  ...rest
23
- }) => {
31
+ }: ClusterDeploymentHostsDiscoveryStepProps) => {
24
32
  const { t } = useTranslation();
25
- const { setCurrentStepId } = React.useContext(ClusterDeploymentWizardContext);
33
+ const { syncError } = React.useContext(ClusterDeploymentWizardContext);
34
+ const { activeStep, goToNextStep, goToPrevStep, close } = useWizardContext();
26
35
  const [showClusterErrors, setShowClusterErrors] = React.useState(false);
27
36
  const [nextRequested, setNextRequested] = React.useState(false);
28
37
  const [showFormErrors, setShowFormErrors] = React.useState(false);
@@ -61,7 +70,7 @@ const ClusterDeploymentHostsDiscoveryStep: React.FC<ClusterDeploymentHostsDiscov
61
70
  errors.push(t('ai:Some hosts are not ready.'));
62
71
  }
63
72
 
64
- const onNext = async () => {
73
+ const onNext = React.useCallback(async () => {
65
74
  if (!showFormErrors) {
66
75
  setShowFormErrors(true);
67
76
  if (errors.length) {
@@ -70,7 +79,7 @@ const ClusterDeploymentHostsDiscoveryStep: React.FC<ClusterDeploymentHostsDiscov
70
79
  }
71
80
  await onSaveHostsDiscovery();
72
81
  setNextRequested(true);
73
- };
82
+ }, [errors.length, onSaveHostsDiscovery, showFormErrors]);
74
83
 
75
84
  React.useEffect(() => {
76
85
  setNextRequested(false);
@@ -86,31 +95,68 @@ const ClusterDeploymentHostsDiscoveryStep: React.FC<ClusterDeploymentHostsDiscov
86
95
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
87
96
  // @ts-ignore
88
97
  if (canNextFromHostDiscoveryStep(agentClusterInstall, infraEnvAgents)) {
89
- setCurrentStepId('networking');
98
+ void goToNextStep();
90
99
  }
91
100
  }
92
101
  }
93
- }, [nextRequested, infraEnvAgents, agentClusterInstall, setCurrentStepId, agentsNotHealthy]);
102
+ }, [nextRequested, infraEnvAgents, agentClusterInstall, agentsNotHealthy, goToNextStep]);
94
103
 
95
- const submittingText =
96
- nextRequested && !showClusterErrors ? t('ai:Saving changes...') : undefined;
104
+ const submittingText = React.useMemo(
105
+ () => (nextRequested && !showClusterErrors ? t('ai:Saving changes...') : undefined),
106
+ [nextRequested, showClusterErrors, t],
107
+ );
108
+
109
+ React.useEffect(() => {
110
+ if (syncError) {
111
+ setNextRequested(false);
112
+ }
113
+ }, [syncError]);
97
114
 
98
- const onSyncError = React.useCallback(() => setNextRequested(false), []);
115
+ const footer = React.useMemo(
116
+ () => (
117
+ <WizardFooter
118
+ activeStep={activeStep}
119
+ onNext={onNext}
120
+ isNextDisabled={nextRequested || (showFormErrors ? !!errors.length : false)}
121
+ nextButtonText={submittingText || t('ai:Next')}
122
+ nextButtonProps={{ isLoading: !!submittingText }}
123
+ onBack={goToPrevStep}
124
+ onClose={close}
125
+ />
126
+ ),
127
+ [
128
+ activeStep,
129
+ close,
130
+ errors.length,
131
+ goToPrevStep,
132
+ nextRequested,
133
+ onNext,
134
+ showFormErrors,
135
+ submittingText,
136
+ t,
137
+ ],
138
+ );
139
+ useWizardFooter(footer);
99
140
 
100
- const footer = (
101
- <ClusterDeploymentWizardFooter
102
- agentClusterInstall={agentClusterInstall}
103
- agents={infraEnvAgents}
104
- isSubmitting={!!submittingText}
105
- submittingText={submittingText}
106
- isNextDisabled={nextRequested || (showFormErrors ? !!errors.length : false)}
107
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
108
- onNext={onNext}
109
- onBack={() => setCurrentStepId('cluster-details')}
110
- showClusterErrors={showClusterErrors}
111
- onSyncError={onSyncError}
112
- onCancel={onClose}
113
- >
141
+ return (
142
+ <Grid hasGutter>
143
+ <GridItem>
144
+ <ClusterWizardStepHeader>{t('ai:Cluster hosts')}</ClusterWizardStepHeader>
145
+ </GridItem>
146
+ <GridItem>
147
+ <ClusterDeploymentHostsDiscovery
148
+ agentClusterInstall={agentClusterInstall}
149
+ agents={infraEnvAgents}
150
+ infraEnv={infraEnv}
151
+ usedHostnames={usedHostnames}
152
+ {...rest}
153
+ />
154
+ </GridItem>
155
+ {showClusterErrors && !!errors.length && (
156
+ <GridItem>
157
+ <Alerts />
158
+ </GridItem>
159
+ )}
114
160
  {showFormErrors && !!errors.length && (
115
161
  <Alert
116
162
  variant={AlertVariant.danger}
@@ -124,27 +170,17 @@ const ClusterDeploymentHostsDiscoveryStep: React.FC<ClusterDeploymentHostsDiscov
124
170
  </List>
125
171
  </Alert>
126
172
  )}
127
- </ClusterDeploymentWizardFooter>
128
- );
129
173
 
130
- return (
131
- <ClusterDeploymentWizardStep footer={footer}>
132
- <Grid hasGutter>
174
+ {!!syncError && (
133
175
  <GridItem>
134
- <ClusterWizardStepHeader>{t('ai:Cluster hosts')}</ClusterWizardStepHeader>
176
+ <ValidationSection currentStepId={'hosts-selection'} hosts={[]}>
177
+ <Alert variant={AlertVariant.danger} title={t('ai:An error occured')} isInline>
178
+ {syncError}
179
+ </Alert>
180
+ </ValidationSection>
135
181
  </GridItem>
136
- <GridItem>
137
- <ClusterDeploymentHostsDiscovery
138
- agentClusterInstall={agentClusterInstall}
139
- agents={infraEnvAgents}
140
- infraEnv={infraEnv}
141
- usedHostnames={usedHostnames}
142
- {...rest}
143
- />
144
- </GridItem>
145
- </Grid>
146
- </ClusterDeploymentWizardStep>
182
+ )}
183
+ </Grid>
147
184
  );
148
185
  };
149
-
150
186
  export default ClusterDeploymentHostsDiscoveryStep;