@@ -2,8 +2,8 @@ import * as React from 'react';
2
2
import { Alert , AlertVariant , FlexItem , Form } from '@patternfly/react-core' ;
3
3
import { useFormikContext } from 'formik' ;
4
4
5
+ import { OpenShiftVersionDropdown , OpenShiftVersionModal } from '../../../common' ;
5
6
import { StaticTextField } from '../../../common/components/ui/StaticTextField' ;
6
- import OpenShiftVersionSelect from '../../../common/components/clusterConfiguration/OpenShiftVersionSelect' ;
7
7
import { PullSecret } from '../../../common/components/clusters' ;
8
8
import { OpenshiftVersionOptionType } from '../../../common/types' ;
9
9
import {
@@ -14,13 +14,14 @@ import {
14
14
import { ClusterDetailsValues } from '../../../common/components/clusterWizard/types' ;
15
15
import { useTranslation } from '../../../common/hooks/use-translation-wrapper' ;
16
16
import CpuArchitectureDropdown from '../common/CpuArchitectureDropdown' ;
17
- import { getNetworkType } from '../helpers' ;
18
17
import ControlPlaneNodesDropdown from '../../../common/components/clusterConfiguration/ControlPlaneNodesDropdown' ;
18
+
19
19
export type ClusterDetailsFormFieldsProps = {
20
20
isEditFlow : boolean ;
21
21
forceOpenshiftVersion ?: string ;
22
22
extensionAfter ?: { [ key : string ] : React . ReactElement } ;
23
23
versions : OpenshiftVersionOptionType [ ] ;
24
+ allVersions : OpenshiftVersionOptionType [ ] ;
24
25
isNutanix ?: boolean ;
25
26
cpuArchitectures ?: string [ ] ;
26
27
} ;
@@ -46,13 +47,39 @@ export const BaseDnsHelperText: React.FC<{ name?: string; baseDnsDomain?: string
46
47
export const ClusterDetailsFormFields : React . FC < ClusterDetailsFormFieldsProps > = ( {
47
48
isEditFlow,
48
49
versions,
50
+ allVersions,
49
51
forceOpenshiftVersion,
50
52
extensionAfter,
51
53
isNutanix,
52
54
cpuArchitectures,
53
55
} ) => {
54
- const { values, setFieldValue } = useFormikContext < ClusterDetailsValues > ( ) ;
56
+ const { values } = useFormikContext < ClusterDetailsValues > ( ) ;
55
57
const { name, baseDnsDomain } = values ;
58
+ const [ openshiftVersionModalOpen , setOpenshiftVersionModalOpen ] = React . useState ( false ) ;
59
+
60
+ const selectOptions = React . useMemo (
61
+ ( ) =>
62
+ versions . map ( ( version ) => ( {
63
+ label : version . label ,
64
+ value : version . value ,
65
+ } ) ) ,
66
+ [ versions ] ,
67
+ ) ;
68
+
69
+ const additionalSelectOptions = React . useMemo ( ( ) => {
70
+ if (
71
+ values . customOpenshiftSelect &&
72
+ ! selectOptions . some ( ( option ) => option . value === values . customOpenshiftSelect ?. value )
73
+ ) {
74
+ return [
75
+ {
76
+ value : values . customOpenshiftSelect . value ,
77
+ label : values . customOpenshiftSelect . label ,
78
+ } ,
79
+ ] ;
80
+ }
81
+ return [ ] ;
82
+ } , [ selectOptions , values . customOpenshiftSelect ] ) ;
56
83
57
84
const nameInputRef = React . useRef < HTMLInputElement > ( ) ;
58
85
React . useEffect ( ( ) => {
@@ -102,13 +129,22 @@ export const ClusterDetailsFormFields: React.FC<ClusterDetailsFormFieldsProps> =
102
129
{ t ( 'ai:OpenShift' ) } { forceOpenshiftVersion }
103
130
</ StaticTextField >
104
131
) : (
105
- < OpenShiftVersionSelect
106
- versions = { versions }
107
- onChange = { ( _event , value ) => {
108
- const ocpVersion = versions . find ( ( v ) => v . value === value ) ;
109
- setFieldValue ( 'networkType' , getNetworkType ( ocpVersion ) ) ;
110
- } }
111
- />
132
+ < >
133
+ < OpenShiftVersionDropdown
134
+ name = "openshiftVersion"
135
+ items = { selectOptions }
136
+ versions = { versions }
137
+ showReleasesLink = { false }
138
+ showOpenshiftVersionModal = { ( ) => setOpenshiftVersionModalOpen ( true ) }
139
+ customItems = { additionalSelectOptions }
140
+ />
141
+ { openshiftVersionModalOpen && (
142
+ < OpenShiftVersionModal
143
+ allVersions = { allVersions }
144
+ setOpenshiftVersionModalOpen = { setOpenshiftVersionModalOpen }
145
+ />
146
+ ) }
147
+ </ >
112
148
) }
113
149
< ControlPlaneNodesDropdown isNutanix = { isNutanix } isDisabled = { isEditFlow } />
114
150
{ ! isNutanix && (
0 commit comments