@openshift-assisted/ui-lib 2.56.0 → 2.56.2

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 (130) hide show
  1. package/build/@types/common/config/constants.d.ts.map +1 -1
  2. package/build/@types/common/config/docs_links.d.ts +1 -0
  3. package/build/@types/common/config/docs_links.d.ts.map +1 -1
  4. package/build/@types/ocm/components/wizard/NewClusterWizard.d.ts.map +1 -1
  5. package/build/@types/ocm/components/wizard/clusterWizardContext/ClusterWizardContextProvider.d.ts +1 -1
  6. package/build/@types/ocm/components/wizard/clusterWizardContext/ClusterWizardContextProvider.d.ts.map +1 -1
  7. package/build/@types/ocm/components/wizard/clusterWizardContext/utils.d.ts +7 -0
  8. package/build/@types/ocm/components/wizard/clusterWizardContext/utils.d.ts.map +1 -0
  9. package/build/@types/ocm/components/wizard/steps/clusterDetails/ClusterDetailsForm.d.ts.map +1 -1
  10. package/build/@types/ocm/components/wizard/steps/disconnected/BasicStep.d.ts +2 -1
  11. package/build/@types/ocm/components/wizard/steps/disconnected/BasicStep.d.ts.map +1 -1
  12. package/build/@types/ocm/components/wizard/steps/disconnected/DisconnectedReviewStep.d.ts.map +1 -1
  13. package/build/@types/ocm/components/wizard/steps/disconnected/DisconnectedStaticIp.d.ts +4 -0
  14. package/build/@types/ocm/components/wizard/steps/disconnected/DisconnectedStaticIp.d.ts.map +1 -0
  15. package/build/@types/ocm/components/wizard/steps/disconnected/InstallDisconnectedSwitch.d.ts.map +1 -1
  16. package/build/@types/ocm/components/wizard/steps/disconnected/OptionalConfigurationsStep.d.ts.map +1 -1
  17. package/build/@types/ocm/components/wizard/steps/disconnected/index.d.ts +1 -0
  18. package/build/@types/ocm/components/wizard/steps/disconnected/index.d.ts.map +1 -1
  19. package/build/@types/ocm/components/wizard/steps/staticIp/StaticIp.d.ts +1 -1
  20. package/build/@types/ocm/components/wizard/steps/staticIp/StaticIp.d.ts.map +1 -1
  21. package/build/@types/ocm/components/wizard/steps/staticIp/commonValidationSchemas.d.ts +6 -1
  22. package/build/@types/ocm/components/wizard/steps/staticIp/commonValidationSchemas.d.ts.map +1 -1
  23. package/build/@types/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/FormViewNetworkWide.d.ts.map +1 -1
  24. package/build/@types/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/FormViewNetworkWideFields.d.ts.map +1 -1
  25. package/build/@types/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/disconnectedNetworkWideValidationSchema.d.ts +24 -0
  26. package/build/@types/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/disconnectedNetworkWideValidationSchema.d.ts.map +1 -0
  27. package/build/@types/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/formViewNetworkWideValidationSchema.d.ts +46 -1
  28. package/build/@types/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/formViewNetworkWideValidationSchema.d.ts.map +1 -1
  29. package/build/@types/ocm/components/wizard/steps/staticIp/components/StaticIpPage.d.ts.map +1 -1
  30. package/build/@types/ocm/components/wizard/steps/staticIp/data/dataTypes.d.ts +1 -1
  31. package/build/@types/ocm/components/wizard/steps/staticIp/data/dataTypes.d.ts.map +1 -1
  32. package/build/@types/ocm/components/wizard/steps/staticIp/data/disconnectedNetworkWide.d.ts +8 -0
  33. package/build/@types/ocm/components/wizard/steps/staticIp/data/disconnectedNetworkWide.d.ts.map +1 -0
  34. package/build/@types/ocm/components/wizard/steps/staticIp/data/formDataFromInfraEnvField.d.ts.map +1 -1
  35. package/build/@types/ocm/components/wizard/steps/staticIp/data/fromInfraEnv.d.ts +2 -0
  36. package/build/@types/ocm/components/wizard/steps/staticIp/data/fromInfraEnv.d.ts.map +1 -1
  37. package/build/@types/ocm/components/wizard/steps/staticIp/data/index.d.ts +1 -0
  38. package/build/@types/ocm/components/wizard/steps/staticIp/data/index.d.ts.map +1 -1
  39. package/build/@types/ocm/components/wizard/steps/staticIp/data/nmstateYaml.d.ts +1 -0
  40. package/build/@types/ocm/components/wizard/steps/staticIp/data/nmstateYaml.d.ts.map +1 -1
  41. package/build/@types/ocm/components/wizard/steps/staticIp/data/protocolVersion.d.ts +2 -2
  42. package/build/@types/ocm/components/wizard/steps/staticIp/data/protocolVersion.d.ts.map +1 -1
  43. package/build/@types/ocm/components/wizard/wizardComponents/ClusterWizardNavigation.d.ts +7 -0
  44. package/build/@types/ocm/components/wizard/wizardComponents/ClusterWizardNavigation.d.ts.map +1 -1
  45. package/build/cjs/common/components/clusterWizard/ClusterWizardStep.css +9 -0
  46. package/build/cjs/common/config/constants.js +1 -0
  47. package/build/cjs/common/config/constants.js.map +1 -1
  48. package/build/cjs/common/config/docs_links.js +3 -1
  49. package/build/cjs/common/config/docs_links.js.map +1 -1
  50. package/build/cjs/common/validationSchemas/addressValidation.js +2 -2
  51. package/build/cjs/common/validationSchemas/addressValidation.js.map +1 -1
  52. package/build/cjs/ocm/components/wizard/NewClusterWizard.js +4 -0
  53. package/build/cjs/ocm/components/wizard/NewClusterWizard.js.map +1 -1
  54. package/build/cjs/ocm/components/wizard/clusterWizardContext/ClusterWizardContextProvider.js +62 -62
  55. package/build/cjs/ocm/components/wizard/clusterWizardContext/ClusterWizardContextProvider.js.map +1 -1
  56. package/build/cjs/ocm/components/wizard/clusterWizardContext/utils.js +61 -0
  57. package/build/cjs/ocm/components/wizard/clusterWizardContext/utils.js.map +1 -0
  58. package/build/cjs/ocm/components/wizard/steps/clusterDetails/ClusterDetailsForm.js +1 -2
  59. package/build/cjs/ocm/components/wizard/steps/clusterDetails/ClusterDetailsForm.js.map +1 -1
  60. package/build/cjs/ocm/components/wizard/steps/disconnected/BasicStep.js +95 -7
  61. package/build/cjs/ocm/components/wizard/steps/disconnected/BasicStep.js.map +1 -1
  62. package/build/cjs/ocm/components/wizard/steps/disconnected/DisconnectedReviewStep.js +54 -44
  63. package/build/cjs/ocm/components/wizard/steps/disconnected/DisconnectedReviewStep.js.map +1 -1
  64. package/build/cjs/ocm/components/wizard/steps/disconnected/DisconnectedStaticIp.js +26 -0
  65. package/build/cjs/ocm/components/wizard/steps/disconnected/DisconnectedStaticIp.js.map +1 -0
  66. package/build/cjs/ocm/components/wizard/steps/disconnected/InstallDisconnectedSwitch.js +1 -1
  67. package/build/cjs/ocm/components/wizard/steps/disconnected/InstallDisconnectedSwitch.js.map +1 -1
  68. package/build/cjs/ocm/components/wizard/steps/disconnected/OptionalConfigurationsStep.js +87 -56
  69. package/build/cjs/ocm/components/wizard/steps/disconnected/OptionalConfigurationsStep.js.map +1 -1
  70. package/build/cjs/ocm/components/wizard/steps/disconnected/index.js +1 -0
  71. package/build/cjs/ocm/components/wizard/steps/disconnected/index.js.map +1 -1
  72. package/build/cjs/ocm/components/wizard/steps/staticIp/StaticIp.js.map +1 -1
  73. package/build/cjs/ocm/components/wizard/steps/staticIp/commonValidationSchemas.js +49 -12
  74. package/build/cjs/ocm/components/wizard/steps/staticIp/commonValidationSchemas.js.map +1 -1
  75. package/build/cjs/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/FormViewNetworkWide.js +13 -4
  76. package/build/cjs/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/FormViewNetworkWide.js.map +1 -1
  77. package/build/cjs/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/FormViewNetworkWideFields.js +96 -4
  78. package/build/cjs/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/FormViewNetworkWideFields.js.map +1 -1
  79. package/build/cjs/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/disconnectedNetworkWideValidationSchema.js +70 -0
  80. package/build/cjs/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/disconnectedNetworkWideValidationSchema.js.map +1 -0
  81. package/build/cjs/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/formViewNetworkWideValidationSchema.js +19 -9
  82. package/build/cjs/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/formViewNetworkWideValidationSchema.js.map +1 -1
  83. package/build/cjs/ocm/components/wizard/steps/staticIp/components/StaticIpPage.js +8 -2
  84. package/build/cjs/ocm/components/wizard/steps/staticIp/components/StaticIpPage.js.map +1 -1
  85. package/build/cjs/ocm/components/wizard/steps/staticIp/data/disconnectedNetworkWide.js +55 -0
  86. package/build/cjs/ocm/components/wizard/steps/staticIp/data/disconnectedNetworkWide.js.map +1 -0
  87. package/build/cjs/ocm/components/wizard/steps/staticIp/data/formDataFromInfraEnvField.js +5 -1
  88. package/build/cjs/ocm/components/wizard/steps/staticIp/data/formDataFromInfraEnvField.js.map +1 -1
  89. package/build/cjs/ocm/components/wizard/steps/staticIp/data/fromInfraEnv.js +48 -1
  90. package/build/cjs/ocm/components/wizard/steps/staticIp/data/fromInfraEnv.js.map +1 -1
  91. package/build/cjs/ocm/components/wizard/steps/staticIp/data/index.js +1 -0
  92. package/build/cjs/ocm/components/wizard/steps/staticIp/data/index.js.map +1 -1
  93. package/build/cjs/ocm/components/wizard/steps/staticIp/data/nmstateYaml.js +12 -1
  94. package/build/cjs/ocm/components/wizard/steps/staticIp/data/nmstateYaml.js.map +1 -1
  95. package/build/cjs/ocm/components/wizard/steps/staticIp/data/protocolVersion.js +9 -7
  96. package/build/cjs/ocm/components/wizard/steps/staticIp/data/protocolVersion.js.map +1 -1
  97. package/build/cjs/ocm/components/wizard/wizardComponents/ClusterWizardNavigation.js +31 -20
  98. package/build/cjs/ocm/components/wizard/wizardComponents/ClusterWizardNavigation.js.map +1 -1
  99. package/lib/common/components/clusterWizard/ClusterWizardStep.css +9 -0
  100. package/lib/common/config/constants.ts +1 -0
  101. package/lib/common/config/docs_links.ts +3 -0
  102. package/lib/common/validationSchemas/_validationSchemas.test.ts +1 -1
  103. package/lib/common/validationSchemas/addressValidation.tsx +2 -2
  104. package/lib/ocm/components/wizard/NewClusterWizard.tsx +5 -0
  105. package/lib/ocm/components/wizard/clusterWizardContext/ClusterWizardContextProvider.tsx +63 -85
  106. package/lib/ocm/components/wizard/clusterWizardContext/utils.ts +73 -0
  107. package/lib/ocm/components/wizard/steps/clusterDetails/ClusterDetailsForm.tsx +0 -2
  108. package/lib/ocm/components/wizard/steps/disconnected/BasicStep.tsx +147 -7
  109. package/lib/ocm/components/wizard/steps/disconnected/DisconnectedReviewStep.tsx +101 -72
  110. package/lib/ocm/components/wizard/steps/disconnected/DisconnectedStaticIp.tsx +29 -0
  111. package/lib/ocm/components/wizard/steps/disconnected/InstallDisconnectedSwitch.tsx +1 -0
  112. package/lib/ocm/components/wizard/steps/disconnected/OptionalConfigurationsStep.tsx +137 -69
  113. package/lib/ocm/components/wizard/steps/disconnected/index.tsx +1 -0
  114. package/lib/ocm/components/wizard/steps/staticIp/StaticIp.tsx +1 -1
  115. package/lib/ocm/components/wizard/steps/staticIp/commonValidationSchemas.tsx +42 -3
  116. package/lib/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/FormViewNetworkWide.tsx +15 -4
  117. package/lib/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/FormViewNetworkWideFields.tsx +232 -14
  118. package/lib/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/disconnectedNetworkWideValidationSchema.tsx +98 -0
  119. package/lib/ocm/components/wizard/steps/staticIp/components/FormViewNetworkWide/formViewNetworkWideValidationSchema.tsx +14 -5
  120. package/lib/ocm/components/wizard/steps/staticIp/components/StaticIpPage.tsx +8 -3
  121. package/lib/ocm/components/wizard/steps/staticIp/data/dataTypes.ts +1 -1
  122. package/lib/ocm/components/wizard/steps/staticIp/data/disconnectedNetworkWide.ts +81 -0
  123. package/lib/ocm/components/wizard/steps/staticIp/data/formDataFromInfraEnvField.ts +6 -2
  124. package/lib/ocm/components/wizard/steps/staticIp/data/fromInfraEnv.ts +57 -2
  125. package/lib/ocm/components/wizard/steps/staticIp/data/index.tsx +1 -0
  126. package/lib/ocm/components/wizard/steps/staticIp/data/nmstateYaml.ts +16 -0
  127. package/lib/ocm/components/wizard/steps/staticIp/data/protocolVersion.ts +9 -7
  128. package/lib/ocm/components/wizard/utils/_wizardTransition.test.ts +60 -1
  129. package/lib/ocm/components/wizard/wizardComponents/ClusterWizardNavigation.tsx +39 -16
  130. package/package.json +3 -3
