From 2454e077b1d77d70508dcce6a5b015d4a69f41fa Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Wed, 18 Aug 2021 14:57:22 +0200 Subject: [PATCH] SONAR-15119 Align Azure Pipelines tutorial end with other tutorials --- .../tutorials/TutorialSelectionRenderer.tsx | 1 + .../AzurePipelinesTutorial.tsx | 37 +++--- .../azure-pipelines/SaveAndRunStepContent.tsx | 86 ------------- .../__tests__/AzurePipelinesTutorial-test.tsx | 17 +-- .../__tests__/SaveAndRunStepContent-test.tsx | 37 ------ .../AzurePipelinesTutorial-test.tsx.snap | 115 ++++++++++++++++-- .../SaveAndRunStepContent-test.tsx.snap | 110 ----------------- .../resources/org/sonar/l10n/core.properties | 9 -- 8 files changed, 133 insertions(+), 279 deletions(-) delete mode 100644 server/sonar-web/src/main/js/components/tutorials/azure-pipelines/SaveAndRunStepContent.tsx delete mode 100644 server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/SaveAndRunStepContent-test.tsx delete mode 100644 server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/SaveAndRunStepContent-test.tsx.snap diff --git a/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx b/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx index 173d2ce1e4b..257077294b7 100644 --- a/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx @@ -237,6 +237,7 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender baseUrl={baseUrl} component={component} currentUser={currentUser} + willRefreshAutomatically={willRefreshAutomatically} /> )} diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/AzurePipelinesTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/AzurePipelinesTutorial.tsx index 5bda46d5743..fd794e44f4d 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/AzurePipelinesTutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/AzurePipelinesTutorial.tsx @@ -21,10 +21,11 @@ import * as React from 'react'; import { Button } from 'sonar-ui-common/components/controls/buttons'; import { translate } from 'sonar-ui-common/helpers/l10n'; import { AlmKeys } from '../../../types/alm-settings'; +import AllSetStep from '../components/AllSetStep'; +import FinishButton from '../components/FinishButton'; import Step from '../components/Step'; import BranchAnalysisStepContent from './BranchAnalysisStepContent'; import ExtensionInstallationStepContent from './ExtensionInstallationStepContent'; -import SaveAndRunStepContent from './SaveAndRunStepContent'; import ServiceEndpointStepContent from './ServiceEndpointStepContent'; export interface AzurePipelinesTutorialProps { @@ -32,13 +33,14 @@ export interface AzurePipelinesTutorialProps { baseUrl: string; component: T.Component; currentUser: T.LoggedInUser; + willRefreshAutomatically?: boolean; } export enum Steps { ExtensionInstallation, ServiceEndpoint, BranchAnalysis, - SaveAndRun + AllSet } interface Step { @@ -48,7 +50,7 @@ interface Step { } export default function AzurePipelinesTutorial(props: AzurePipelinesTutorialProps) { - const { alm, baseUrl, component, currentUser } = props; + const { alm, baseUrl, component, currentUser, willRefreshAutomatically } = props; const [currentStep, setCurrentStep] = React.useState(Steps.ExtensionInstallation); const [isCurrentStepValid, setIsCurrentStepValid] = React.useState(false); @@ -74,8 +76,7 @@ export default function AzurePipelinesTutorial(props: AzurePipelinesTutorialProp /> ), checkValidity: true - }, - { step: Steps.SaveAndRun, content: } + } ]; const switchCurrentStep = (step: Steps) => { @@ -83,8 +84,7 @@ export default function AzurePipelinesTutorial(props: AzurePipelinesTutorialProp setIsCurrentStepValid(false); }; - const canContinue = (step: Step, i: number) => - i < steps.length - 1 && (!step.checkValidity || isCurrentStepValid); + const canContinue = (step: Step) => !step.checkValidity || isCurrentStepValid; return ( <> @@ -107,17 +107,26 @@ export default function AzurePipelinesTutorial(props: AzurePipelinesTutorialProp renderForm={() => (
{step.content}
- {canContinue(step, i) && ( - - )} + {canContinue(step) && + (step.step === Steps.BranchAnalysis ? ( + switchCurrentStep(step.step + 1)} /> + ) : ( + + ))}
)} /> ))} + ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/SaveAndRunStepContent.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/SaveAndRunStepContent.tsx deleted file mode 100644 index c07e543c61f..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/SaveAndRunStepContent.tsx +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import * as React from 'react'; -import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n'; -import { getBaseUrl } from '../../../helpers/system'; -import { AlmKeys } from '../../../types/alm-settings'; -import { withAppState } from '../../hoc/withAppState'; - -export interface SaveAndRunStepContentProps { - alm?: AlmKeys; - appState: T.AppState; -} - -export function SaveAndRunStepContent(props: SaveAndRunStepContentProps) { - const { - alm, - appState: { branchesEnabled } - } = props; - return ( - <> -
-
- -
-
-

