]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-14803 Adding bitbucket cloud to create project menu.
authorMathieu Suen <mathieu.suen@sonarsource.com>
Mon, 10 May 2021 13:36:47 +0000 (15:36 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 21 May 2021 20:03:37 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenu.tsx
server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenuItem.tsx
server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCreationMenu-test.tsx
server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx
server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap
server/sonar-web/src/main/js/helpers/constants.ts
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 3e5fa2f6818de15a490360881ae58a6ea11c5c51..7ea8dbc5211040df55bea0e3b8b2ae63e3d723b3 100644 (file)
@@ -42,7 +42,7 @@ interface State {
 const almSettingsValidators = {
   [AlmKeys.Azure]: (settings: AlmSettingsInstance) => !!settings.url,
   [AlmKeys.BitbucketServer]: (_: AlmSettingsInstance) => true,
-  [AlmKeys.BitbucketCloud]: (_: AlmSettingsInstance) => false,
+  [AlmKeys.BitbucketCloud]: (_: AlmSettingsInstance) => true,
   [AlmKeys.GitHub]: (_: AlmSettingsInstance) => true,
   [AlmKeys.GitLab]: (settings: AlmSettingsInstance) => !!settings.url
 };
@@ -86,7 +86,11 @@ export class ProjectCreationMenu extends React.PureComponent<Props, State> {
       } else {
         currentAlmSettings = almSettings.filter(s => s.alm === key);
       }
-      return currentAlmSettings.length === 1 && this.almSettingIsValid(currentAlmSettings[0]);
+      return (
+        currentAlmSettings.length === 1 &&
+        key === currentAlmSettings[0].alm &&
+        this.almSettingIsValid(currentAlmSettings[0])
+      );
     });
 
     if (this.mounted) {
index daf435d9e7547ee03f8d6434c6232fa74824ad8e..6bdc1540b657d57864241d88a4215131c638f822 100644 (file)
@@ -22,6 +22,7 @@ import { Link } from 'react-router';
 import ChevronsIcon from 'sonar-ui-common/components/icons/ChevronsIcon';
 import { translate } from 'sonar-ui-common/helpers/l10n';
 import { getBaseUrl } from 'sonar-ui-common/helpers/urls';
+import { AlmKeys } from '../../../types/alm-settings';
 
 export interface ProjectCreationMenuItemProps {
   alm: string;
@@ -29,6 +30,10 @@ export interface ProjectCreationMenuItemProps {
 
 export default function ProjectCreationMenuItem(props: ProjectCreationMenuItemProps) {
   const { alm } = props;
+  let almIcon = alm;
+  if (alm === AlmKeys.BitbucketCloud) {
+    almIcon = 'bitbucket';
+  }
   return (
     <Link
       className="display-flex-center"
@@ -40,7 +45,7 @@ export default function ProjectCreationMenuItem(props: ProjectCreationMenuItemPr
           alt={alm}
           className="spacer-right"
           width={16}
-          src={`${getBaseUrl()}/images/alm/${alm}.svg`}
+          src={`${getBaseUrl()}/images/alm/${almIcon}.svg`}
         />
       )}
       {translate('my_account.add_project', alm)}
index f2a6a02620454561051335d298f0c79fe65f0db9..7afc40b3af395d11387bd28d0779a1d71f5b8058 100644 (file)
@@ -57,7 +57,6 @@ it('should filter alm bindings appropriately', async () => {
     .mockResolvedValueOnce([
       // Only faulty configs.
       { alm: AlmKeys.Azure }, // Missing some configuration; will be ignored.
-      { alm: AlmKeys.BitbucketCloud }, // Bitbucket Cloud isn't supported.
       { alm: AlmKeys.GitLab } // Missing some configuration; will be ignored.
     ])
     .mockResolvedValueOnce([
@@ -67,6 +66,13 @@ it('should filter alm bindings appropriately', async () => {
       { alm: AlmKeys.GitHub },
       { alm: AlmKeys.GitLab, url: 'gitlab.com' }
     ])
+    .mockResolvedValueOnce([
+      // All correct configs.
+      { alm: AlmKeys.Azure, url: 'http://ado.example.com' },
+      { alm: AlmKeys.BitbucketCloud },
+      { alm: AlmKeys.GitHub },
+      { alm: AlmKeys.GitLab, url: 'gitlab.com' }
+    ])
     .mockResolvedValueOnce([
       // Special case for BBS with BBC
       { alm: AlmKeys.Azure, url: 'http://ado.example.com' },
@@ -100,6 +106,15 @@ it('should filter alm bindings appropriately', async () => {
     AlmKeys.GitLab
   ]);
 
+  wrapper = shallowRender();
+  await waitAndUpdate(wrapper);
+  expect(wrapper.state().boundAlms).toEqual([
+    AlmKeys.Azure,
+    AlmKeys.BitbucketCloud,
+    AlmKeys.GitHub,
+    AlmKeys.GitLab
+  ]);
+
   wrapper = shallowRender();
   await waitAndUpdate(wrapper);
   expect(wrapper.state().boundAlms).toEqual([AlmKeys.Azure, AlmKeys.GitHub, AlmKeys.GitLab]);
index 9f1d81371f9da0a400d9e35c41801540fa71710c..0a8b1aa9c92e637a2509ea5d49ddfd617adfd5b4 100644 (file)
@@ -28,8 +28,8 @@ import DeleteIcon from 'sonar-ui-common/components/icons/DeleteIcon';
 import EditIcon from 'sonar-ui-common/components/icons/EditIcon';
 import { Alert } from 'sonar-ui-common/components/ui/Alert';
 import { translate } from 'sonar-ui-common/helpers/l10n';
-import { getEdition, getEditionUrl } from '../../../../helpers/editions';
 import { IMPORT_COMPATIBLE_ALMS } from '../../../../helpers/constants';
+import { getEdition, getEditionUrl } from '../../../../helpers/editions';
 import {
   AlmBindingDefinition,
   AlmKeys,
@@ -103,6 +103,7 @@ function getPRDecorationFeatureStatus(
 }
 
 function getImportFeatureStatus(
+  alm: AlmKeys,
   definition: AlmBindingDefinition,
   multipleDefinitions: boolean,
   type: AlmSettingsBindingStatusType.Success | AlmSettingsBindingStatusType.Failure
@@ -121,7 +122,7 @@ function getImportFeatureStatus(
     );
   }
 
-  if (!definition.url) {
+  if (!definition.url && alm !== AlmKeys.BitbucketCloud) {
     return (
       <div className="display-inline-flex-center">
         <strong className="spacer-left">
@@ -194,7 +195,7 @@ export default function AlmBindingDefinitionBox(props: AlmBindingDefinitionBoxPr
                       {translate('settings.almintegration.feature.alm_repo_import.title')}
                     </span>
                   </Tooltip>
-                  {getImportFeatureStatus(definition, multipleDefinitions, status.type)}
+                  {getImportFeatureStatus(alm, definition, multipleDefinitions, status.type)}
                 </div>
               )}
             </div>
index 4fce50260a749097e45fd3d83eeaaf783c100bea..50f99f0dc36e485e8a89a1037b9cbb40e87ef4d1 100644 (file)
@@ -332,6 +332,18 @@ exports[`should render correctly: success for Bitbucket Cloud 1`] = `
         className="spacer-left"
       />
     </div>
+    <div>
+      <Tooltip
+        overlay="settings.almintegration.feature.alm_repo_import.description"
+      >
+        <span>
+          settings.almintegration.feature.alm_repo_import.title
+        </span>
+      </Tooltip>
+      <AlertSuccessIcon
+        className="spacer-left"
+      />
+    </div>
   </div>
   <div
     className="width-50"
index 5cfc1f6a4adf5473b584384f852f6dc29f996345..f59638d5ebec6c2c7943724077b6d071a292752a 100644 (file)
@@ -74,6 +74,7 @@ export const ALM_DOCUMENTATION_PATHS = {
 export const IMPORT_COMPATIBLE_ALMS = [
   AlmKeys.Azure,
   AlmKeys.BitbucketServer,
+  AlmKeys.BitbucketCloud,
   AlmKeys.GitHub,
   AlmKeys.GitLab
 ];
index 8c0bf019fd204261b775d58e9d214d6afb68a0a0..311290360f987bc97e42bfdb3de272d81285b887 100644 (file)
@@ -1916,6 +1916,7 @@ my_account.add_project=Add Project
 my_account.add_project.manual=Manually
 my_account.add_project.azure=Azure DevOps
 my_account.add_project.bitbucket=Bitbucket
+my_account.add_project.bitbucketcloud=Bitbucket
 my_account.add_project.github=GitHub
 my_account.add_project.gitlab=GitLab
 my_account.reset_password=Update your password