@@ -1,48 +1,82 @@
1
1
  import * as React from 'react';
2
2
  import * as Yup from 'yup';
3
3
  import { Formik, useFormikContext } from 'formik';
4
- import { AlertVariant } from '@patternfly/react-core';
5
- import { Form, Grid, GridItem, Content } from '@patternfly/react-core';
6
- import { ImageType } from '@openshift-assisted/types/assisted-installer-service';
4
+ import { Alert, AlertVariant, Form, Grid, GridItem, Content } from '@patternfly/react-core';
5
+ import {
6
+ InfraEnv,
7
+ InfraEnvUpdateParams,
8
+ } from '@openshift-assisted/types/assisted-installer-service';
7
9
  import {
8
10
  ClusterWizardStep,
9
11
  WithErrorBoundary,
10
12
  UploadSSH,
11
- isInOcm,
12
- PullSecret,
13
13
  useAlerts,
14
14
  sshPublicKeyValidationSchema,
15
- pullSecretValidationSchema,
16
15
  InfraEnvsAPI,
17
- ClustersAPI,
18
16
  handleApiError,
19
17
  getApiErrorMessage,
20
18
  useTranslation,
19
+ InputField,
20
+ ipValidationSchema,
21
+ getFormikErrorFields,
22
+ httpProxyValidationSchema,
23
+ httpsProxyValidationSchema,
24
+ noProxyValidationSchema,
25
+ ntpSourceValidationSchema,
26
+ ProxyFields,
27
+ NtpSourcesFields,
21
28
  } from '../../../../../common';