- - {translate('onboarding.tutorial.with.azure_pipelines.SaveAndRun.commit')} - -

-

- {translate('onboarding.tutorial.with.azure_pipelines.SaveAndRun.commit.why')}{' '} - {branchesEnabled && - alm && - translateWithParameters( - 'onboarding.tutorial.with.azure_pipelines.SaveAndRun.commit.pr_deco', - translate('alm', alm) - )} -

-
-
-
-
- -
-
-

- - {translate('onboarding.tutorial.with.azure_pipelines.SaveAndRun.refresh')} - -

-

{translate('onboarding.tutorial.with.azure_pipelines.SaveAndRun.refresh.why')}

-
-
- - ); -} - -export default withAppState(SaveAndRunStepContent); diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/AzurePipelinesTutorial-test.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/AzurePipelinesTutorial-test.tsx index 0f980af3d37..21c414bd54b 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/AzurePipelinesTutorial-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/AzurePipelinesTutorial-test.tsx @@ -28,18 +28,10 @@ import AzurePipelinesTutorial, { AzurePipelinesTutorialProps } from '../AzurePip it('should render correctly', () => { const wrapper = shallowRender(); expect(wrapper).toMatchSnapshot(); - expect( - wrapper - .find(Step) - .first() - .dive() - ).toMatchSnapshot('first-step-wrapper'); - expect( - wrapper - .find(Step) - .last() - .dive() - ).toMatchSnapshot('last-step-wrapper'); + + wrapper.find(Step).forEach(step => { + expect(step.dive()).toMatchSnapshot(); + }); }); it('should display the next step when one is finished', () => { @@ -97,6 +89,7 @@ function shallowRender(props: Partial = {}) { baseUrl="http://localhost:9000" component={mockComponent()} currentUser={mockLoggedInUser()} + willRefreshAutomatically={true} {...props} /> ); diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/SaveAndRunStepContent-test.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/SaveAndRunStepContent-test.tsx deleted file mode 100644 index b58a2aa6a41..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/SaveAndRunStepContent-test.tsx +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { mockAppState } from '../../../../helpers/testMocks'; -import { AlmKeys } from '../../../../types/alm-settings'; -import { SaveAndRunStepContent, SaveAndRunStepContentProps } from '../SaveAndRunStepContent'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect( - shallowRender({ alm: AlmKeys.Azure, appState: mockAppState({ branchesEnabled: true }) }) - ).toMatchSnapshot('with branches and alm info'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/AzurePipelinesTutorial-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/AzurePipelinesTutorial-test.tsx.snap index 694610a19c5..3a94c11f961 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/AzurePipelinesTutorial-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/AzurePipelinesTutorial-test.tsx.snap @@ -38,19 +38,16 @@ exports[`should render correctly 1`] = ` stepNumber={3} stepTitle="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.title" /> - `; -exports[`should render correctly: first-step-wrapper 1`] = ` +exports[`should render correctly 2`] = `
@@ -86,20 +83,92 @@ exports[`should render correctly: first-step-wrapper 1`] = `
`; -exports[`should render correctly: last-step-wrapper 1`] = ` +exports[`should render correctly 3`] = ` +
+
+ 2 +
+
+

