@@ -24,7 +24,17 @@ import {
2424 useAccessReview ,
2525 useK8sWatchResource ,
2626} from '@openshift-console/dynamic-plugin-sdk' ;
27- import { Modal , ModalVariant , Wizard , WizardStep , ValidatedOptions } from '@patternfly/react-core' ;
27+ import {
28+ Button ,
29+ Modal ,
30+ ModalVariant ,
31+ Wizard ,
32+ WizardStep ,
33+ WizardHeader ,
34+ WizardFooterWrapper ,
35+ useWizardContext ,
36+ ValidatedOptions ,
37+ } from '@patternfly/react-core' ;
2838import * as React from 'react' ;
2939
3040import { ContainerSelectionStep } from './ContainerSelectionStep' ;
@@ -43,7 +53,6 @@ import { InstanceSelectionStep } from './InstanceSelectionStep';
4353import { JavaOptsConfigStep } from './JavaOptsConfigStep' ;
4454import { LogLevelConfigStep } from './LogLevelConfigStep' ;
4555import { ReviewStep } from './ReviewStep' ;
46- import { WizardCustomFooter } from './WizardCustomFooter' ;
4756
4857interface CryostatModalProps {
4958 kind : K8sModel ;
@@ -567,105 +576,127 @@ export const DeploymentLabelActionModal: React.FC<CryostatModalProps> = ({ kind,
567576 const selectedInstance = formData . cryostatInstance !== EMPTY_VALUE ? cryostats [ formData . cryostatInstance ] : null ;
568577 const selectedContainer = containers [ formData . selectedContainerIndex ] || null ;
569578
570- const steps = [
571- {
572- id : 'instance-selection' ,
573- name : t ( 'DEPLOYMENT_ACTION_WIZARD_STEP_INSTANCE' ) ,
574- component : (
575- < InstanceSelectionStep
576- cryostats = { cryostats }
577- formSelectValue = { formSelectValue }
578- onChange = { handleInstanceChange }
579- validated = { validated }
580- helperText = { helperText }
581- />
582- ) ,
583- } ,
584- {
585- id : 'container-selection' ,
586- name : t ( 'DEPLOYMENT_ACTION_WIZARD_STEP_CONTAINER' ) ,
587- component : (
588- < ContainerSelectionStep
589- containers = { containers }
590- selectedContainerIndex = { formData . selectedContainerIndex }
591- onChange = { handleContainerChange }
592- logLevel = { formData . logLevel }
593- javaOptsVar = { formData . javaOptsVar }
594- />
595- ) ,
596- canJumpTo : formSelectValue !== EMPTY_VALUE && ! isDisabled ,
597- } ,
598- {
599- id : 'java-opts-config' ,
600- name : t ( 'DEPLOYMENT_ACTION_WIZARD_STEP_JAVA_OPTS' ) ,
601- component : < JavaOptsConfigStep javaOptsVar = { formData . javaOptsVar } onChange = { handleJavaOptsVarChange } /> ,
602- canJumpTo : formSelectValue !== EMPTY_VALUE && ! isDisabled ,
603- } ,
604- {
605- id : 'harvester-config' ,
606- name : t ( 'DEPLOYMENT_ACTION_WIZARD_STEP_HARVESTER' ) ,
607- component : (
608- < HarvesterConfigStep
609- harvesterTemplate = { formData . harvesterTemplate }
610- harvesterExitMaxAgeMs = { formData . harvesterExitMaxAgeMs }
611- harvesterExitMaxSizeB = { formData . harvesterExitMaxSizeB }
612- onChange = { handleHarvesterChange }
613- />
614- ) ,
615- canJumpTo : formSelectValue !== EMPTY_VALUE && ! isDisabled ,
616- } ,
617- {
618- id : 'log-level-config' ,
619- name : t ( 'DEPLOYMENT_ACTION_WIZARD_STEP_LOG_LEVEL' ) ,
620- component : < LogLevelConfigStep logLevel = { formData . logLevel } onChange = { handleLogLevelChange } /> ,
621- canJumpTo : formSelectValue !== EMPTY_VALUE && ! isDisabled ,
622- } ,
623- {
624- id : 'review' ,
625- name : t ( 'DEPLOYMENT_ACTION_WIZARD_STEP_REVIEW' ) ,
626- component : (
627- < ReviewStep
628- selectedInstance = { selectedInstance }
629- selectedContainer = { selectedContainer }
630- javaOptsVar = { formData . javaOptsVar }
631- harvesterTemplate = { formData . harvesterTemplate }
632- harvesterExitMaxAgeMs = { formData . harvesterExitMaxAgeMs }
633- harvesterExitMaxSizeB = { formData . harvesterExitMaxSizeB }
634- logLevel = { formData . logLevel }
635- />
636- ) ,
637- } ,
638- ] ;
579+ const InstanceSelectionFooter = ( ) => {
580+ const { goToNextStep } = useWizardContext ( ) ;
581+
582+ return (
583+ < WizardFooterWrapper >
584+ < Button
585+ variant = "primary"
586+ onClick = { handleQuickRegister }
587+ isDisabled = {
588+ ! (
589+ ( formSelectValue === EMPTY_VALUE && initialValue !== EMPTY_VALUE ) ||
590+ ( formSelectValue !== EMPTY_VALUE && ! isDisabled )
591+ )
592+ }
593+ >
594+ { formSelectValue === EMPTY_VALUE && initialValue !== EMPTY_VALUE
595+ ? t ( 'DEPLOYMENT_ACTION_DEREGISTER' )
596+ : t ( 'DEPLOYMENT_ACTION_QUICK_REGISTER' ) }
597+ </ Button >
598+ < Button variant = "secondary" onClick = { goToNextStep } isDisabled = { formSelectValue === EMPTY_VALUE || isDisabled } >
599+ { t ( 'NEXT' ) }
600+ </ Button >
601+ < Button variant = "link" onClick = { closeModal } >
602+ { t ( 'CANCEL' ) }
603+ </ Button >
604+ </ WizardFooterWrapper >
605+ ) ;
606+ } ;
639607
640608 return (
641609 < Modal
642610 variant = { ModalVariant . large }
643- title = { t ( 'DEPLOYMENT_ACTION_TITLE' ) }
644611 isOpen = { true }
645612 onClose = { closeModal }
646- hasNoBodyWrapper
647613 aria-label = { t ( 'DEPLOYMENT_ACTION_TITLE' ) }
648614 ouiaId = "CryostatDeploymentActionWizard"
649615 >
650616 < Wizard
651617 onClose = { closeModal }
652618 onSave = { handleFormSubmit }
653- footer = {
654- < WizardCustomFooter
655- onQuickRegister = { handleQuickRegister }
656- onSubmit = { handleFormSubmit }
657- onCancel = { closeModal }
658- isValid = { formSelectValue !== EMPTY_VALUE && ! isDisabled }
659- initialValue = { initialValue }
660- currentValue = { formSelectValue }
661- />
619+ header = {
620+ < WizardHeader title = { t ( 'DEPLOYMENT_ACTION_TITLE' ) } onClose = { closeModal } closeButtonAriaLabel = { t ( 'CLOSE' ) } />
662621 }
663622 >
664- { steps . map ( ( step ) => (
665- < WizardStep key = { step . id } id = { step . id } name = { step . name } >
666- { step . component }
667- </ WizardStep >
668- ) ) }
623+ < WizardStep
624+ id = "instance-selection"
625+ name = { t ( 'DEPLOYMENT_ACTION_WIZARD_STEP_INSTANCE' ) }
626+ footer = { < InstanceSelectionFooter /> }
627+ >
628+ < InstanceSelectionStep
629+ cryostats = { cryostats }
630+ formSelectValue = { formSelectValue }
631+ onChange = { handleInstanceChange }
632+ validated = { validated }
633+ helperText = { helperText }
634+ />
635+ </ WizardStep >
636+ < WizardStep
637+ id = "container-selection"
638+ name = { t ( 'DEPLOYMENT_ACTION_WIZARD_STEP_CONTAINER' ) }
639+ footer = { {
640+ isNextDisabled : isDisabled ,
641+ } }
642+ >
643+ < ContainerSelectionStep
644+ containers = { containers }
645+ selectedContainerIndex = { formData . selectedContainerIndex }
646+ onChange = { handleContainerChange }
647+ logLevel = { formData . logLevel }
648+ javaOptsVar = { formData . javaOptsVar }
649+ />
650+ </ WizardStep >
651+ < WizardStep
652+ id = "java-opts-config"
653+ name = { t ( 'DEPLOYMENT_ACTION_WIZARD_STEP_JAVA_OPTS' ) }
654+ footer = { {
655+ isNextDisabled : isDisabled ,
656+ } }
657+ >
658+ < JavaOptsConfigStep javaOptsVar = { formData . javaOptsVar } onChange = { handleJavaOptsVarChange } />
659+ </ WizardStep >
660+ < WizardStep
661+ id = "harvester-config"
662+ name = { t ( 'DEPLOYMENT_ACTION_WIZARD_STEP_HARVESTER' ) }
663+ footer = { {
664+ isNextDisabled : isDisabled ,
665+ } }
666+ >
667+ < HarvesterConfigStep
668+ harvesterTemplate = { formData . harvesterTemplate }
669+ harvesterExitMaxAgeMs = { formData . harvesterExitMaxAgeMs }
670+ harvesterExitMaxSizeB = { formData . harvesterExitMaxSizeB }
671+ onChange = { handleHarvesterChange }
672+ />
673+ </ WizardStep >
674+ < WizardStep
675+ id = "log-level-config"
676+ name = { t ( 'DEPLOYMENT_ACTION_WIZARD_STEP_LOG_LEVEL' ) }
677+ footer = { {
678+ isNextDisabled : isDisabled ,
679+ } }
680+ >
681+ < LogLevelConfigStep logLevel = { formData . logLevel } onChange = { handleLogLevelChange } />
682+ </ WizardStep >
683+ < WizardStep
684+ id = "review"
685+ name = { t ( 'DEPLOYMENT_ACTION_WIZARD_STEP_REVIEW' ) }
686+ footer = { {
687+ nextButtonText : t ( 'DEPLOYMENT_ACTION_REGISTER' ) ,
688+ } }
689+ >
690+ < ReviewStep
691+ selectedInstance = { selectedInstance }
692+ selectedContainer = { selectedContainer }
693+ javaOptsVar = { formData . javaOptsVar }
694+ harvesterTemplate = { formData . harvesterTemplate }
695+ harvesterExitMaxAgeMs = { formData . harvesterExitMaxAgeMs }
696+ harvesterExitMaxSizeB = { formData . harvesterExitMaxSizeB }
697+ logLevel = { formData . logLevel }
698+ />
699+ </ WizardStep >
669700 </ Wizard >
670701 </ Modal >
671702 ) ;
0 commit comments