From 2dc324697c80d6eb5748a14ab17307430321ce8a Mon Sep 17 00:00:00 2001
From: Philippe Perrin
Date: Tue, 15 Jun 2021 11:36:38 +0200
Subject: [PATCH] SONAR-14932 Improve design for non-admin users
---
.../project/CreateProjectModeSelection.tsx | 69 +--
.../apps/create/project/CreateProjectPage.tsx | 2 +-
.../CreateProjectModeSelection-test.tsx | 8 +-
.../CreateProjectModeSelection-test.tsx.snap | 442 +++++++++---------
.../CreateProjectPage-test.tsx.snap | 12 +-
.../src/main/js/apps/create/project/style.css | 4 +
.../resources/org/sonar/l10n/core.properties | 20 +-
7 files changed, 275 insertions(+), 282 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 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')}
+
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`] = `
+
+
+
+
+
+
+
+
+
@@ -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
+
+