+ onboarding.tutorial.with.azure_pipelines.ServiceEndpoint.title +

+
+
+
+
+
+ +
+ +
+
+
+`; + +exports[`should render correctly 4`] = `
- 4 + 3

- onboarding.tutorial.with.azure_pipelines.SaveAndRun.title + onboarding.tutorial.with.azure_pipelines.BranchAnalysis.title

- +
diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/SaveAndRunStepContent-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/SaveAndRunStepContent-test.tsx.snap deleted file mode 100644 index 0a15051c265..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/SaveAndRunStepContent-test.tsx.snap +++ /dev/null @@ -1,110 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` - -
-
- -
-
-

- - onboarding.tutorial.with.azure_pipelines.SaveAndRun.commit - -

-

- onboarding.tutorial.with.azure_pipelines.SaveAndRun.commit.why - -

-
-
-
-
- -
-
-

- - onboarding.tutorial.with.azure_pipelines.SaveAndRun.refresh - -

-

- onboarding.tutorial.with.azure_pipelines.SaveAndRun.refresh.why -

-
-
-
-`; - -exports[`should render correctly: with branches and alm info 1`] = ` - -
-
- -
-
-

- - onboarding.tutorial.with.azure_pipelines.SaveAndRun.commit - -

-

- onboarding.tutorial.with.azure_pipelines.SaveAndRun.commit.why - - onboarding.tutorial.with.azure_pipelines.SaveAndRun.commit.pr_deco.alm.azure -

-
-
-
-
- -
-
-

- - onboarding.tutorial.with.azure_pipelines.SaveAndRun.refresh - -

-

- onboarding.tutorial.with.azure_pipelines.SaveAndRun.refresh.why -

-
-
-
-`; 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 b7f982039f8..e60300e69bb 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -3900,15 +3900,6 @@ onboarding.tutorial.with.azure_pipelines.BranchAnalysis.continous_integration.no onboarding.tutorial.with.azure_pipelines.BranchAnalysis.continous_integration.no_branches.sentence.continuous_integration=Enable continuous integration onboarding.tutorial.with.azure_pipelines.BranchAnalysis.branch_protection=To make sure your Pull Requests are analyzed automatically and aren't merged when they're failing their quality gate, check out the {link}. onboarding.tutorial.with.azure_pipelines.BranchAnalysis.branch_protection.link=documentation -onboarding.tutorial.with.azure_pipelines.SaveAndRun.title=Save and run your pipeline -onboarding.tutorial.with.azure_pipelines.SaveAndRun.commit=Save your pipeline and push your code to start the analysis -onboarding.tutorial.with.azure_pipelines.SaveAndRun.commit.why=Each new push you make on your branches will trigger a new analysis in SonarQube. -onboarding.tutorial.with.azure_pipelines.SaveAndRun.commit.pr_deco=We will decorate Pull Requests directly on {0} for you. -onboarding.tutorial.with.azure_pipelines.SaveAndRun.refresh=This page will then refresh with your analysis results -onboarding.tutorial.with.azure_pipelines.SaveAndRun.refresh.why=If this page doesn't refresh after a while, please double-check your pipeline configuration. -onboarding.tutorial.with.azure_pipelines.SaveAndRun.then={what} Checkout our {link} to make sure SonarQube analyze and decorate all of your Pull Requests -onboarding.tutorial.with.azure_pipelines.SaveAndRun.then.what=Then what? -onboarding.tutorial.with.azure_pipelines.SaveAndRun.then.link=Azure integration documentation #------------------------------------------------------------------------------ # # BRANCHES -- 2.39.5