Skip to content

Commit 529f458

Browse files
committed
fix
1 parent fbb44aa commit 529f458

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

public/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@
281281
"copy": "Copy",
282282
"next": "Next",
283283
"create": "Create",
284-
"close": "Close"
284+
"close": "Close",
285+
"back": "Back"
285286
},
286287
"yaml": {
287288
"copiedToClipboard": "YAML copied to clipboard!",

src/components/Wizards/CreateManagedControlPlaneWizardContainer.tsx

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ type CreateManagedControlPlaneWizardContainerProps = {
5353

5454
type WizardStepType = 'metadata' | 'members' | 'summarize' | 'success';
5555

56+
const wizardStepOrder: WizardStepType[] = [
57+
'metadata',
58+
'members',
59+
'summarize',
60+
'success',
61+
];
62+
5663
export const CreateManagedControlPlaneWizardContainer: FC<
5764
CreateManagedControlPlaneWizardContainerProps
5865
> = ({ isOpen, setIsOpen, projectName = '', workspaceName = '' }) => {
@@ -80,7 +87,6 @@ export const CreateManagedControlPlaneWizardContainer: FC<
8087
members: [],
8188
},
8289
mode: 'onChange',
83-
reValidateMode: 'onChange',
8490
});
8591

8692
const nextButtonText = useMemo(
@@ -218,6 +224,13 @@ export const CreateManagedControlPlaneWizardContainer: FC<
218224
[selectedStep, isValid],
219225
);
220226

227+
const onBackClick = useCallback(() => {
228+
const currentIndex = wizardStepOrder.indexOf(selectedStep);
229+
if (currentIndex > 0) {
230+
setSelectedStep(wizardStepOrder[currentIndex - 1]);
231+
}
232+
}, [selectedStep]);
233+
221234
return (
222235
<Dialog
223236
stretch
@@ -229,19 +242,17 @@ export const CreateManagedControlPlaneWizardContainer: FC<
229242
design="Footer"
230243
endContent={
231244
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
232-
{selectedStep !== 'success' && (
233-
<Button design="Negative" onClick={resetFormAndClose}>
234-
{t('buttons.close')}
235-
</Button>
236-
)}
237-
<Button
238-
design="Emphasized"
239-
disabled={
240-
(selectedStep === 'metadata' && !isValid) ||
241-
(selectedStep === 'summarize' && !isValid)
242-
}
243-
onClick={onNextClick}
244-
>
245+
{selectedStep !== 'success' &&
246+
(selectedStep === 'metadata' ? (
247+
<Button design="Negative" onClick={resetFormAndClose}>
248+
{t('buttons.close')}
249+
</Button>
250+
) : (
251+
<Button design="Negative" onClick={onBackClick}>
252+
{t('buttons.back')}
253+
</Button>
254+
))}
255+
<Button design="Emphasized" onClick={onNextClick}>
245256
{nextButtonText[selectedStep]}
246257
</Button>
247258
</div>

0 commit comments

Comments
 (0)