Skip to content

Commit

Permalink
fix: disable creating new SSO config while configuring prior config (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonkeating authored Nov 7, 2023
1 parent 1f1c1ac commit 179524d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { connect } from 'react-redux';
import LmsApiService from '../../../data/services/LmsApiService';
import NewSSOConfigAlerts from './NewSSOConfigAlerts';
import NewSSOConfigCard from './NewSSOConfigCard';
import { isInProgressConfig } from './utils';

const FRESH_CONFIG_POLLING_INTERVAL = 30000;
const UPDATED_CONFIG_POLLING_INTERVAL = 2000;
Expand Down Expand Up @@ -66,9 +67,7 @@ const NewExistingSSOConfigs = ({

useEffect(() => {
const [active, inactive] = _.partition(configs, config => config.active);
const inProgress = configs.filter(
config => (config.submitted_at && !config.configured_at) || (config.configured_at < config.submitted_at),
);
const inProgress = configs.filter(isInProgressConfig);
const untested = configs.filter(config => !config.validated_at);
const live = configs.filter(
config => (config.validated_at && config.active && config.validated_at > config.configured_at),
Expand Down
6 changes: 5 additions & 1 deletion src/components/settings/SettingsSSOTab/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import NewSSOConfigForm from './NewSSOConfigForm';
import { SSOConfigContext, SSOConfigContextProvider } from './SSOConfigContext';
import LmsApiService from '../../../data/services/LmsApiService';
import { features } from '../../../config';
import { isInProgressConfig } from './utils';

const SettingsSSOTab = ({ enterpriseId, setHasSSOConfig }) => {
const {
Expand Down Expand Up @@ -51,6 +52,8 @@ const SettingsSSOTab = ({ enterpriseId, setHasSSOConfig }) => {
}, [AUTH0_SELF_SERVICE_INTEGRATION, existingConfigs, setHasSSOConfig]);

if (AUTH0_SELF_SERVICE_INTEGRATION) {
const newButtonVisible = existingConfigs?.length > 0 && (providerConfig === null);
const newButtonDisabled = existingConfigs.some(isInProgressConfig);
return (
<div>
<ModalDialog
Expand Down Expand Up @@ -92,11 +95,12 @@ const SettingsSSOTab = ({ enterpriseId, setHasSSOConfig }) => {
<div className="d-flex">
<h2 className="py-2">Single Sign-On (SSO) Integrations</h2>
<div className="mr-0 ml-auto flex-column d-flex">
{existingConfigs?.length > 0 && (providerConfig === null) && (
{newButtonVisible && (
<Button
className="btn btn-outline-primary mb-1"
iconBefore={Add}
onClick={open}
disabled={newButtonDisabled}
>
New
</Button>
Expand Down
9 changes: 8 additions & 1 deletion src/components/settings/SettingsSSOTab/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ function createSAMLURLs({
return { testLink, spMetadataLink };
}

export { updateSamlProviderData, deleteSamlProviderData, createSAMLURLs };
function isInProgressConfig(config) {
return (config.submitted_at && !config.configured_at)
|| config.configured_at < config.submitted_at;
}

export {
updateSamlProviderData, deleteSamlProviderData, createSAMLURLs, isInProgressConfig,
};

0 comments on commit 179524d

Please sign in to comment.