From 0863e93ba1f4d9d20acb6b4ef3934fbc53e8d615 Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Wed, 16 Jun 2021 16:19:45 +0200 Subject: [PATCH] SONAR-14932 Add message for sys admin when no alm are configured yet --- .../project/CreateProjectModeSelection.tsx | 33 +- .../CreateProjectModeSelection-test.tsx | 3 + .../CreateProjectModeSelection-test.tsx.snap | 1088 ++++++++++------- .../resources/org/sonar/l10n/core.properties | 1 + 4 files changed, 665 insertions(+), 460 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx b/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx index 3a9f25b81d8..0fa039eb003 100644 --- a/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx @@ -20,6 +20,7 @@ import * as classNames from 'classnames'; import * as React from 'react'; import ChevronsIcon from 'sonar-ui-common/components/icons/ChevronsIcon'; +import { Alert } from 'sonar-ui-common/components/ui/Alert'; import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n'; import { getBaseUrl } from 'sonar-ui-common/helpers/urls'; import { withAppState } from '../../../components/hoc/withAppState'; @@ -40,7 +41,8 @@ const DEFAULT_ICON_SIZE = 80; function renderAlmOption( props: CreateProjectModeSelectionProps, alm: AlmKeys.Azure | AlmKeys.BitbucketServer | AlmKeys.GitHub | AlmKeys.GitLab, - mode: CreateProjectModes + mode: CreateProjectModes, + last = false ) { const { almCounts, @@ -59,11 +61,11 @@ function renderAlmOption( const disabled = loadingBindings || hasTooManyConfig || (!hasConfig && !canAdmin); return ( -
+
- {renderAlmOption(props, AlmKeys.Azure, CreateProjectModes.AzureDevOps)} - {renderAlmOption(props, AlmKeys.BitbucketServer, CreateProjectModes.BitbucketServer)} - {renderAlmOption(props, AlmKeys.GitHub, CreateProjectModes.GitHub)} - {renderAlmOption(props, AlmKeys.GitLab, CreateProjectModes.GitLab)} +
+
+ {renderAlmOption(props, AlmKeys.Azure, CreateProjectModes.AzureDevOps)} + {renderAlmOption(props, AlmKeys.BitbucketServer, CreateProjectModes.BitbucketServer)} + {renderAlmOption(props, AlmKeys.GitHub, CreateProjectModes.GitHub)} + {renderAlmOption(props, AlmKeys.GitLab, CreateProjectModes.GitLab, true)} +
+ {almTotalCount === 0 && canAdmin && ( + + {translate('onboarding.create_project.select_method.no_alm_yet.admin')} + + )} +
); diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectModeSelection-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectModeSelection-test.tsx index ecd184e7b0b..509bb889374 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectModeSelection-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectModeSelection-test.tsx @@ -45,6 +45,9 @@ it('should render correctly', () => { { [AlmKeys.BitbucketServer]: 0, [AlmKeys.BitbucketCloud]: 0, [AlmKeys.GitHub]: 2 } ) ).toMatchSnapshot('invalid configs, admin'); + expect( + shallowRender({ appState: { canAdmin: true } }, { [AlmKeys.BitbucketServer]: 0 }) + ).toMatchSnapshot('no alm conf yet, admin'); }); it('should correctly pass the selected mode up', () => { diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/CreateProjectModeSelection-test.tsx.snap b/server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/CreateProjectModeSelection-test.tsx.snap index aec9f4cc947..8dcb5b96696 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/CreateProjectModeSelection-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/CreateProjectModeSelection-test.tsx.snap @@ -29,7 +29,7 @@ exports[`should render correctly: default 1`] = ` className="create-project-modes huge-spacer-top display-flex-justify-center" >
-
-

- onboarding.create_project.alm_not_configured -

- - -
-
- - -
-
-

- onboarding.create_project.alm_not_configured -

- - -
-
-

- onboarding.create_project.alm_not_configured -

- + @@ -189,7 +197,7 @@ exports[`should render correctly: invalid configs, admin 1`] = ` className="create-project-modes huge-spacer-top display-flex-justify-center" >
-
- - -
-
- - -
-
-

- onboarding.create_project.too_many_alm_instances_X.alm.github -

- - -
-
- + @@ -329,7 +345,7 @@ exports[`should render correctly: invalid configs, admin 2`] = ` className="create-project-modes huge-spacer-top display-flex-justify-center" >
-
- - -
-
- - -
-
-

- onboarding.create_project.too_many_alm_instances_X.alm.github -

- - -
-
- + @@ -469,7 +493,7 @@ exports[`should render correctly: invalid configs, not admin 1`] = ` className="create-project-modes huge-spacer-top display-flex-justify-center" >
-
-

- onboarding.create_project.alm_not_configured -

- - -
- +
- onboarding.create_project.select_method.bitbucket +
-

- onboarding.create_project.alm_not_configured -

- + + + + + + +`; + +exports[`should render correctly: loading instances 1`] = ` + +
+
+

+ onboarding.create_project.select_method +

+

+ onboarding.create_project.select_method.description1 +

+

+ onboarding.create_project.select_method.description2 +

+
+
+
-
-

- onboarding.create_project.too_many_alm_instances_X.alm.github -

- -
-
- +
- onboarding.create_project.select_method.gitlab +
-

- onboarding.create_project.alm_not_configured -

- + + +
`; -exports[`should render correctly: loading instances 1`] = ` +exports[`should render correctly: no alm conf yet, admin 1`] = `
-
- - onboarding.create_project.check_alm_supported - - - - -
-
- - onboarding.create_project.check_alm_supported - - - - -
-
- - onboarding.create_project.check_alm_supported - - - - -
-
- - onboarding.create_project.check_alm_supported - - - + + + onboarding.create_project.select_method.no_alm_yet.admin + 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 f289417b065..d48356c261b 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -3243,6 +3243,7 @@ onboarding.create_project.setup_manually=Create a project onboarding.create_project.select_method=How do you want to create your project? onboarding.create_project.select_method.description1=Are you just testing or have an advanced use-case? Create a project manually. onboarding.create_project.select_method.description2=Do you want to benefit from all of SonarQube's features (like repository import and Pull Request decoration)? Create your project from your favorite DevOps platform. +onboarding.create_project.select_method.no_alm_yet.admin=We recommend setting up a DevOps platform configuration so you and your team can benefit from more SonarQube features. onboarding.create_project.select_method.manual=Manually onboarding.create_project.select_method.azure=From Azure DevOps onboarding.create_project.select_method.bitbucket=From Bitbucket -- 2.39.5