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

[ENT-8510] - fix: SSO tool not updating SSO records if no form fields are changed #1183

Merged
merged 4 commits into from
Mar 15, 2024
Merged
Changes from 2 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
19 changes: 16 additions & 3 deletions src/components/settings/SettingsSSOTab/SSOFormWorkflowConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,24 @@ export const SSOFormWorkflowConfig = ({ enterpriseId, setConfigureError }) => {
}: FormWorkflowHandlerArgs<SSOConfigFormContextData>) => {
let err = null;

// Accurately detect if form fields have changed
if (!formFieldsChanged) {
// Don't submit if nothing has changed
// Accurately detect if form fields have changed or there's and error in existing record
let isErrored;
if (formFields?.uuid) {
const ssoRecord =
await LmsApiService.fetchEnterpriseSsoOrchestrationRecord(
formFields?.uuid
).catch(() => {
return { data: {} };
});
Copy link
Member Author

@hamzawaleed01 hamzawaleed01 Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alex-sheehan-edx I just gone reviewed code again, formFields is supposed to have many other attributes given here.

So, can we use any keys from formFields instead of making this separate API call?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated ✅

const { data } = ssoRecord;
isErrored =
data.errored_at &&
data.submitted_at < data.errored_at;
}
if (!isErrored && !formFieldsChanged) {
return formFields;
}
// else, update enterprise SSO record
let updatedFormFields: SSOConfigCamelCase = omit(formFields, ['idpConnectOption', 'spMetadataUrl', 'isPendingConfiguration']);
updatedFormFields.enterpriseCustomer = enterpriseId;
const submittedFormFields: SSOConfigSnakeCase = snakeCaseDict(updatedFormFields) as SSOConfigSnakeCase;
Expand Down
Loading