From: Mathieu Suen Date: Mon, 10 May 2021 13:36:47 +0000 (+0200) Subject: SONAR-14803 Adding bitbucket cloud to create project menu. X-Git-Tag: 9.0.0.45539~168 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=be8b3d7aa7efccf0a7b8c6f650acfca069450484;p=sonarqube.git SONAR-14803 Adding bitbucket cloud to create project menu. --- diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenu.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenu.tsx index 3e5fa2f6818..7ea8dbc5211 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenu.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenu.tsx @@ -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 { } 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) { diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenuItem.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenuItem.tsx index daf435d9e75..6bdc1540b65 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenuItem.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenuItem.tsx @@ -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 ( )} {translate('my_account.add_project', alm)} diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCreationMenu-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCreationMenu-test.tsx index f2a6a026204..7afc40b3af3 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCreationMenu-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCreationMenu-test.tsx @@ -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]); diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx index 9f1d81371f9..0a8b1aa9c92 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx @@ -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 (
@@ -194,7 +195,7 @@ export default function AlmBindingDefinitionBox(props: AlmBindingDefinitionBoxPr {translate('settings.almintegration.feature.alm_repo_import.title')} - {getImportFeatureStatus(definition, multipleDefinitions, status.type)} + {getImportFeatureStatus(alm, definition, multipleDefinitions, status.type)}
)} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap index 4fce50260a7..50f99f0dc36 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap @@ -332,6 +332,18 @@ exports[`should render correctly: success for Bitbucket Cloud 1`] = ` className="spacer-left" /> +
+ + + settings.almintegration.feature.alm_repo_import.title + + + +