]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-19337 Enable GitHub check only when auth config is enabled
authorMathieu Suen <mathieu.suen@sonarsource.com>
Thu, 1 Jun 2023 07:59:06 +0000 (09:59 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 1 Jun 2023 20:02:58 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubConfigurationValidity.tsx
server/sonar-web/src/main/js/apps/settings/components/authentication/hook/useGithubConfiguration.ts
server/sonar-web/src/main/js/apps/settings/components/authentication/queries/identity-provider.ts

index 78eab7a5dc19e4c6c3617870d4a92c9c07546330..efaea7d8616b655bca4f8d7e2773828786f738ca 100644 (file)
@@ -48,7 +48,7 @@ function GitHubConfigurationValidity({ isAutoProvisioning }: Props) {
   const [openDetails, setOpenDetails] = useState(false);
   const [messages, setMessages] = useState<string[]>([]);
   const [alertVariant, setAlertVariant] = useState<AlertVariant>('loading');
-  const { data, isFetching, refetch } = useCheckGitHubConfigQuery();
+  const { data, isFetching, refetch } = useCheckGitHubConfigQuery(true);
   const modalHeader = translate(`${intlPrefix}.details.title`);
 
   const applicationField = isAutoProvisioning ? 'autoProvisioning' : 'jit';
index 7b1d1121478f5bbca416b27e394920fd27d106e7..bd90eec9a9b2e371aeede0067d3a2d7436e43272 100644 (file)
@@ -61,7 +61,6 @@ export default function useGithubConfiguration(definitions: ExtendedSettingDefin
     Feature.GithubProvisioning
   );
   const { data: githubProvisioningStatus } = useGithubStatusQuery();
-  const { refetch } = useCheckGitHubConfigQuery();
   const toggleGithubProvisioning = useToggleGithubProvisioningMutation();
   const [newGithubProvisioningStatus, setNewGithubProvisioningStatus] = useState<boolean>();
   const hasGithubProvisioningConfigChange =
@@ -74,6 +73,7 @@ export default function useGithubConfiguration(definitions: ExtendedSettingDefin
   };
 
   const enabled = values[GITHUB_ENABLED_FIELD]?.value === 'true';
+  const { refetch } = useCheckGitHubConfigQuery(enabled);
   const appId = values[GITHUB_APP_ID_FIELD]?.value as string;
   const url = values[GITHUB_API_URL_FIELD]?.value;
   const clientIdIsNotSet = values[GITHUB_CLIENT_ID_FIELD]?.isNotSet;
index 832a6c54035c9c2e1da0dd5fa1baac8f729cebf4..a5c3bf339ad2b8730f3185a3e6cdf2ed34bd5c8f 100644 (file)
@@ -80,6 +80,8 @@ export function useToggleGithubProvisioningMutation() {
   });
 }
 
-export const useCheckGitHubConfigQuery = () => {
-  return useQuery(['identity_provider', 'github_check'], checkConfigurationValidity);
+export const useCheckGitHubConfigQuery = (githubEnabled: boolean) => {
+  return useQuery(['identity_provider', 'github_check'], checkConfigurationValidity, {
+    enabled: githubEnabled,
+  });
 };