Skip to content

Commit 52ebabc

Browse files
[Snapshot Restore] Disable steps when form is invalid (#76540) (#77337)
1 parent 2613af4 commit 52ebabc

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

x-pack/plugins/snapshot_restore/public/application/components/policy_form/navigation.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ interface Props {
1111
currentStep: number;
1212
maxCompletedStep: number;
1313
updateCurrentStep: (step: number) => void;
14+
isFormValid: boolean;
1415
}
1516

1617
export const PolicyNavigation: React.FunctionComponent<Props> = ({
1718
currentStep,
1819
maxCompletedStep,
1920
updateCurrentStep,
21+
isFormValid,
2022
}) => {
2123
const { i18n } = useServices();
2224

@@ -27,6 +29,7 @@ export const PolicyNavigation: React.FunctionComponent<Props> = ({
2729
}),
2830
isComplete: maxCompletedStep >= 1,
2931
isSelected: currentStep === 1,
32+
disabled: !isFormValid && currentStep !== 1,
3033
onClick: () => updateCurrentStep(1),
3134
},
3235
{
@@ -35,7 +38,7 @@ export const PolicyNavigation: React.FunctionComponent<Props> = ({
3538
}),
3639
isComplete: maxCompletedStep >= 2,
3740
isSelected: currentStep === 2,
38-
disabled: maxCompletedStep < 1,
41+
disabled: maxCompletedStep < 1 || (!isFormValid && currentStep !== 2),
3942
onClick: () => updateCurrentStep(2),
4043
},
4144
{
@@ -44,7 +47,7 @@ export const PolicyNavigation: React.FunctionComponent<Props> = ({
4447
}),
4548
isComplete: maxCompletedStep >= 3,
4649
isSelected: currentStep === 3,
47-
disabled: maxCompletedStep < 2,
50+
disabled: maxCompletedStep < 2 || (!isFormValid && currentStep !== 3),
4851
onClick: () => updateCurrentStep(3),
4952
},
5053
{
@@ -53,7 +56,7 @@ export const PolicyNavigation: React.FunctionComponent<Props> = ({
5356
}),
5457
isComplete: maxCompletedStep >= 3,
5558
isSelected: currentStep === 4,
56-
disabled: maxCompletedStep < 3,
59+
disabled: maxCompletedStep < 3 || (!isFormValid && currentStep !== 4),
5760
onClick: () => updateCurrentStep(4),
5861
},
5962
];

x-pack/plugins/snapshot_restore/public/application/components/policy_form/policy_form.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export const PolicyForm: React.FunctionComponent<Props> = ({
130130
currentStep={currentStep}
131131
maxCompletedStep={maxCompletedStep}
132132
updateCurrentStep={updateCurrentStep}
133+
isFormValid={validation.isValid}
133134
/>
134135
<EuiSpacer size="l" />
135136
<EuiForm>

0 commit comments

Comments
 (0)