Skip to content

Commit 11a4344

Browse files
committed
Update CreateManagedControlPlaneWizardContainer.tsx
1 parent ae5bd0e commit 11a4344

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

src/components/Wizards/CreateManagedControlPlaneWizardContainer.tsx

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export const CreateManagedControlPlaneWizardContainer: FC<
8282
mode: 'onChange',
8383
});
8484

85-
// Memoize next button text to avoid unnecessary recalculations
8685
const nextButtonText = useMemo(
8786
() => ({
8887
metadata: t('buttons.next'),
@@ -93,21 +92,18 @@ export const CreateManagedControlPlaneWizardContainer: FC<
9392
[t],
9493
);
9594

96-
// Helper to reset form and close dialog
9795
const resetFormAndClose = useCallback(() => {
9896
reset();
9997
setSelectedStep('metadata');
10098
setIsOpen(false);
10199
}, [reset, setIsOpen]);
102100

103-
// Helper to clear only the form fields, not the members
104101
const clearFormFields = useCallback(() => {
105102
resetField('name');
106103
resetField('chargingTarget');
107104
resetField('displayName');
108105
}, [resetField]);
109106

110-
// Set default member (current user) on open, clear fields on close
111107
useEffect(() => {
112108
if (user?.email && isOpen) {
113109
setValue('members', [
@@ -117,15 +113,12 @@ export const CreateManagedControlPlaneWizardContainer: FC<
117113
if (!isOpen) {
118114
clearFormFields();
119115
}
120-
// Only run when dialog open/close or user changes
121116
}, [user?.email, isOpen, setValue, clearFormFields]);
122117

123-
// API mutation hook
124118
const { trigger } = useApiResourceMutation<CreateManagedControlPlaneType>(
125119
CreateManagedControlPlaneResource(projectName, workspaceName),
126120
);
127121

128-
// Handles the creation API call and error dialog
129122
const handleCreateManagedControlPlane = useCallback(
130123
async ({
131124
name,
@@ -148,7 +141,6 @@ export const CreateManagedControlPlaneWizardContainer: FC<
148141
setSelectedStep('success');
149142
return true;
150143
} catch (e) {
151-
// Only show error dialog for APIError
152144
if (e instanceof APIError && errorDialogRef.current) {
153145
errorDialogRef.current.showErrorDialog(
154146
`${e.message}: ${JSON.stringify(e.info)}`,
@@ -162,7 +154,6 @@ export const CreateManagedControlPlaneWizardContainer: FC<
162154
[trigger, projectName, workspaceName],
163155
);
164156

165-
// Handles wizard step change (if user clicks on step header)
166157
const handleStepChange = useCallback(
167158
(e: Ui5CustomEvent<WizardDomRef, WizardStepChangeEventDetail>) => {
168159
const step = (e.detail.step.dataset.step ?? '') as WizardStepType;
@@ -171,16 +162,10 @@ export const CreateManagedControlPlaneWizardContainer: FC<
171162
[],
172163
);
173164

174-
// Handles the Next/Create/Close button logic
175165
const onNextClick = useCallback(() => {
176166
switch (selectedStep) {
177167
case 'metadata':
178-
handleSubmit(
179-
() => setSelectedStep('members'),
180-
() => {
181-
// Optionally, show a toast or error message here
182-
},
183-
)();
168+
handleSubmit(() => setSelectedStep('members'))();
184169
break;
185170
case 'members':
186171
setSelectedStep('summarize');
@@ -203,15 +188,13 @@ export const CreateManagedControlPlaneWizardContainer: FC<
203188
resetFormAndClose,
204189
]);
205190

206-
// Update members in form state
207191
const setMembers = useCallback(
208192
(members: Member[]) => {
209193
setValue('members', members, { shouldValidate: true });
210194
},
211195
[setValue],
212196
);
213197

214-
// Helper to determine if a step should be disabled
215198
const isStepDisabled = useCallback(
216199
(step: WizardStepType) => {
217200
switch (step) {
@@ -226,7 +209,6 @@ export const CreateManagedControlPlaneWizardContainer: FC<
226209
!isValid
227210
);
228211
case 'success':
229-
// Success step should only be enabled when selectedStep is 'success'
230212
return selectedStep !== 'success';
231213
default:
232214
return false;
@@ -235,7 +217,6 @@ export const CreateManagedControlPlaneWizardContainer: FC<
235217
[selectedStep, isValid],
236218
);
237219

238-
// Render
239220
return (
240221
<Dialog
241222
stretch
@@ -269,6 +250,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<
269250
data-testid="create-mcp-dialog"
270251
onClose={resetFormAndClose}
271252
>
253+
<ErrorDialog ref={errorDialogRef} />
272254
<Wizard contentLayout="SingleStep" onStepChange={handleStepChange}>
273255
<WizardStep
274256
icon="create-form"
@@ -324,10 +306,10 @@ export const CreateManagedControlPlaneWizardContainer: FC<
324306
text={t('common.namespace')}
325307
additionalText={`${projectName}--ws-${workspaceName}`}
326308
/>
327-
{/* If region is available, show it; otherwise, leave blank */}
309+
328310
<ListItemStandard
329311
text={t('common.region')}
330-
additionalText={''}
312+
additionalText={'🇪🇺'}
331313
/>
332314
</List>
333315
<br />
@@ -373,7 +355,6 @@ export const CreateManagedControlPlaneWizardContainer: FC<
373355
/>
374356
</WizardStep>
375357
</Wizard>
376-
<ErrorDialog ref={errorDialogRef} />
377358
</Dialog>
378359
);
379360
};

0 commit comments

Comments
 (0)