@@ -2,18 +2,14 @@ import {
22 Button ,
33 Checkbox ,
44 FormHelperText ,
5+ FormGroup ,
6+ Form ,
7+ TextInput ,
58 HelperText ,
69 HelperTextItem ,
710 Modal ,
811 ModalVariant ,
912 Radio ,
10- Stack ,
11- StackItem ,
12- TextInput ,
13- Divider ,
14- Flex ,
15- FlexItem ,
16- Text ,
1713} from '@patternfly/react-core' ;
1814import React from 'react' ;
1915import { ActionOperations , ActionTypes } from '@app/types/types' ;
@@ -165,10 +161,10 @@ export const ModalPowerManagement: React.FunctionComponent<ModalPowerManagementP
165161 if ( actionType === ActionTypes . INSTANT_ACTION ) {
166162 if ( actionOperation === ActionOperations . POWER_ON ) {
167163 debug ( 'Powering on the cluster' ) ;
168- startCluster ( selectedCluster ?. clusterId , userEmail , finalDescription ) ;
164+ startCluster ( selectedCluster ?. clusterId , userEmail ?? undefined , finalDescription ) ;
169165 } else if ( actionOperation === ActionOperations . POWER_OFF ) {
170166 debug ( 'Powering off the cluster' ) ;
171- stopCluster ( selectedCluster ?. clusterId , userEmail , finalDescription ) ;
167+ stopCluster ( selectedCluster ?. clusterId , userEmail ?? undefined , finalDescription ) ;
172168 }
173169 } else {
174170 // Creating base action. Tunning depending on ActionType
@@ -237,109 +233,84 @@ export const ModalPowerManagement: React.FunctionComponent<ModalPowerManagementP
237233 >
238234 { /* Account selection */ }
239235
240- < Stack hasGutter >
241- < Flex alignItems = { { default : 'alignItemsCenter' } } >
242- < FlexItem >
243- < Text component = "h2" > Target</ Text >
244- </ FlexItem >
245- < FlexItem grow = { { default : 'grow' } } >
246- < Divider />
247- </ FlexItem >
248- </ Flex >
249- < StackItem >
250- < AccountTypeaheadSelect
251- accounts = { allAccounts }
252- selectedAccount = { selectedAccount }
253- onSelectAccount = { account => {
254- setSelectedAccount ( account ) ;
255- } }
256- onClearAccount = { onAccountClearButtonClick }
257- />
258- < ClusterTypeaheadSelect
259- accountId = { selectedAccount ?. accountId ?? null }
260- clusters = { allClusters }
261- selectedCluster = { selectedCluster }
262- onSelectCluster = { cluster => {
263- setSelectedCluster ( cluster ) ;
264- } }
265- isDisabled = { ! selectedAccount }
266- onClearCluster = { onClusterClearButtonClick }
267- />
268- </ StackItem >
269- < Divider />
236+ < Form >
237+ < AccountTypeaheadSelect
238+ accounts = { allAccounts }
239+ selectedAccount = { selectedAccount }
240+ onSelectAccount = { account => {
241+ setSelectedAccount ( account ) ;
242+ } }
243+ onClearAccount = { onAccountClearButtonClick }
244+ />
245+ < ClusterTypeaheadSelect
246+ accountId = { selectedAccount ?. accountId ?? null }
247+ clusters = { allClusters }
248+ selectedCluster = { selectedCluster }
249+ onSelectCluster = { cluster => {
250+ setSelectedCluster ( cluster ) ;
251+ } }
252+ isDisabled = { ! selectedAccount }
253+ onClearCluster = { onClusterClearButtonClick }
254+ />
270255
271256 { /* Action selection */ }
272- < Flex alignItems = { { default : 'alignItemsCenter' } } >
273- < FlexItem >
274- < Text component = "h2" > Action</ Text >
275- </ FlexItem >
276- < FlexItem grow = { { default : 'grow' } } >
277- < Divider />
278- </ FlexItem >
279- </ Flex >
280- < StackItem >
257+ < FormGroup label = "Action" role = "radiogroup" isRequired fieldId = "action-operation" >
281258 < Radio
282259 id = "action-power-on"
283260 name = "action"
284261 label = "Power On"
262+ isChecked = { actionOperation === ActionOperations . POWER_ON }
285263 onChange = { ( ) => setActionOperation ( ActionOperations . POWER_ON ) }
286264 />
287265 < Radio
288266 id = "action-power-off"
289267 name = "action"
290268 label = "Power Off"
269+ isChecked = { actionOperation === ActionOperations . POWER_OFF }
291270 onChange = { ( ) => setActionOperation ( ActionOperations . POWER_OFF ) }
292271 />
293- </ StackItem >
272+ </ FormGroup >
294273
295274 { /* Schedule management */ }
296- < Flex alignItems = { { default : 'alignItemsCenter' } } >
297- < FlexItem >
298- < Text component = "h2" > Execution</ Text >
299- </ FlexItem >
300- < FlexItem grow = { { default : 'grow' } } >
301- < Divider />
302- </ FlexItem >
303- </ Flex >
304- < StackItem >
275+ < FormGroup label = "Execution" fieldId = "scheduled-action-type" >
305276 < Checkbox
306277 id = "scheduled-action-type"
307278 name = "scheduled-action-type"
308- label = "Schedule Action "
279+ label = "Schedule action "
309280 isChecked = { showSchedule }
310281 onChange = { ( _event , checked ) => {
311282 setShowSchedule ( checked ) ;
312283 setActionType ( checked ? ActionTypes . SCHEDULED_ACTION : ActionTypes . INSTANT_ACTION ) ;
313284 } }
314285 />
315- </ StackItem >
286+ </ FormGroup >
316287 { showSchedule && (
317288 < >
318- < StackItem >
289+ < FormGroup role = "radiogroup" fieldId = "schedule-type" >
319290 < Radio
320291 id = "specific-time"
321292 name = "scheduleType"
322293 label = "Specific time"
323294 isChecked = { actionType === ActionTypes . SCHEDULED_ACTION }
324295 onChange = { ( ) => setActionType ( ActionTypes . SCHEDULED_ACTION ) }
325296 />
326- </ StackItem >
297+ </ FormGroup >
327298 { actionType === ActionTypes . SCHEDULED_ACTION && (
328- < StackItem >
299+ < FormGroup fieldId = "datetime-picker" isRequired >
329300 < DateTimePicker onChange = { setScheduledDateTime } />
330- </ StackItem >
301+ </ FormGroup >
331302 ) }
332- < StackItem >
303+ < FormGroup fieldId = "cron-expression-input" isRequired >
333304 < Radio
334305 id = "cron-expression"
335306 name = "scheduleType"
336307 label = "Cron expression"
337308 isChecked = { actionType === ActionTypes . CRON_ACTION }
338309 onChange = { ( ) => setActionType ( ActionTypes . CRON_ACTION ) }
339310 />
340- </ StackItem >
311+ </ FormGroup >
341312 { actionType === ActionTypes . CRON_ACTION && (
342- < StackItem >
313+ < FormGroup fieldId = "cron-expression-input" isRequired >
343314 < TextInput
344315 type = "text"
345316 id = "cron-expression-input"
@@ -355,21 +326,13 @@ export const ModalPowerManagement: React.FunctionComponent<ModalPowerManagementP
355326 </ HelperTextItem >
356327 </ HelperText >
357328 </ FormHelperText >
358- </ StackItem >
329+ </ FormGroup >
359330 ) }
360331 </ >
361332 ) }
362333
363- { /* Reason management */ }
364- < Flex alignItems = { { default : 'alignItemsCenter' } } >
365- < FlexItem >
366- < Text component = "h2" > Description (Optional)</ Text >
367- </ FlexItem >
368- < FlexItem grow = { { default : 'grow' } } >
369- < Divider />
370- </ FlexItem >
371- </ Flex >
372- < StackItem >
334+ { /* Description management */ }
335+ < FormGroup label = "Description" fieldId = "description-input" >
373336 < TextInput
374337 type = "text"
375338 id = "description-input"
@@ -378,8 +341,8 @@ export const ModalPowerManagement: React.FunctionComponent<ModalPowerManagementP
378341 placeholder = "Enter reason"
379342 aria-label = "Reason for action"
380343 />
381- </ StackItem >
382- </ Stack >
344+ </ FormGroup >
345+ </ Form >
383346 </ Modal >
384347 ) ;
385348
0 commit comments