Skip to content

Commit

Permalink
fix: hit updateEnterpriseSsoOrchestrationRecord if errore
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzawaleed01 committed Mar 11, 2024
1 parent 853c8e3 commit 5de18f9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ const NewExistingSSOConfigs = ({
);
const untested = res.data.filter(config => !config.validated_at || config.validated_at < config.configured_at);
const timedOut = res.data.filter(checkTimedOut);
const errored = res.data.filter(checkErrored);
if (timedOut.length >= 1) {
const errored = res.data.filter(checkErrored);

Check failure on line 164 in src/components/settings/SettingsSSOTab/NewExistingSSOConfigs.jsx

View workflow job for this annotation

GitHub Actions / tests

Trailing spaces not allowed
if (timedOut.length >= 1) {

Check failure on line 165 in src/components/settings/SettingsSSOTab/NewExistingSSOConfigs.jsx

View workflow job for this annotation

GitHub Actions / tests

Trailing spaces not allowed
setTimedOutConfigs(timedOut);
}

Expand Down
20 changes: 17 additions & 3 deletions src/components/settings/SettingsSSOTab/SSOFormWorkflowConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,25 @@ 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: {} };
});
const { data } = ssoRecord;
isErrored =
data.errored_at &&
data.uuid == formFields?.uuid &&
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

0 comments on commit 5de18f9

Please sign in to comment.