Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wizard: Add beforeNext conditions to Details step footer #2392

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Components/CreateImageWizard/CreateImageWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
// Firstboot
const firstBootValidation = useFirstBootValidation();
// Details
const [detailsPristine, setDetailsPristine] = useState(true);
mgold1234 marked this conversation as resolved.
Show resolved Hide resolved
const detailsValidation = useDetailsValidation();

let startIndex = 1; // default index
Expand Down Expand Up @@ -453,7 +454,14 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
status={detailsValidation.disabledNext ? 'error' : 'default'}
footer={
<CustomWizardFooter
disableNext={detailsValidation.disabledNext}
beforeNext={() => {
if (detailsValidation.disabledNext) {
setDetailsPristine(false);
return false;
}
return true;
}}
disableNext={!detailsPristine && detailsValidation.disabledNext}
/>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ describe('Step Details', () => {
const nextButton = await getNextButton();
expect(nextButton).toBeEnabled();
await enterBlueprintName(' ');
await clickNext();
await waitFor(() => expect(nextButton).toBeDisabled());
});

Expand All @@ -83,6 +84,7 @@ describe('Step Details', () => {
await goToDetailsStep();
await enterBlueprintName('Lemon Pie');
const nextButton = await getNextButton();
await clickNext();
await waitFor(() => expect(nextButton).toBeDisabled());
});

Expand Down
Loading