Skip to content

Commit

Permalink
Merge pull request #1183 from openedx/hamza/ENT-8510
Browse files Browse the repository at this point in the history
[ENT-8510] - fix: SSO tool not updating SSO records if no form fields are changed
  • Loading branch information
hamzawaleed01 authored Mar 15, 2024
2 parents 1e206ee + fc7f0a6 commit 1ea9233
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/components/settings/SettingsSSOTab/SSOFormWorkflowConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export type SSOConfigCamelCase = {
submittedAt: null,
configuredAt: null,
validatedAt: null,
erroredAt: null,
odataApiTimeoutInterval: null,
odataApiRootUrl: string,
odataCompanyId: string,
Expand Down Expand Up @@ -105,11 +106,18 @@ 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) {
isErrored =
formFields.erroredAt &&
formFields.submittedAt &&
formFields.submittedAt < formFields.erroredAt;
}
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

0 comments on commit 1ea9233

Please sign in to comment.