22
- import { usePullSecret } from '../../../../hooks';
23
29
  import { useClusterWizardContext } from '../../clusterWizardContext';
24
30
  import { ClusterWizardNavigation, ClusterWizardFooter } from '../../wizardComponents';
25
- import { DISCONNECTED_OPENSHIFT_VERSION } from './BasicStep';
26
-
27
- const DISCONNECTED_IMAGE_TYPE: ImageType = 'disconnected-iso';
28
- const DISCONNECTED_CLUSTER_NAME = 'disconnected-cluster';
31
+ import { getDummyInfraEnvField } from '../staticIp/data/dummyData';
32
+ import {
33
+ canonicalizeIp,
34
+ getHostIpsFromInfraEnv,
35
+ getStaticNetworkConfig,
36
+ } from '../staticIp/data/fromInfraEnv';
29
37
 
30
38
  type OptionalConfigurationsValues = {
31
39
  sshPublicKey: string;
32
- pullSecret: string;
40
+ rendezvousIp: string;
41
+ enableProxy: boolean;
42
+ httpProxy: string;
43
+ httpsProxy: string;
44
+ noProxy: string;
45
+ enableNtpSources: boolean;
46
+ ntpSourcesList: string;
33
47
  };
34
48
 
35
49
  type OptionalConfigurationsFormProps = {
36
- defaultPullSecret?: string;
37
50
  isSubmitting: boolean;
38
51
  };
