From: Philippe Perrin Date: Tue, 15 Jun 2021 09:36:38 +0000 (+0200) Subject: SONAR-14932 Improve design for non-admin users X-Git-Tag: 9.0.0.45539~44 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2dc324697c80d6eb5748a14ab17307430321ce8a;p=sonarqube.git SONAR-14932 Improve design for non-admin users --- 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 35a73fadf1a..3a9f25b81d8 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 @@ -22,11 +22,8 @@ import * as React from 'react'; import ChevronsIcon from 'sonar-ui-common/components/icons/ChevronsIcon'; import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n'; import { getBaseUrl } from 'sonar-ui-common/helpers/urls'; -import DocumentationTooltip from '../../../components/common/DocumentationTooltip'; import { withAppState } from '../../../components/hoc/withAppState'; -import { ALM_DOCUMENTATION_PATHS } from '../../../helpers/constants'; import { AlmKeys } from '../../../types/alm-settings'; -import { ALM_INTEGRATION } from '../../settings/components/AdditionalCategoryKeys'; import { CreateProjectModes } from './types'; export interface CreateProjectModeSelectionProps { @@ -57,28 +54,9 @@ function renderAlmOption( const count = isBitbucket ? almCounts[AlmKeys.BitbucketServer] + almCounts[AlmKeys.BitbucketCloud] : almCounts[alm]; - const disabled = count !== 1 || loadingBindings; - - const tooltipLinks = []; - if (count === 0) { - if (canAdmin) { - tooltipLinks.push({ - href: `/admin/settings?category=${ALM_INTEGRATION}&alm=${alm}`, - label: translateWithParameters( - 'onboarding.create_project.set_up_x', - translate('alm', alm, 'short') - ) - }); - } - - tooltipLinks.push({ - href: ALM_DOCUMENTATION_PATHS[alm], - label: translateWithParameters( - 'onboarding.create_project.help_set_up_x', - translate('alm', alm, 'short') - ) - }); - } + const hasConfig = count > 0; + const hasTooManyConfig = count > 1; + const disabled = loadingBindings || hasTooManyConfig || (!hasConfig && !canAdmin); return (
@@ -111,22 +89,14 @@ function renderAlmOption( )} {!loadingBindings && disabled && ( -
- {translate('onboarding.create_project.alm_not_configured')} - -
+

+ {!hasConfig && translate('onboarding.create_project.alm_not_configured')} + {hasTooManyConfig && + translateWithParameters( + 'onboarding.create_project.too_many_alm_instances_X', + translate('alm', alm) + )} +

)}
@@ -136,11 +106,18 @@ function renderAlmOption( export function CreateProjectModeSelection(props: CreateProjectModeSelectionProps) { return ( <> -
-

- {translate('my_account.create_new.TRK')} -

-

{translate('onboarding.create_project.select_method')}

+
+
+

+ {translate('onboarding.create_project.select_method')} +

+

+ {translate('onboarding.create_project.select_method.description1')} +

+

+ {translate('onboarding.create_project.select_method.description2')} +

+
diff --git a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx index 37ec6bd4ef2..ee9704aad80 100644 --- a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx @@ -211,7 +211,7 @@ export class CreateProjectPage extends React.PureComponent { return ( <> - +
{this.renderForm(mode)} 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 5af2ea20fab..ecd184e7b0b 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 @@ -28,8 +28,8 @@ import { import { CreateProjectModes } from '../types'; it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); expect(shallowRender({ loadingBindings: true })).toMatchSnapshot('loading instances'); + expect(shallowRender()).toMatchSnapshot('default'); expect(shallowRender({}, { [AlmKeys.BitbucketServer]: 0, [AlmKeys.GitHub]: 2 })).toMatchSnapshot( 'invalid configs, not admin' ); @@ -39,6 +39,12 @@ it('should render correctly', () => { { [AlmKeys.BitbucketServer]: 0, [AlmKeys.GitHub]: 2 } ) ).toMatchSnapshot('invalid configs, admin'); + expect( + shallowRender( + { appState: { canAdmin: true } }, + { [AlmKeys.BitbucketServer]: 0, [AlmKeys.BitbucketCloud]: 0, [AlmKeys.GitHub]: 2 } + ) + ).toMatchSnapshot('invalid configs, 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 7ecb4dff98e..aec9f4cc947 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 @@ -3,18 +3,27 @@ exports[`should render correctly: default 1`] = `
-

- my_account.create_new.TRK -

-

- onboarding.create_project.select_method -

+

+ onboarding.create_project.select_method +

+

+ onboarding.create_project.select_method.description1 +

+

+ onboarding.create_project.select_method.description2 +

+
onboarding.create_project.select_method.azure
-
onboarding.create_project.alm_not_configured - -
+

onboarding.create_project.select_method.github
-
onboarding.create_project.alm_not_configured - -
+

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

@@ -190,18 +163,27 @@ exports[`should render correctly: default 1`] = ` exports[`should render correctly: invalid configs, admin 1`] = `
-

- my_account.create_new.TRK -

-

- onboarding.create_project.select_method -

+

+ onboarding.create_project.select_method +

+

+ onboarding.create_project.select_method.description1 +

+

+ onboarding.create_project.select_method.description2 +

+
+ + +
+
@@ -279,14 +256,14 @@ exports[`should render correctly: invalid configs, admin 1`] = `
- onboarding.create_project.select_method.bitbucket + onboarding.create_project.select_method.github
-
- onboarding.create_project.alm_not_configured - + onboarding.create_project.too_many_alm_instances_X.alm.github +

+ +
+
+ +
+ +
+`; + +exports[`should render correctly: invalid configs, admin 2`] = ` + +
+
+

+ onboarding.create_project.select_method +

+

+ onboarding.create_project.select_method.description1 +

+

+ onboarding.create_project.select_method.description2 +

+
+
+
+ +
+ +
+
+
@@ -333,7 +403,7 @@ exports[`should render correctly: invalid configs, admin 1`] = ` > onboarding.create_project.select_method.github
-
- onboarding.create_project.alm_not_configured - -
+ onboarding.create_project.too_many_alm_instances_X.alm.github +

-
- onboarding.create_project.alm_not_configured - -
@@ -404,18 +443,27 @@ exports[`should render correctly: invalid configs, admin 1`] = ` exports[`should render correctly: invalid configs, not admin 1`] = `
-

- my_account.create_new.TRK -

-

- onboarding.create_project.select_method -

+

+ onboarding.create_project.select_method +

+

+ onboarding.create_project.select_method.description1 +

+

+ onboarding.create_project.select_method.description2 +

+
onboarding.create_project.select_method.azure
-
onboarding.create_project.alm_not_configured - -
+

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

onboarding.create_project.select_method.github
-
- onboarding.create_project.alm_not_configured - -
+ onboarding.create_project.too_many_alm_instances_X.alm.github +

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

@@ -606,18 +613,27 @@ exports[`should render correctly: invalid configs, not admin 1`] = ` exports[`should render correctly: loading instances 1`] = `
-

- my_account.create_new.TRK -

-

- onboarding.create_project.select_method -

+

+ onboarding.create_project.select_method +

+

+ onboarding.create_project.select_method.description1 +

+

+ onboarding.create_project.select_method.description2 +

+