@@ -23,6 +23,7 @@ import {
23
23
CreateClusterStepKey ,
24
24
useCreateClusterContext ,
25
25
} from '../CreateClusterWizard'
26
+ import { Confirm } from '../../utils/Confirm'
26
27
27
28
const nameRegex = / ^ [ a - z ] [ a - z 0 - 9 - ] [ a - z 0 - 9 ] { 4 , 9 } $ /
28
29
@@ -35,6 +36,7 @@ export function ConfigureCloudInstanceStep() {
35
36
const [ size , setSize ] = useState < ConsoleSize > ( ConsoleSize . Small )
36
37
const [ cloud , setCloud ] = useState < CloudProvider > ( CloudProvider . Aws )
37
38
const [ region , setRegion ] = useState < string > ( regions [ 0 ] )
39
+ const [ confirm , setConfirm ] = useState ( false )
38
40
const isNameValid = nameRegex . test ( name )
39
41
40
42
const canSubmit = ! ! (
@@ -65,9 +67,8 @@ export function ConfigureCloudInstanceStep() {
65
67
setContinueBtn (
66
68
< Button
67
69
key = "create"
68
- loading = { loading }
69
70
disabled = { ! canSubmit }
70
- onClick = { ( ) => mutation ( ) }
71
+ onClick = { ( ) => setConfirm ( true ) }
71
72
>
72
73
Continue
73
74
</ Button >
@@ -79,82 +80,94 @@ export function ConfigureCloudInstanceStep() {
79
80
} , [ canSubmit , loading , mutation , setContinueBtn ] )
80
81
81
82
return (
82
- < Flex
83
- flexDirection = "column"
84
- gap = "medium"
85
- >
86
- { error && < GqlError error = { error } /> }
87
- < Callout
88
- css = { { marginBottom : theme . spacing . medium } }
89
- title = "Your Console may take a few minutes to deploy."
90
- >
91
- After completing this step it may take a few minutes for your Console to
92
- deploy. It will run in the background as you proceed.
93
- </ Callout >
94
- < FormFieldSC
95
- label = "Cluster name"
96
- hint = {
97
- < FormFieldCaptionSC $name = { name } >
98
- Name must be between 6 and 11 characters, lowercase, alphanumeric,
99
- and begin with a letter.
100
- </ FormFieldCaptionSC >
101
- }
83
+ < >
84
+ < Flex
85
+ flexDirection = "column"
86
+ gap = "medium"
102
87
>
103
- < Input
104
- placeholder = "Enter cluster name"
105
- borderColor = {
106
- name === '' || isNameValid
107
- ? undefined
108
- : theme . colors [ 'border-danger' ]
109
- }
110
- value = { name }
111
- onChange = { ( e ) => setName ( e . target . value ) }
112
- />
113
- </ FormFieldSC >
114
- < FormFieldSC label = "Cluster size" >
115
- < Select
116
- selectedKey = { size }
117
- onSelectionChange = { ( size ) => setSize ( size as ConsoleSize ) }
88
+ { error && < GqlError error = { error } /> }
89
+ < Callout
90
+ css = { { marginBottom : theme . spacing . medium } }
91
+ title = "Your Console may take a few minutes to deploy."
118
92
>
119
- { Object . values ( ConsoleSize )
120
- . reverse ( )
121
- . map ( ( value ) => (
122
- < ListBoxItem
123
- key = { value }
124
- label = { firstLetterUppercase ( value ) }
125
- />
126
- ) ) }
127
- </ Select >
128
- </ FormFieldSC >
129
- < FormFieldSC label = "Cloud" >
130
- < Select
131
- selectedKey = { cloud }
132
- onSelectionChange = { ( cloud ) => setCloud ( cloud as CloudProvider ) }
93
+ After completing this step it may take a few minutes for your Console
94
+ to deploy. It will run in the background as you proceed.
95
+ </ Callout >
96
+ < FormFieldSC
97
+ label = "Cluster name"
98
+ hint = {
99
+ < FormFieldCaptionSC $name = { name } >
100
+ Name must be between 6 and 11 characters, lowercase, alphanumeric,
101
+ and begin with a letter.
102
+ </ FormFieldCaptionSC >
103
+ }
133
104
>
134
- { Object . values ( CloudProvider ) . map ( ( value ) => (
135
- < ListBoxItem
136
- key = { value }
137
- label = { value }
138
- />
139
- ) ) }
140
- </ Select >
141
- </ FormFieldSC >
142
- { cloud === CloudProvider . Aws && (
143
- < FormFieldSC label = "Region" >
105
+ < Input
106
+ placeholder = "Enter cluster name"
107
+ borderColor = {
108
+ name === '' || isNameValid
109
+ ? undefined
110
+ : theme . colors [ 'border-danger' ]
111
+ }
112
+ value = { name }
113
+ onChange = { ( e ) => setName ( e . target . value ) }
114
+ />
115
+ </ FormFieldSC >
116
+ < FormFieldSC label = "Cluster size" >
144
117
< Select
145
- selectedKey = { region }
146
- onSelectionChange = { ( region ) => setRegion ( region as string ) }
118
+ selectedKey = { size }
119
+ onSelectionChange = { ( size ) => setSize ( size as ConsoleSize ) }
147
120
>
148
- { regions . map ( ( region ) => (
121
+ { Object . values ( ConsoleSize )
122
+ . reverse ( )
123
+ . map ( ( value ) => (
124
+ < ListBoxItem
125
+ key = { value }
126
+ label = { firstLetterUppercase ( value ) }
127
+ />
128
+ ) ) }
129
+ </ Select >
130
+ </ FormFieldSC >
131
+ < FormFieldSC label = "Cloud" >
132
+ < Select
133
+ selectedKey = { cloud }
134
+ onSelectionChange = { ( cloud ) => setCloud ( cloud as CloudProvider ) }
135
+ >
136
+ { Object . values ( CloudProvider ) . map ( ( value ) => (
149
137
< ListBoxItem
150
- key = { region }
151
- label = { region }
138
+ key = { value }
139
+ label = { value }
152
140
/>
153
141
) ) }
154
142
</ Select >
155
143
</ FormFieldSC >
156
- ) }
157
- </ Flex >
144
+ { cloud === CloudProvider . Aws && (
145
+ < FormFieldSC label = "Region" >
146
+ < Select
147
+ selectedKey = { region }
148
+ onSelectionChange = { ( region ) => setRegion ( region as string ) }
149
+ >
150
+ { regions . map ( ( region ) => (
151
+ < ListBoxItem
152
+ key = { region }
153
+ label = { region }
154
+ />
155
+ ) ) }
156
+ </ Select >
157
+ </ FormFieldSC >
158
+ ) }
159
+ </ Flex >
160
+ < Confirm
161
+ open = { confirm }
162
+ error = { error }
163
+ title = { `Create cluster` }
164
+ text = { `Would you like to proceed with cluster creation?` }
165
+ submit = { ( ) => mutation ( ) }
166
+ close = { ( ) => setConfirm ( false ) }
167
+ label = "Create cluster"
168
+ loading = { loading }
169
+ />
170
+ </ >
158
171
)
159
172
}
160
173
0 commit comments