39
52
 
53
+ const isRendezvousIpInStaticHostList = (
54
+ rendezvousIp: string | undefined,
55
+ infraEnv: InfraEnv | undefined,
56
+ ): boolean => {
57
+ if (!rendezvousIp?.trim()) {
58
+ return true;
59
+ }
60
+ const staticHostIps = getHostIpsFromInfraEnv(infraEnv);
61
+ if (!staticHostIps.length) {
62
+ return true;
63
+ }
64
+ const canonicalRendezvousIp = canonicalizeIp(rendezvousIp.trim());
65
+ return staticHostIps.some((ip) => canonicalizeIp(ip) === canonicalRendezvousIp);
66
+ };
67
+
40
68
  const OptionalConfigurationsForm: React.FC<OptionalConfigurationsFormProps> = ({
41
- defaultPullSecret,
42
69
  isSubmitting,
43
70
  }) => {
44
- const { moveBack } = useClusterWizardContext();
45
- const { isValid, submitForm } = useFormikContext<OptionalConfigurationsValues>();
71
+ const { moveBack, disconnectedInfraEnv } = useClusterWizardContext();
72
+ const { isValid, submitForm, errors, touched, values } =
73
+ useFormikContext<OptionalConfigurationsValues>();
74
+ const errorFields = getFormikErrorFields(errors, touched);
75
+
76
+ const showRendezvousIpMismatchWarning =
77
+ !!disconnectedInfraEnv?.staticNetworkConfig &&
78
+ !!values.rendezvousIp.trim() &&
79
+ !isRendezvousIpInStaticHostList(values.rendezvousIp, disconnectedInfraEnv);
46
80
 
47
81
  return (
48
82
  <ClusterWizardStep
@@ -53,6 +87,7 @@ const OptionalConfigurationsForm: React.FC<OptionalConfigurationsFormProps> = ({
53
87
  onBack={moveBack}
54
88
  isSubmitting={isSubmitting}
55
89
  isNextDisabled={!isValid}
90
+ errorFields={errorFields}
56
91
  />
57
92
  }
58
93
  >
@@ -63,8 +98,25 @@ const OptionalConfigurationsForm: React.FC<OptionalConfigurationsFormProps> = ({
63
98
  </GridItem>
64
99
  <GridItem>
65
100
  <Form id="wizard-cluster-optional-config__form">
101
+ <InputField
102
+ label="Rendezvous IP"
103
+ name="rendezvousIp"
104
+ helperText="The IP address that hosts will use to communicate with the bootstrap node during installation."
105
+ maxLength={45}
106
+ />
107
+ {showRendezvousIpMismatchWarning && (
108
+ <Alert
109
+ isInline
110
+ variant="warning"
111
+ title="Rendezvous IP does not match a configured static IP"
112
+ >
113
+ The rendezvous IP does not match any of the configured static IP addresses. The
114
+ installation may fail if the rendezvous IP is unreachable.
115
+ </Alert>
116
+ )}
66
117
  <UploadSSH />
67
- {!isInOcm && <PullSecret isOcm={false} defaultPullSecret={defaultPullSecret} />}
118
+ <ProxyFields />
119
+ <NtpSourcesFields />
68
120
  </Form>
69
121
  </GridItem>
70
122
  </Grid>
@@ -73,31 +125,76 @@ const OptionalConfigurationsForm: React.FC<OptionalConfigurationsFormProps> = ({
73
125
  );
74
126
  };
75
127
 
128
+ const getStaticNetworkConfigUpdate = (infraEnv: InfraEnv) => {
129
+ if (!infraEnv.staticNetworkConfig) {
130
+ return [];
131
+ }
132
+ return getStaticNetworkConfig(infraEnv) ?? getDummyInfraEnvField();
133
+ };
134
+
135
+ const buildInfraEnvUpdateParams = (
136
+ values: OptionalConfigurationsValues,
137
+ disconnectedInfraEnv: InfraEnv,
138
+ ): InfraEnvUpdateParams => ({
139
+ sshAuthorizedKey: values.sshPublicKey,
140
+ rendezvousIp: values.rendezvousIp,
141
+ staticNetworkConfig: getStaticNetworkConfigUpdate(disconnectedInfraEnv),
142
+ proxy: {
143
+ httpProxy: values.httpProxy,
144
+ httpsProxy: values.httpsProxy,
145
+ noProxy: values.noProxy,
146
+ },
147
+ ntpSources: values.enableNtpSources ? values.ntpSourcesList : '',
148
+ });
149
+
76
150
  export const OptionalConfigurationsStep = () => {
77
151
  const { t } = useTranslation();
78
- const {
79
- moveNext,
80
- disconnectedCluster,
81
- setDisconnectedCluster,
82
- disconnectedInfraEnv,
83
- setDisconnectedInfraEnv,
84
- } = useClusterWizardContext();
152
+ const { moveNext, disconnectedInfraEnv, setDisconnectedInfraEnv } = useClusterWizardContext();
85
153
  const { addAlert, clearAlerts } = useAlerts();
86
154
  const [isSubmitting, setIsSubmitting] = React.useState(false);
87
- const defaultPullSecret = usePullSecret();
88
155
 
89
156
  const validationSchema = React.useMemo(
90
157
  () =>
91
- Yup.object({
92
- sshPublicKey: sshPublicKeyValidationSchema(t),
93
- pullSecret: isInOcm ? Yup.string() : pullSecretValidationSchema(t),
94
- }),
158
+ Yup.lazy((values: OptionalConfigurationsValues) =>
159
+ Yup.object({
160
+ sshPublicKey: sshPublicKeyValidationSchema(t),
161
+ rendezvousIp: Yup.string()
162
+ .max(45, 'IP address must be at most 45 characters')
163
+ .concat(ipValidationSchema(t)),
164
+ httpProxy: httpProxyValidationSchema({
165
+ values,
166
+ pairValueName: 'httpsProxy',
167
+ allowEmpty: true,
168
+ t,
169
+ }),
170
+ httpsProxy: httpsProxyValidationSchema({
171
+ values,
172
+ pairValueName: 'httpProxy',
173
+ allowEmpty: true,
174
+ t,
175
+ }),
176
+ noProxy: noProxyValidationSchema(t),
177
+ ntpSourcesList: values.enableNtpSources
178
+ ? ntpSourceValidationSchema(t, false)
179
+ : ntpSourceValidationSchema(t),
180
+ }),
181
+ ),
95
182
  [t],
96
183
  );
97
184
 
98
185
  const initialValues: OptionalConfigurationsValues = {
99
186
  sshPublicKey: disconnectedInfraEnv?.sshAuthorizedKey ?? '',
100
- pullSecret: defaultPullSecret ?? '',
187
+ rendezvousIp: disconnectedInfraEnv?.rendezvousIp ?? '',
188
+ enableProxy: !!(
189
+ disconnectedInfraEnv?.proxy?.httpProxy ||
190
+ disconnectedInfraEnv?.proxy?.httpsProxy ||
191
+ disconnectedInfraEnv?.proxy?.noProxy
192
+ ),
193
+ httpProxy: disconnectedInfraEnv?.proxy?.httpProxy ?? '',
194
+ httpsProxy: disconnectedInfraEnv?.proxy?.httpsProxy ?? '',
195
+ noProxy: disconnectedInfraEnv?.proxy?.noProxy ?? '',
196
+ enableNtpSources: !!disconnectedInfraEnv?.ntpSources?.trim(),
197
+ ntpSourcesList: disconnectedInfraEnv?.ntpSources ?? '',
101
198
  };
102
199
 
103
200
  const handleNext = React.useCallback(
@@ -105,31 +202,15 @@ export const OptionalConfigurationsStep = () => {
105
202
  clearAlerts();
106
203
  setIsSubmitting(true);
107
204
  try {
108
- const pullSecretToUse = isInOcm ? defaultPullSecret ?? '' : values.pullSecret;
109
-
110
- if (disconnectedCluster?.id && disconnectedInfraEnv?.id) {
111
- const { data: updatedInfraEnv } = await InfraEnvsAPI.update(disconnectedInfraEnv.id, {
112
- sshAuthorizedKey: values.sshPublicKey,
113
- });
114
- setDisconnectedInfraEnv(updatedInfraEnv);
115
- } else {
116
- const { data: cluster } = await ClustersAPI.registerDisconnected({
117
- name: DISCONNECTED_CLUSTER_NAME,
118
- openshiftVersion: DISCONNECTED_OPENSHIFT_VERSION,
119
- });
120
- setDisconnectedCluster(cluster);
121
-
122
- const { data: createdInfraEnv } = await InfraEnvsAPI.register({
123
- name: 'disconnected-infra-env',
124
- pullSecret: pullSecretToUse,
125
- clusterId: cluster.id,
126
- imageType: DISCONNECTED_IMAGE_TYPE,
127
- openshiftVersion: DISCONNECTED_OPENSHIFT_VERSION,
128
- sshAuthorizedKey: values.sshPublicKey || undefined,
129
- });
130
- setDisconnectedInfraEnv(createdInfraEnv);
205
+ if (!disconnectedInfraEnv?.id) {
206
+ throw new Error('No disconnected infraEnv available');
131
207
  }
132
208
 
209
+ const { data: updatedInfraEnv } = await InfraEnvsAPI.update(
210
+ disconnectedInfraEnv.id,
211
+ buildInfraEnvUpdateParams(values, disconnectedInfraEnv),
212
+ );
213
+ setDisconnectedInfraEnv(updatedInfraEnv);
133
214
  moveNext();
134
215
  } catch (error) {
135
216
  handleApiError(error, () => {
@@ -143,29 +224,16 @@ export const OptionalConfigurationsStep = () => {
143
224
  setIsSubmitting(false);
144
225
  }
145
226
  },
146
- [
147
- clearAlerts,
148
- defaultPullSecret,
149
- disconnectedCluster,
150
- disconnectedInfraEnv,
151
- setDisconnectedCluster,
152
- setDisconnectedInfraEnv,
153
- addAlert,
154
- moveNext,
155
- ],
227
+ [clearAlerts, disconnectedInfraEnv, setDisconnectedInfraEnv, addAlert, moveNext],
156
228
  );
157
229
 
158
230
  return (
159
231
  <Formik<OptionalConfigurationsValues>
160
232
  initialValues={initialValues}
161
- enableReinitialize
162
233
  validationSchema={validationSchema}
163
234
  onSubmit={(values) => void handleNext(values)}
164
235
  >
165
- <OptionalConfigurationsForm
166
- defaultPullSecret={defaultPullSecret}
167
- isSubmitting={isSubmitting}
168
- />
236
+ <OptionalConfigurationsForm isSubmitting={isSubmitting} />
169
237
  </Formik>
170
238
  );
171
239
  };
@@ -2,3 +2,4 @@ export * from './InstallDisconnectedSwitch';
2
2
  export * from './BasicStep';
3
3
  export * from './OptionalConfigurationsStep';
4
4
  export * from './DisconnectedReviewStep';
5
+ export * from './DisconnectedStaticIp';
@@ -25,7 +25,7 @@ const getInitialFormStateProps = () => {
25
25
  };
26
26
  };
27
27
 
28
- export const StaticIp: React.FC<StaticIpProps & { cluster: Cluster }> = ({
28
+ export const StaticIp: React.FC<StaticIpProps & { cluster?: Cluster }> = ({
29
29
  cluster,
30
30
  infraEnv,
31
31
  updateInfraEnv,
@@ -2,7 +2,8 @@ import * as Yup from 'yup';
2
2
  import { isInSubnet } from 'is-in-subnet';
3
3
  import { Address4, Address6 } from 'ip-address';
4
4
  import { getDuplicates } from '../../../../../common';
5
- import { getAddressObject, ProtocolVersion } from './data';
5
+ import { ProtocolVersion } from './data/dataTypes';
6
+ import { getAddressObject } from './data/protocolVersion';
6
7
 
7
8
  const RESERVED_IPS = ['127.0.0.0', '127.0.0.1', '0.0.0.0', '255.255.255.255'];
8
9
 
@@ -41,7 +42,7 @@ export const getUniqueValidationSchema = <FormValues,>(
41
42
  );
42
43
  };
43
44
 
44
- const isValidIPv4Address = (addressStr: string) => {
45
+ export const isValidIPv4Address = (addressStr: string) => {
45
46
  try {
46
47
  // ip-address package treats cidr addresses as valid so need to verify it isn't a cidr
47
48
  // Can't use Address4.isValid()
@@ -52,7 +53,7 @@ const isValidIPv4Address = (addressStr: string) => {
52
53
  }
53
54
  };
54
55
 
55
- const isValidIPv6Address = (addressStr: string) => {
56
+ export const isValidIPv6Address = (addressStr: string) => {
56
57
  try {
57
58
  // ip-address package treats cidr addresses as valid so need to verify it isn't a cidr
58
59
  // Can't use Address6.isValid()
@@ -87,6 +88,44 @@ const isReservedAddress = (addressStr: string, protocolVersion?: ProtocolVersion
87
88
  }
88
89
  };
89
90
 
91
+ export const detectProtocolVersionFromIp = (ip?: string): ProtocolVersion | undefined => {
92
+ if (!ip) {
93
+ return undefined;
94
+ }
95
+ if (isValidIPv4Address(ip)) {
96
+ return ProtocolVersion.ipv4;
97
+ }
98
+ if (isValidIPv6Address(ip)) {
99
+ return ProtocolVersion.ipv6;
100
+ }
101
+ return undefined;
102
+ };
103
+
104
+ export const getFamilyAgnosticIpValidationSchema = () => {
105
+ return Yup.string().test(
106
+ 'ipv4-or-ipv6',
107
+ 'Value ${value} is not a valid IPv4 or IPv6 address',
108
+ (value?: string) => {
109
+ if (!value) {
110
+ return true;
111
+ }
112
+ return isValidIPv4Address(value) || isValidIPv6Address(value);
113
+ },
114
+ );
115
+ };
116
+
117
+ export const getDnsMatchingSubnetFamilyValidationSchema = (subnetIp: string) => {
118
+ const family = detectProtocolVersionFromIp(subnetIp);
119
+ if (!family) {
120
+ return getFamilyAgnosticIpValidationSchema()
121
+ .required('A value is required')
122
+ .concat(isNotReservedHostDNSAddress());
123
+ }
124
+ return getMultipleIpAddressValidationSchema(family)
125
+ .required('A value is required')
126
+ .concat(isNotReservedHostDNSAddress(family));
127
+ };
128
+
90
129
  export const getIpAddressValidationSchema = (protocolVersion: ProtocolVersion) => {
91
130
  const protocolVersionLabel = protocolVersion === ProtocolVersion.ipv4 ? 'IPv4' : 'IPv6';
92
131
  return Yup.string().test(
@@ -5,15 +5,20 @@ import {
5
5
  getFormViewNetworkWideValues,
6
6
  getEmptyNetworkWideConfigurations,
7
7
  networkWideToInfraEnvField,
8
+ disconnectedNetworkWideToInfraEnvField,
9
+ getDisconnectedFormViewNetworkWideValues,
8
10
  FormViewHost,
9
11
  FormViewNetworkWideValues,
10
12
  } from '../../data';
11
13
  import { StaticIpForm } from '../StaticIpForm';
12
14
  import { StaticIpFormProps, StaticIpViewProps } from '../propTypes';
13
15
  import { networkWideValidationSchema } from './formViewNetworkWideValidationSchema';
16
+ import { disconnectedNetworkWideValidationSchema } from './disconnectedNetworkWideValidationSchema';
14
17
  import { FormViewNetworkWideFields } from './FormViewNetworkWideFields';
18
+ import { useClusterWizardContext } from '../../../../clusterWizardContext';
15
19
 
16
20
  export const FormViewNetworkWide: React.FC<StaticIpViewProps> = ({ infraEnv, ...props }) => {
21
+ const { installDisconnected } = useClusterWizardContext();
17
22
  const [formProps, setFormProps] = React.useState<StaticIpFormProps<FormViewNetworkWideValues>>();
18
23
  const [hosts, setHosts] = React.useState<FormViewHost[]>();
19
24
 
@@ -26,16 +31,22 @@ export const FormViewNetworkWide: React.FC<StaticIpViewProps> = ({ infraEnv, ...
26
31
  setFormProps({
27
32
  infraEnv,
28
33
  ...props,
29
- validationSchema: networkWideValidationSchema,
34
+ validationSchema: installDisconnected
35
+ ? disconnectedNetworkWideValidationSchema
36
+ : networkWideValidationSchema,
30
37
  getInitialValues: (infraEnv: InfraEnv) => {
31
- return getFormViewNetworkWideValues(infraEnv);
38
+ return installDisconnected
39
+ ? getDisconnectedFormViewNetworkWideValues(infraEnv)
40
+ : getFormViewNetworkWideValues(infraEnv);
32
41
  },
33
42
  getUpdateParams: (currentInfraEnv: InfraEnv, values: FormViewNetworkWideValues) =>
34
- networkWideToInfraEnvField(currentInfraEnv, values),
43
+ installDisconnected
44
+ ? disconnectedNetworkWideToInfraEnvField(currentInfraEnv, values)
45
+ : networkWideToInfraEnvField(currentInfraEnv, values),
35
46
  getEmptyValues: () => getEmptyNetworkWideConfigurations(),
36
47
  });
37
48
  // eslint-disable-next-line react-hooks/exhaustive-deps
38
- }, []);
49
+ }, [installDisconnected]);
39
50
  if (!hosts || !formProps) {
40
51
  return null;
41
52
  }