Skip to content

Commit

Permalink
HMS-2601 fix: PATCH executed on finish
Browse files Browse the repository at this point in the history
The code to update the data was executed when doing click on Next button
for the page 3, however it is expected this call is triggered when the
Finish button in the page 4 is clicked.

This change fix the above situation as when we do click on the Finish
button the event triggered is the onCloseClick.

Signed-off-by: Alejandro Visiedo <[email protected]>
  • Loading branch information
avisiedo committed Oct 3, 2023
1 parent f0a1312 commit b022f8a
Showing 1 changed file with 21 additions and 33 deletions.
54 changes: 21 additions & 33 deletions src/Routes/WizardPage/WizardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,29 @@ const WizardPage = () => {

/** Event triggered when Close button is clicked. */
const onCloseClick = () => {
// FIXME A few things pending:
// - Mocal confirmation
// TODO A few things pending:
// - Modal confirmation
// - Confirm =>
// - if not registered, dismiss wizard
// - else => DELETE /domains/:domain_id
// - Cancel or close model => Do not dismiss wizard
if (domain.domain_id) {
resources_api
.updateDomainUser(domain.domain_id, {
title: domain.title,
description: domain.description,
auto_enrollment_enabled: domain.auto_enrollment_enabled,
})
.then((response) => {
if (response.status >= 400) {
// TODO show-up notification with error message
}
})
.catch((error) => {
// TODO show-up notification with error message
console.log('error onClose: ' + error);
});
}
navigate('/domains');
};

Expand All @@ -56,6 +73,7 @@ const WizardPage = () => {
_newStep: { id?: string | number; name: React.ReactNode },

Check warning on line 73 in src/Routes/WizardPage/WizardPage.tsx

View workflow job for this annotation

GitHub Actions / validate

'_newStep' is defined but never used

Check warning on line 73 in src/Routes/WizardPage/WizardPage.tsx

View workflow job for this annotation

GitHub Actions / validate

'_newStep' is defined but never used
_prevStep: { prevId?: string | number; prevName: React.ReactNode }

Check warning on line 74 in src/Routes/WizardPage/WizardPage.tsx

View workflow job for this annotation

GitHub Actions / validate

'_prevStep' is defined but never used

Check warning on line 74 in src/Routes/WizardPage/WizardPage.tsx

View workflow job for this annotation

GitHub Actions / validate

'_prevStep' is defined but never used
) => {
// TODO If not needed at the end clean-up onPreviousPage
console.log('onPreviousPage fired');
return;
};
Expand All @@ -65,6 +83,7 @@ const WizardPage = () => {
_newStep: { id?: string | number; name: React.ReactNode },

Check warning on line 83 in src/Routes/WizardPage/WizardPage.tsx

View workflow job for this annotation

GitHub Actions / validate

'_newStep' is defined but never used

Check warning on line 83 in src/Routes/WizardPage/WizardPage.tsx

View workflow job for this annotation

GitHub Actions / validate

'_newStep' is defined but never used
_prevStep: { prevId?: string | number; prevName: React.ReactNode }

Check warning on line 84 in src/Routes/WizardPage/WizardPage.tsx

View workflow job for this annotation

GitHub Actions / validate

'_prevStep' is defined but never used

Check warning on line 84 in src/Routes/WizardPage/WizardPage.tsx

View workflow job for this annotation

GitHub Actions / validate

'_prevStep' is defined but never used
) => {
// TODO If not needed at the end clean-up onPreviousPage
console.log('onGoToStep fired');
return;
};
Expand All @@ -80,37 +99,6 @@ const WizardPage = () => {
const [, orderIndex] = id.split('-');
id = parseInt(orderIndex);
}
if (id === 2) {
// FIXME Clean-up when the token is created into the page 1
// try {
// const response = await resources_api.createDomainToken({ domain_type: 'rhel-idm' }, undefined, undefined);
// const newData = response.data;
// appContext.wizard.setToken(newData.domain_token);
// appContext.wizard.setUUID(newData.domain_id);
// } catch (error) {
// // TODO Add error hanlder
// console.log('error noNextPage: ' + error);
// appContext.wizard.setToken('');
// appContext.wizard.setUUID('');
// }
}
if (id === 4) {
try {
if (domain.domain_id) {
const response = await resources_api.updateDomainUser(domain.domain_id, {
title: domain.title,
description: domain.description,
auto_enrollment_enabled: domain.auto_enrollment_enabled,
});
if (response.status >= 400) {
// TODO show-up notification with error message
}
}
} catch (error) {
// TODO show-up notification with error message
console.log('error noNextPage: ' + error);
}
}
};

const initCanJumpPage1 = true;
Expand Down

0 comments on commit b022f8a

Please sign in to comment.