From 787a44f746f4a933b6c8324905fb6ccc0d2975e6 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Wed, 22 Jul 2020 14:14:13 +0200 Subject: [PATCH] SONAR-13671 Add import feature box to gitlab settings --- .../almIntegration/BitbucketTab.tsx | 2 +- .../components/almIntegration/GithubTab.tsx | 2 +- .../components/almIntegration/GitlabTab.tsx | 30 ++++++++++++++++++- .../__snapshots__/BitbucketTab-test.tsx.snap | 2 +- .../__snapshots__/GitlabTab-test.tsx.snap | 24 +++++++++++++++ .../resources/org/sonar/l10n/core.properties | 6 ++-- 6 files changed, 60 insertions(+), 6 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/BitbucketTab.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/BitbucketTab.tsx index 46a7f3d3548..05010d67d83 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/BitbucketTab.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/BitbucketTab.tsx @@ -78,7 +78,7 @@ export default function BitbucketTab(props: BitbucketTabProps) { active: definitions.length === 1, description: translate('settings.almintegration.feature.alm_repo_import.description'), inactiveReason: translateWithParameters( - 'onboarding.create_project.too_many_bbs_instances_X', + 'settings.almintegration.feature.alm_repo_import.bitbucket.wrong_count_x', definitions.length ) } diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/GithubTab.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/GithubTab.tsx index 0a98795b0dc..82f4298b289 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/GithubTab.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/GithubTab.tsx @@ -119,7 +119,7 @@ export default function GithubTab(props: GithubTabProps) { ) : ( translateWithParameters( - 'settings.almintegration.feature.alm_repo_import.github.too_many_instances_x', + 'settings.almintegration.feature.alm_repo_import.github.wrong_count_x', definitions.length ) ) diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/GitlabTab.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/GitlabTab.tsx index e334f5d398b..9533191c7b3 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/GitlabTab.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/GitlabTab.tsx @@ -18,7 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { translate } from 'sonar-ui-common/helpers/l10n'; +import { FormattedMessage } from 'react-intl'; +import { Alert } from 'sonar-ui-common/components/ui/Alert'; +import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n'; import { createGitlabConfiguration, updateGitlabConfiguration } from '../../../../api/alm-settings'; import { AlmKeys, GitlabBindingDefinition } from '../../../../types/alm-settings'; import { ALM_INTEGRATION } from '../AdditionalCategoryKeys'; @@ -56,6 +58,21 @@ export default function GitlabTab(props: GitlabTabProps) { translate('settings.almintegration.table.column.gitlab.url') ]} additionalColumnsKeys={['url']} + additionalTableInfo={ + + {translate('settings.almintegration.feature.alm_repo_import.title')} + ) + }} + /> + + } alm={AlmKeys.GitLab} createConfiguration={createGitlabConfiguration} defaultBinding={{ key: '', personalAccessToken: '', url: '' }} @@ -66,6 +83,17 @@ export default function GitlabTab(props: GitlabTabProps) { active: definitions.length > 0, description: translate('settings.almintegration.feature.mr_decoration.description'), inactiveReason: translate('settings.almintegration.feature.need_at_least_1_binding') + }, + { + name: translate('settings.almintegration.feature.alm_repo_import.title'), + active: definitions.length === 1, + description: translate( + 'settings.almintegration.feature.alm_repo_import.description' + ), + inactiveReason: translateWithParameters( + 'settings.almintegration.feature.alm_repo_import.gitlab.wrong_count_x', + definitions.length + ) } ]} form={childProps => } diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/BitbucketTab-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/BitbucketTab-test.tsx.snap index c09ac23275d..d86ec2f33cd 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/BitbucketTab-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/BitbucketTab-test.tsx.snap @@ -62,7 +62,7 @@ exports[`should render correctly 1`] = ` Object { "active": true, "description": "settings.almintegration.feature.alm_repo_import.description", - "inactiveReason": "onboarding.create_project.too_many_bbs_instances_X.1", + "inactiveReason": "settings.almintegration.feature.alm_repo_import.bitbucket.wrong_count_x.1", "name": "settings.almintegration.feature.alm_repo_import.title", }, ] diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/GitlabTab-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/GitlabTab-test.tsx.snap index a039ff5b3ee..0337700998b 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/GitlabTab-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/GitlabTab-test.tsx.snap @@ -15,6 +15,24 @@ exports[`should render correctly: with branch support 1`] = ` "url", ] } + additionalTableInfo={ + + + settings.almintegration.feature.alm_repo_import.title + , + } + } + /> + + } alm="gitlab" createConfiguration={[Function]} defaultBinding={ @@ -40,6 +58,12 @@ exports[`should render correctly: with branch support 1`] = ` "inactiveReason": "settings.almintegration.feature.need_at_least_1_binding", "name": "settings.almintegration.feature.mr_decoration.title", }, + Object { + "active": true, + "description": "settings.almintegration.feature.alm_repo_import.description", + "inactiveReason": "settings.almintegration.feature.alm_repo_import.gitlab.wrong_count_x.1", + "name": "settings.almintegration.feature.alm_repo_import.title", + }, ] } form={[Function]} 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 12af10ee67c..e45d4af8035 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1081,10 +1081,12 @@ settings.almintegration.feature.alm_repo_import.title=Import repositories from y settings.almintegration.feature.alm_repo_import.description=Select repositories from your ALM, and import them into SonarQube. settings.almintegration.feature.alm_repo_import.disabled_if_multiple_bbs_instances=Connecting to multiple Bitbucket Server instances will deactivate the {feature} feature. Projects will have to be set up manually. settings.almintegration.feature.alm_repo_import.disabled_if_multiple_github_instances=Connecting to multiple GitHub instances will deactivate the {feature} feature. Projects will have to be set up manually. -settings.almintegration.feature.alm_repo_import.github.too_many_instances_x=You must have exactly 1 GitHub instance configured in order to use this method. You currently have {0}. +settings.almintegration.feature.alm_repo_import.disabled_if_multiple_gitlab_instances=Connecting to multiple GitLab instances will deactivate the {feature} feature. Projects will have to be set up manually. +settings.almintegration.feature.alm_repo_import.bitbucket.wrong_count_x=You must have exactly 1 Bitbucket Server instance configured in order to use this method. You currently have {0}. +settings.almintegration.feature.alm_repo_import.github.wrong_count_x=You must have exactly 1 GitHub instance configured in order to use this method. You currently have {0}. +settings.almintegration.feature.alm_repo_import.gitlab.wrong_count_x=You must have exactly 1 GitLab instance configured in order to use this method. You currently have {0}. settings.almintegration.feature.alm_repo_import.github.requires_fields=Your configured instance must be provided with the App's {clientId} and {clientSecret}. - 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} settings.pr_decoration.binding.title=Pull Request Decoration -- 2.39.5