diff options
author | Mathieu Suen <mathieu.suen@sonarsource.com> | 2021-05-10 15:36:47 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-05-21 20:03:37 +0000 |
commit | be8b3d7aa7efccf0a7b8c6f650acfca069450484 (patch) | |
tree | 08d34ac980e00fba2ee9f0a44b8345aa8f49a296 | |
parent | 8e4eb316ef602ec28ee7a707adcaa05836b9f780 (diff) | |
download | sonarqube-be8b3d7aa7efccf0a7b8c6f650acfca069450484.tar.gz sonarqube-be8b3d7aa7efccf0a7b8c6f650acfca069450484.zip |
SONAR-14803 Adding bitbucket cloud to create project menu.
7 files changed, 46 insertions, 7 deletions
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<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) { 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 ( <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)} 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([ @@ -68,6 +67,13 @@ it('should filter alm bindings appropriately', async () => { { 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' }, { alm: AlmKeys.BitbucketServer, url: 'b1' }, @@ -102,6 +108,15 @@ it('should filter alm bindings appropriately', async () => { 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]); wrapper = shallowRender(); 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 ( <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> 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" /> </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" diff --git a/server/sonar-web/src/main/js/helpers/constants.ts b/server/sonar-web/src/main/js/helpers/constants.ts index 5cfc1f6a4ad..f59638d5ebe 100644 --- a/server/sonar-web/src/main/js/helpers/constants.ts +++ b/server/sonar-web/src/main/js/helpers/constants.ts @@ -74,6 +74,7 @@ export const ALM_DOCUMENTATION_PATHS = { export const IMPORT_COMPATIBLE_ALMS = [ AlmKeys.Azure, AlmKeys.BitbucketServer, + AlmKeys.BitbucketCloud, AlmKeys.GitHub, AlmKeys.GitLab ]; diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 8c0bf019fd2..311290360f9 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -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 |