]> source.dussan.org Git - sonarqube.git/commitdiff
[No-JIRA] Fix provisioning validation mechanism
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Thu, 29 Jun 2023 13:31:16 +0000 (15:31 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 30 Jun 2023 20:03:14 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/settings/components/authentication/GithubAuthenticationTab.tsx
server/sonar-web/src/main/js/apps/settings/components/authentication/SamlAuthenticationTab.tsx
server/sonar-web/src/main/js/apps/settings/components/authentication/hook/useGithubConfiguration.ts
server/sonar-web/src/main/js/apps/settings/components/authentication/hook/useSamlConfiguration.ts

index a6814babf7c09a732e1a812b68931fb8a514fe2d..7eb384a9bb08868d2abadd5d10b079d3ab68892f 100644 (file)
@@ -68,6 +68,7 @@ export default function GithubAuthenticationTab(props: GithubAuthenticationProps
     enabled,
     newGithubProvisioningStatus,
     setNewGithubProvisioningStatus,
+    hasGithubProvisioningTypeChange,
     hasGithubProvisioningConfigChange,
     resetJitSetting,
     saveGroup,
@@ -165,7 +166,7 @@ export default function GithubAuthenticationTab(props: GithubAuthenticationProps
             <form
               onSubmit={async (e) => {
                 e.preventDefault();
-                if (newGithubProvisioningStatus !== githubProvisioningStatus) {
+                if (hasGithubProvisioningTypeChange) {
                   setShowConfirmProvisioningModal(true);
                 } else {
                   await saveGroup();
index f51e9f893c33a0032e1b73bd4bd307d5b0b6ee3b..edc40991d95275174c2db92678f78d18c3772679 100644 (file)
@@ -68,6 +68,7 @@ export default function SamlAuthenticationTab(props: SamlAuthenticationProps) {
     values,
     setNewValue,
     canBeSave,
+    hasScimTypeChange,
     hasScimConfigChange,
     newScimStatus,
     setNewScimStatus,
@@ -174,7 +175,7 @@ export default function SamlAuthenticationTab(props: SamlAuthenticationProps) {
             <form
               onSubmit={(e) => {
                 e.preventDefault();
-                if (newScimStatus !== scimStatus) {
+                if (hasScimTypeChange) {
                   setShowConfirmProvisioningModal(true);
                 } else {
                   handleSaveGroup();
index 384dfbf8c484a02860918d17cb1915f606b26cc7..b335b41f9edb465e8116dd6f33fd15cd71b8dfc0 100644 (file)
@@ -62,10 +62,11 @@ export default function useGithubConfiguration(definitions: ExtendedSettingDefin
   const { data: githubProvisioningStatus } = useGithubStatusQuery();
   const toggleGithubProvisioning = useToggleGithubProvisioningMutation();
   const [newGithubProvisioningStatus, setNewGithubProvisioningStatus] = useState<boolean>();
+  const hasGithubProvisioningTypeChange =
+    newGithubProvisioningStatus !== undefined &&
+    newGithubProvisioningStatus !== githubProvisioningStatus;
   const hasGithubProvisioningConfigChange =
-    some(GITHUB_JIT_FIELDS, isValueChange) ||
-    (newGithubProvisioningStatus !== undefined &&
-      newGithubProvisioningStatus !== githubProvisioningStatus);
+    some(GITHUB_JIT_FIELDS, isValueChange) || hasGithubProvisioningTypeChange;
 
   const resetJitSetting = () => {
     GITHUB_JIT_FIELDS.forEach((s) => setNewValue(s));
@@ -80,7 +81,7 @@ export default function useGithubConfiguration(definitions: ExtendedSettingDefin
   const clientIdIsNotSet = values[GITHUB_CLIENT_ID_FIELD]?.isNotSet;
 
   const changeProvisioning = async () => {
-    if (newGithubProvisioningStatus !== githubProvisioningStatus) {
+    if (hasGithubProvisioningTypeChange) {
       await toggleGithubProvisioning.mutateAsync(!!newGithubProvisioningStatus);
     }
     if (!newGithubProvisioningStatus || !githubProvisioningStatus) {
@@ -109,6 +110,7 @@ export default function useGithubConfiguration(definitions: ExtendedSettingDefin
     githubProvisioningStatus,
     newGithubProvisioningStatus,
     setNewGithubProvisioningStatus,
+    hasGithubProvisioningTypeChange,
     hasGithubProvisioningConfigChange,
     changeProvisioning,
     saveGroup,
index d80ffeeda92f737826d5f927fd79498b54f5df72..47b2a9c5207b3509e9688a15d09f429294431208 100644 (file)
@@ -56,8 +56,8 @@ export default function useSamlConfiguration(definitions: ExtendedSettingDefinit
     setNewValue(SAML_GROUP_NAME, value);
   };
 
-  const hasScimConfigChange =
-    isValueChange(SAML_GROUP_NAME) || (newScimStatus !== undefined && newScimStatus !== scimStatus);
+  const hasScimTypeChange = newScimStatus !== undefined && newScimStatus !== scimStatus;
+  const hasScimConfigChange = isValueChange(SAML_GROUP_NAME) || hasScimTypeChange;
 
   return {
     ...config,
@@ -69,6 +69,7 @@ export default function useSamlConfiguration(definitions: ExtendedSettingDefinit
     groupValue,
     values,
     setNewValue,
+    hasScimTypeChange,
     hasScimConfigChange,
     newScimStatus,
     setNewScimStatus,