]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-14058 Add URL to azure config form
authorJeremy Davis <jeremy.davis@sonarsource.com>
Wed, 4 Nov 2020 14:06:42 +0000 (15:06 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 25 Nov 2020 20:06:26 +0000 (20:06 +0000)
server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx
server/sonar-web/src/main/js/apps/settings/components/almIntegration/AzureForm.tsx
server/sonar-web/src/main/js/apps/settings/components/almIntegration/AzureTab.tsx
server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AzureForm-test.tsx
server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap
server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AzureForm-test.tsx.snap
server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AzureTab-test.tsx.snap
server/sonar-web/src/main/js/types/alm-settings.ts
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 74203d53f7045a19a168cac9ba969e4af2febe34..fa55dca833d0658ba8d3e0c7388b062e619d7177 100644 (file)
@@ -57,6 +57,7 @@ const STATUS_ICON = {
 };
 
 function getImportFeatureStatus(
+  definition: AlmBindingDefinition,
   multipleDefinitions: boolean,
   type: AlmSettingsBindingStatusType.Success | AlmSettingsBindingStatusType.Failure
 ) {
@@ -68,7 +69,19 @@ function getImportFeatureStatus(
         </strong>
         <HelpTooltip
           className="little-spacer-left"
-          overlay={translate('settings.almintegration.feature.alm_repo_import.help')}
+          overlay={translate('settings.almintegration.feature.alm_repo_import.disabled.multiple')}
+        />
+      </div>
+    );
+  } else if (!definition.url) {
+    return (
+      <div className="display-inline-flex-center">
+        <strong className="spacer-left">
+          {translate('settings.almintegration.feature.alm_repo_import.disabled')}
+        </strong>
+        <HelpTooltip
+          className="little-spacer-left"
+          overlay={translate('settings.almintegration.feature.alm_repo_import.disabled.no_url')}
         />
       </div>
     );
@@ -111,10 +124,23 @@ export default function AlmBindingDefinitionBox(props: AlmBindingDefinitionBoxPr
       {!VALIDATED_ALMS.includes(alm) && (
         <>
           <div className="display-flex-row spacer-bottom">
-            <Tooltip overlay={importFeatureDescription}>
-              <span>{importFeatureTitle}</span>
-            </Tooltip>
-            <AlertSuccessIcon className="spacer-left" />
+            <div className="huge-spacer-right">
+              <Tooltip overlay={importFeatureDescription}>
+                <span>{importFeatureTitle}</span>
+              </Tooltip>
+              <AlertSuccessIcon className="spacer-left" />
+            </div>
+            <div>
+              <Tooltip
+                overlay={translate('settings.almintegration.feature.alm_repo_import.description')}>
+                <span>{translate('settings.almintegration.feature.alm_repo_import.title')}</span>
+              </Tooltip>
+              {getImportFeatureStatus(
+                definition,
+                multipleDefinitions,
+                AlmSettingsBindingStatusType.Success
+              )}
+            </div>
           </div>
 
           <div className="width-50">
@@ -148,7 +174,7 @@ export default function AlmBindingDefinitionBox(props: AlmBindingDefinitionBoxPr
                       {translate('settings.almintegration.feature.alm_repo_import.title')}
                     </span>
                   </Tooltip>
-                  {getImportFeatureStatus(multipleDefinitions, status.type)}
+                  {getImportFeatureStatus(definition, multipleDefinitions, status.type)}
                 </div>
               </div>
             )}
index fef1218019279981b7b2949f0341add78e6154e5..3ce487298e1e311a965b05f27699efc443778cdf 100644 (file)
@@ -45,6 +45,21 @@ export default function AzureForm(props: AzureFormProps) {
           value={formData.key}
         />
       )}
+      <AlmBindingDefinitionFormField
+        help={
+          <>
+            {translate('settings.almintegration.form.url.azure.help')}
+            <br />
+            <em>https://ado.your-company.com/DefaultCollection</em>
+          </>
+        }
+        id="url.azure"
+        maxLength={2000}
+        onFieldChange={onFieldChange}
+        propKey="url"
+        readOnly={readOnly}
+        value={formData.url || ''}
+      />
       <AlmBindingDefinitionFormField
         help={translate('settings.almintegration.form.personal_access_token.azure.help')}
         id="personal_access_token"
index f6998962796f773a5eedcbf8ee263b835783e03b..55834019bff848f9805731afd6b7128806ff1aa7 100644 (file)
@@ -52,7 +52,7 @@ export default function AzureTab(props: AzureTabProps) {
       <AlmTab
         alm={AlmKeys.Azure}
         createConfiguration={createAzureConfiguration}
-        defaultBinding={{ key: '', personalAccessToken: '' }}
+        defaultBinding={{ key: '', personalAccessToken: '', url: '' }}
         definitions={definitions}
         definitionStatus={definitionStatus}
         form={childProps => <AzureForm {...childProps} />}
index fe4a99102a0bd08623a035a9ec6898b0c6a96eb2..3faea7a6a07dbaa975c8efd4e1ae45b5c27b8ea8 100644 (file)
@@ -23,8 +23,8 @@ import { mockAzureBindingDefinition } from '../../../../../helpers/mocks/alm-set
 import AzureForm, { AzureFormProps } from '../AzureForm';
 
 it('should render correctly', () => {
-  expect(shallowRender()).toMatchSnapshot();
-  expect(shallowRender({ formData: mockAzureBindingDefinition() })).toMatchSnapshot();
+  expect(shallowRender()).toMatchSnapshot('create');
+  expect(shallowRender({ formData: mockAzureBindingDefinition() })).toMatchSnapshot('edit');
 });
 
 function shallowRender(props: Partial<AzureFormProps> = {}) {
index 43bc1bfbc5b7ae3a03991cc4442db361be9004bb..2fd332649c62e76f1779b828a3fc6f65929267bd 100644 (file)
@@ -35,16 +35,42 @@ exports[`should render correctly: Azure DevOps 1`] = `
   <div
     className="display-flex-row spacer-bottom"
   >
-    <Tooltip
-      overlay="settings.almintegration.feature.pr_decoration.description"
+    <div
+      className="huge-spacer-right"
     >
-      <span>
-        settings.almintegration.feature.pr_decoration.title
-      </span>
-    </Tooltip>
-    <AlertSuccessIcon
-      className="spacer-left"
-    />
+      <Tooltip
+        overlay="settings.almintegration.feature.pr_decoration.description"
+      >
+        <span>
+          settings.almintegration.feature.pr_decoration.title
+        </span>
+      </Tooltip>
+      <AlertSuccessIcon
+        className="spacer-left"
+      />
+    </div>
+    <div>
+      <Tooltip
+        overlay="settings.almintegration.feature.alm_repo_import.description"
+      >
+        <span>
+          settings.almintegration.feature.alm_repo_import.title
+        </span>
+      </Tooltip>
+      <div
+        className="display-inline-flex-center"
+      >
+        <strong
+          className="spacer-left"
+        >
+          settings.almintegration.feature.alm_repo_import.disabled
+        </strong>
+        <HelpTooltip
+          className="little-spacer-left"
+          overlay="settings.almintegration.feature.alm_repo_import.disabled.no_url"
+        />
+      </div>
+    </div>
   </div>
   <div
     className="width-50"
index ba43fbcd6547a0df158d57c2ddf97f5208f1a944..99c2341cba2e1272cd346a97caf2461092ca83c4 100644 (file)
@@ -1,6 +1,6 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
-exports[`should render correctly 1`] = `
+exports[`should render correctly: create 1`] = `
 <Fragment>
   <AlmBindingDefinitionFormField
     autoFocus={true}
@@ -10,6 +10,22 @@ exports[`should render correctly 1`] = `
     propKey="key"
     value=""
   />
+  <AlmBindingDefinitionFormField
+    help={
+      <React.Fragment>
+        settings.almintegration.form.url.azure.help
+        <br />
+        <em>
+          https://ado.your-company.com/
+        </em>
+      </React.Fragment>
+    }
+    id="url.azure"
+    maxLength={2000}
+    onFieldChange={[MockFunction]}
+    propKey="url"
+    value=""
+  />
   <AlmBindingDefinitionFormField
     help="settings.almintegration.form.personal_access_token.azure.help"
     id="personal_access_token"
@@ -21,7 +37,7 @@ exports[`should render correctly 1`] = `
 </Fragment>
 `;
 
-exports[`should render correctly 2`] = `
+exports[`should render correctly: edit 1`] = `
 <Fragment>
   <AlmBindingDefinitionFormField
     autoFocus={true}
@@ -31,6 +47,22 @@ exports[`should render correctly 2`] = `
     propKey="key"
     value="key"
   />
+  <AlmBindingDefinitionFormField
+    help={
+      <React.Fragment>
+        settings.almintegration.form.url.azure.help
+        <br />
+        <em>
+          https://ado.your-company.com/
+        </em>
+      </React.Fragment>
+    }
+    id="url.azure"
+    maxLength={2000}
+    onFieldChange={[MockFunction]}
+    propKey="url"
+    value=""
+  />
   <AlmBindingDefinitionFormField
     help="settings.almintegration.form.personal_access_token.azure.help"
     id="personal_access_token"
index 395e569599d2901fb39616a9750e023c3830c404..4f8aeff8b9a80b981e5c46da24924bc705c83f43 100644 (file)
@@ -11,6 +11,7 @@ exports[`should render correctly 1`] = `
       Object {
         "key": "",
         "personalAccessToken": "",
+        "url": "",
       }
     }
     definitionStatus={Object {}}
index 09284f3c8c3ef87cadd4930385c6cf644b817c2a..8ae38c80b9113c817dd860af4fa266bb6257c4b6 100644 (file)
@@ -31,6 +31,7 @@ export interface AlmBindingDefinition {
 
 export interface AzureBindingDefinition extends AlmBindingDefinition {
   personalAccessToken: string;
+  url?: string;
 }
 
 export interface BitbucketBindingDefinition extends AlmBindingDefinition {
index 3ba745437946e041cb0547f7a159118fb1c25848..f8cd9e2d12e4bf76ca9375a63fa2de57807d5f31 100644 (file)
@@ -1073,7 +1073,7 @@ settings.almintegration.check_configuration=Check configuration
 settings.almintegration.checking_configuration=Checking configuration
 settings.almintegration.configuration_valid=Configuration valid
 settings.almintegration.could_not_validate=Could not validate this configuration.
-settings.almintegration.no_validation=Pull Request decoration is enabled. However, SonarQube doesn't currently validate Azure DevOps Server configurations.
+settings.almintegration.no_validation=SonarQube doesn't currently validate Azure DevOps Server configurations.
 settings.almintegration.delete.header=Delete configuration
 settings.almintegration.delete.message=Are you sure you want to delete the {id} configuration?
 settings.almintegration.delete.info={0} projects will no longer get Pull Request Decorations.
@@ -1089,6 +1089,8 @@ settings.almintegration.form.name.github=Configuration name
 settings.almintegration.form.name.github.help=Give your configuration a clear and succinct name. This name will be used at project level to identify the correct configured GitHub App for a project.
 settings.almintegration.form.name.gitlab=Configuration name
 settings.almintegration.form.name.gitlab.help=Give your configuration a clear and succinct name. This name will be used at project level to identify the correct configured GitLab instance for a project.
+settings.almintegration.form.url.azure=Azure DevOps Server collection URL
+settings.almintegration.form.url.azure.help=Provide the full Azure DevOps Server collection URL. For example:
 settings.almintegration.form.url.bitbucket=Bitbucket Server URL
 settings.almintegration.form.url.bitbucket.help=Example: {example}
 settings.almintegration.form.url.github=GitHub API URL
@@ -1112,7 +1114,8 @@ settings.almintegration.feature.mr_decoration.description=Add analysis and a Qua
 settings.almintegration.feature.alm_repo_import.title=Import repositories from your ALM
 settings.almintegration.feature.alm_repo_import.description=Select repositories from your ALM, and import them into SonarQube.
 settings.almintegration.feature.alm_repo_import.disabled=Disabled
-settings.almintegration.feature.alm_repo_import.help=This feature is disabled because you have 2 or more integration instances configured.
+settings.almintegration.feature.alm_repo_import.disabled.multiple=This feature is disabled because you have 2 or more integration instances configured.
+settings.almintegration.feature.alm_repo_import.disabled.no_url=This feature is disabled because your configured instance has no URL.
 
 settings.pr_decoration.binding.category=Pull Request Decoration
 settings.pr_decoration.binding.no_bindings=This feature must first be enabled in the global settings. {link}