From 800865786cd3acd3c144695f3d4c681965fd7edf Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Thu, 8 Oct 2020 15:47:18 +0200 Subject: [PATCH] SONAR-13834 SONAR-13939 SONAR-13938 Cleanup and update tutorials, remove organizations --- .../tutorials/jenkins/JenkinsfileStep.tsx | 12 +- .../__tests__/JenkinsfileStep-test.tsx | 7 +- .../JenkinsfileStep-test.tsx.snap | 22 +-- .../{MSBuild.tsx => DotNet.tsx} | 12 +- .../{MSBuild-test.tsx => DotNet-test.tsx} | 6 +- ...ild-test.tsx.snap => DotNet-test.tsx.snap} | 8 +- .../tutorials/manual/BuildToolForm.tsx | 88 ++++++++++ .../tutorials/manual/LanguageForm.tsx | 118 -------------- .../tutorials/manual/ManualTutorial.tsx | 37 ++--- .../tutorials/manual/ProjectAnalysisStep.tsx | 70 +++----- ...geForm-test.tsx => BuildToolForm-test.tsx} | 47 +++--- ...t.tsx.snap => BuildToolForm-test.tsx.snap} | 78 +++++---- .../ManualTutorial-test.tsx.snap | 1 - .../manual/commands/AnalysisCommand.tsx | 105 +++--------- .../tutorials/manual/commands/DotNet.tsx | 39 +++-- .../tutorials/manual/commands/JavaGradle.tsx | 36 +++-- .../tutorials/manual/commands/JavaMaven.tsx | 19 +-- .../manual/commands/MSBuildScanner.tsx | 50 ------ .../tutorials/manual/commands/Other.tsx | 43 +++-- .../tutorials/manual/commands/SQScanner.tsx | 53 ------- .../__tests__/AnalysisCommand-test.tsx | 42 +++-- .../manual/commands/__tests__/DotNet-test.tsx | 15 +- .../commands/__tests__/JavaGradle-test.tsx | 9 +- .../commands/__tests__/JavaMaven-test.tsx | 9 +- .../__tests__/MSBuildScanner-test.tsx | 26 --- .../manual/commands/__tests__/Other-test.tsx | 23 ++- .../commands/__tests__/SQScanner-test.tsx | 28 ---- .../AnalysisCommand-test.tsx.snap | 16 +- .../__snapshots__/DotNet-test.tsx.snap | 39 ++++- .../__snapshots__/JavaGradle-test.tsx.snap | 143 +++-------------- .../__snapshots__/JavaMaven-test.tsx.snap | 109 +------------ .../MSBuildScanner-test.tsx.snap | 37 ----- .../__snapshots__/Other-test.tsx.snap | 150 ++++++++++++++---- .../__snapshots__/SQScanner-test.tsx.snap | 118 -------------- .../src/main/js/components/tutorials/types.ts | 21 ++- .../src/main/js/components/tutorials/utils.ts | 15 -- .../helpers/__tests__/almIntegrations-test.ts | 72 --------- .../src/main/js/helpers/almIntegrations.ts | 61 ------- .../resources/org/sonar/l10n/core.properties | 49 +++--- 39 files changed, 590 insertions(+), 1243 deletions(-) rename server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/{MSBuild.tsx => DotNet.tsx} (92%) rename server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/{MSBuild-test.tsx => DotNet-test.tsx} (84%) rename server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/{MSBuild-test.tsx.snap => DotNet-test.tsx.snap} (94%) create mode 100644 server/sonar-web/src/main/js/components/tutorials/manual/BuildToolForm.tsx delete mode 100644 server/sonar-web/src/main/js/components/tutorials/manual/LanguageForm.tsx rename server/sonar-web/src/main/js/components/tutorials/manual/__tests__/{LanguageForm-test.tsx => BuildToolForm-test.tsx} (50%) rename server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/{LanguageForm-test.tsx.snap => BuildToolForm-test.tsx.snap} (51%) delete mode 100644 server/sonar-web/src/main/js/components/tutorials/manual/commands/MSBuildScanner.tsx delete mode 100644 server/sonar-web/src/main/js/components/tutorials/manual/commands/SQScanner.tsx delete mode 100644 server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/MSBuildScanner-test.tsx delete mode 100644 server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/SQScanner-test.tsx delete mode 100644 server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/MSBuildScanner-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/SQScanner-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/helpers/__tests__/almIntegrations-test.ts delete mode 100644 server/sonar-web/src/main/js/helpers/almIntegrations.ts diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsfileStep.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsfileStep.tsx index 7873a2e9f51..761272b087a 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsfileStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsfileStep.tsx @@ -23,9 +23,10 @@ import { getBaseUrl } from 'sonar-ui-common/helpers/urls'; import RenderOptions from '../components/RenderOptions'; import SentenceWithHighlights from '../components/SentenceWithHighlights'; import Step from '../components/Step'; +import { BuildTools } from '../types'; +import DotNet from './buildtool-steps/DotNet'; import Gradle from './buildtool-steps/Gradle'; import Maven from './buildtool-steps/Maven'; -import MSBuild from './buildtool-steps/MSBuild'; import Other from './buildtool-steps/Other'; export interface JenkinsfileStepProps { @@ -33,19 +34,12 @@ export interface JenkinsfileStepProps { open: boolean; } -export enum BuildTools { - Maven = 'maven', - Gradle = 'gradle', - MSBuild = 'msbuild', - Other = 'other' -} - const BUILDTOOL_COMPONENT_MAP: { [x in BuildTools]: React.ComponentType<{ component: T.Component }>; } = { [BuildTools.Maven]: Maven, [BuildTools.Gradle]: Gradle, - [BuildTools.MSBuild]: MSBuild, + [BuildTools.DotNet]: DotNet, [BuildTools.Other]: Other }; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsfileStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsfileStep-test.tsx index d3dc2e7fbe1..5b34e3d0577 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsfileStep-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsfileStep-test.tsx @@ -23,7 +23,8 @@ import * as React from 'react'; import { mockComponent } from '../../../../helpers/testMocks'; import RenderOptions from '../../components/RenderOptions'; import Step from '../../components/Step'; -import JenkinsfileStep, { BuildTools, JenkinsfileStepProps } from '../JenkinsfileStep'; +import { BuildTools } from '../../types'; +import JenkinsfileStep, { JenkinsfileStepProps } from '../JenkinsfileStep'; import { renderStepContent } from '../test-utils'; it('should render correctly', () => { @@ -49,9 +50,9 @@ it('should render correctly for Gradle', () => { expect(renderStepContent(wrapper)).toMatchSnapshot(); }); -it('should render correctly for MSBuild', () => { +it('should render correctly for .NET', () => { const wrapper = shallowRender(); - selectBuildTool(wrapper, BuildTools.MSBuild); + selectBuildTool(wrapper, BuildTools.DotNet); expect(renderStepContent(wrapper)).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsfileStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsfileStep-test.tsx.snap index 2ef32e08297..205d7970239 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsfileStep-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsfileStep-test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`should render correctly for Gradle 1`] = ` +exports[`should render correctly for .NET 1`] = `
@@ -10,7 +10,7 @@ exports[`should render correctly for Gradle 1`] = `
  • onboarding.build
  • - `; -exports[`should render correctly for MSBuild 1`] = ` +exports[`should render correctly for Gradle 1`] = `
    @@ -132,7 +132,7 @@ exports[`should render correctly for MSBuild 1`] = `
  • onboarding.build
  • - `node { } `; -export default function MSBuild({ component }: MSBuildProps) { +export default function DotNet({ component }: DotNetProps) { return (
  • diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/MSBuild-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNet-test.tsx similarity index 84% rename from server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/MSBuild-test.tsx rename to server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNet-test.tsx index a391815e625..44ea736f12e 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/MSBuild-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNet-test.tsx @@ -21,12 +21,12 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { mockComponent } from '../../../../../helpers/testMocks'; -import MSBuild, { MSBuildProps } from '../MSBuild'; +import DotNet, { DotNetProps } from '../DotNet'; it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot(); }); -function shallowRender(props: Partial = {}) { - return shallow(); +function shallowRender(props: Partial = {}) { + return shallow(); } diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/MSBuild-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNet-test.tsx.snap similarity index 94% rename from server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/MSBuild-test.tsx.snap rename to server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNet-test.tsx.snap index 822c34ce98e..60f35c80bab 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/MSBuild-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNet-test.tsx.snap @@ -23,7 +23,7 @@ exports[`should render correctly 1`] = ` "in_jenkins", ] } - translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.replace" + translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.replace" />

    @@ -62,7 +62,7 @@ exports[`should render correctly 1`] = ` "name", ] } - translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help3" + translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help3" />

    diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/BuildToolForm.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/BuildToolForm.tsx new file mode 100644 index 00000000000..934edc0307a --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/manual/BuildToolForm.tsx @@ -0,0 +1,88 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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 RadioToggle from 'sonar-ui-common/components/controls/RadioToggle'; +import { translate } from 'sonar-ui-common/helpers/l10n'; +import RenderOptions from '../components/RenderOptions'; +import { BuildTools, ManualTutorialConfig, OSs } from '../types'; + +interface Props { + component: T.Component; + config?: ManualTutorialConfig; + onDone: (config: ManualTutorialConfig) => void; +} + +interface State { + config: ManualTutorialConfig; +} + +export default class BuildToolForm extends React.PureComponent { + constructor(props: Props) { + super(props); + this.state = { + config: this.props.config || {} + }; + } + + handleBuildToolChange = (buildTool: BuildTools) => { + this.setState({ config: { buildTool } }, () => { + this.props.onDone(this.state.config); + }); + }; + + handleOSChange = (os: OSs) => { + this.setState({ config: { buildTool: BuildTools.Other, os } }, () => { + this.props.onDone(this.state.config); + }); + }; + + render() { + const { config } = this.state; + const buildTools = [BuildTools.Maven, BuildTools.Gradle, BuildTools.DotNet, BuildTools.Other]; + + return ( + <> +
    +

    {translate('onboarding.build')}

    + ({ + label: translate('onboarding.build', tool), + value: tool + }))} + value={config.buildTool} + /> +
    + + {config.buildTool === BuildTools.Other && ( + + )} + + ); + } +} diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/LanguageForm.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/LanguageForm.tsx deleted file mode 100644 index 30701bc194b..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/manual/LanguageForm.tsx +++ /dev/null @@ -1,118 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 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 RadioToggle from 'sonar-ui-common/components/controls/RadioToggle'; -import { translate } from 'sonar-ui-common/helpers/l10n'; -import RenderOptions from '../components/RenderOptions'; -import { LanguageConfig } from '../types'; -import { isLanguageConfigured } from '../utils'; - -interface Props { - component: T.Component; - config?: LanguageConfig; - onDone: (config: LanguageConfig) => void; - onReset: VoidFunction; - organization?: string; -} - -type State = LanguageConfig; - -export interface RenderOSProps { - os: string | undefined; - setOS: (os: string) => void; -} - -export function RenderOS(props: RenderOSProps) { - return ( - - ); -} - -export default class LanguageForm extends React.PureComponent { - constructor(props: Props) { - super(props); - this.state = { - ...(this.props.config || {}), - projectKey: props.component ? props.component.key : undefined - }; - } - - handleChange = () => { - if (isLanguageConfigured(this.state)) { - this.props.onDone(this.state); - } else { - this.props.onReset(); - } - }; - - handleLanguageChange = (language: string) => { - this.setState({ language }, this.handleChange); - }; - - handleJavaBuildChange = (javaBuild: string) => { - this.setState({ javaBuild }, this.handleChange); - }; - - handleOSChange = (os: string) => { - this.setState({ os }, this.handleChange); - }; - - renderJavaBuild = () => ( - - ); - - render() { - const { language } = this.state; - const languages = ['java', 'dotnet', 'other']; - - return ( - <> -
    -

    {translate('onboarding.language')}

    - ({ - label: translate('onboarding.language', language), - value: language - }))} - value={language} - /> -
    - {language === 'java' && this.renderJavaBuild()} - {language === 'other' && } - - ); - } -} diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/ManualTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/ManualTutorial.tsx index 1714244e00e..6a18aee0343 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/ManualTutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/ManualTutorial.tsx @@ -19,7 +19,6 @@ */ import * as React from 'react'; import { translate } from 'sonar-ui-common/helpers/l10n'; -import { isVSTS } from '../../../helpers/almIntegrations'; import InstanceMessage from '../../common/InstanceMessage'; import ProjectAnalysisStep from './ProjectAnalysisStep'; import TokenStep from './TokenStep'; @@ -54,7 +53,6 @@ export default class ManualTutorial extends React.PureComponent { const { component, currentUser } = this.props; const { step, token } = this.state; - const almKey = (component.alm && component.alm.key) || currentUser.externalProvider; return ( <>
    @@ -64,27 +62,22 @@ export default class ManualTutorial extends React.PureComponent {

    - {!isVSTS(almKey) && ( - <> - + - - - )} + ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/ProjectAnalysisStep.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/ProjectAnalysisStep.tsx index c3acaff6ae0..d9c3a170ff6 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/ProjectAnalysisStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/ProjectAnalysisStep.tsx @@ -20,82 +20,48 @@ import * as React from 'react'; import { translate } from 'sonar-ui-common/helpers/l10n'; import Step from '../components/Step'; -import { LanguageConfig } from '../types'; +import { ManualTutorialConfig } from '../types'; +import BuildToolForm from './BuildToolForm'; import AnalysisCommand from './commands/AnalysisCommand'; -import LanguageForm from './LanguageForm'; interface Props { component: T.Component; - displayRowLayout?: boolean; onFinish?: (projectKey?: string) => void; - onReset?: VoidFunction; open: boolean; - organization?: string; stepNumber: number; token?: string; } interface State { - config?: LanguageConfig; -} - -export function getProjectKey(config?: LanguageConfig, component?: T.Component) { - return (component && component.key) || (config && config.projectKey); + config?: ManualTutorialConfig; } export default class ProjectAnalysisStep extends React.PureComponent { state: State = {}; - handleLanguageSelect = (config: LanguageConfig) => { + handleBuildToolSelect = (config: ManualTutorialConfig) => { + const { component } = this.props; this.setState({ config }); if (this.props.onFinish) { - const projectKey = config.language !== 'java' ? getProjectKey(config) : undefined; - this.props.onFinish(projectKey); - } - }; - - handleLanguageReset = () => { - this.setState({ config: undefined }); - if (this.props.onReset) { - this.props.onReset(); + this.props.onFinish(component.key); } }; renderForm = () => { - const languageComponent = ( - - ); - const analysisComponent = this.state.config && ( - - ); - - if (this.props.displayRowLayout) { - return ( -
    -
    - {languageComponent} - {analysisComponent &&
    {analysisComponent}
    } -
    -
    - ); - } - return (
    -
    -
    {languageComponent}
    -
    {analysisComponent}
    +
    + + + {this.state.config && ( +
    + +
    + )}
    ); diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/LanguageForm-test.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/BuildToolForm-test.tsx similarity index 50% rename from server/sonar-web/src/main/js/components/tutorials/manual/__tests__/LanguageForm-test.tsx rename to server/sonar-web/src/main/js/components/tutorials/manual/__tests__/BuildToolForm-test.tsx index 24dd2af27b0..00afbc1c297 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/LanguageForm-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/BuildToolForm-test.tsx @@ -20,37 +20,34 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { mockComponent } from '../../../../helpers/testMocks'; -import LanguageForm from '../LanguageForm'; +import { BuildTools, OSs } from '../../types'; +import BuildToolForm from '../BuildToolForm'; -it('selects java', () => { - const onDone = jest.fn(); - const wrapper = shallow( - +it('renders correctly', () => { + expect(shallowRender()).toMatchSnapshot('default'); + expect(shallowRender().setState({ config: { buildTool: BuildTools.Maven } })).toMatchSnapshot( + 'with "maven" selected' + ); + expect(shallowRender().setState({ config: { buildTool: BuildTools.Other } })).toMatchSnapshot( + 'with "other" selected' ); - - (wrapper.find('RadioToggle').prop('onCheck') as Function)('java'); - wrapper.update(); - expect(wrapper).toMatchSnapshot(); }); -it('selects c#', () => { +it('correctly calls the onDone prop', () => { const onDone = jest.fn(); - const wrapper = shallow( - - ); + const wrapper = shallowRender({ onDone }); - (wrapper.find('RadioToggle').prop('onCheck') as Function)('dotnet'); - wrapper.update(); - expect(wrapper).toMatchSnapshot(); -}); + wrapper.instance().handleBuildToolChange(BuildTools.Gradle); + expect(onDone).toBeCalledWith(expect.objectContaining({ buildTool: BuildTools.Gradle })); -it('selects other', () => { - const onDone = jest.fn(); - const wrapper = shallow( - + wrapper.instance().handleOSChange(OSs.Windows); + expect(onDone).toBeCalledWith( + expect.objectContaining({ os: OSs.Windows, buildTool: BuildTools.Other }) ); - - (wrapper.find('RadioToggle').prop('onCheck') as Function)('other'); - wrapper.update(); - expect(wrapper).toMatchSnapshot(); }); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/LanguageForm-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/BuildToolForm-test.tsx.snap similarity index 51% rename from server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/LanguageForm-test.tsx.snap rename to server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/BuildToolForm-test.tsx.snap index 04745f2597c..756cb8a109c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/LanguageForm-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/BuildToolForm-test.tsx.snap @@ -1,12 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`selects c# 1`] = ` +exports[`renders correctly: default 1`] = `

    - onboarding.language + onboarding.build

    `; -exports[`selects java 1`] = ` +exports[`renders correctly: with "maven" selected 1`] = `

    - onboarding.language + onboarding.build

    -
    `; -exports[`selects other 1`] = ` +exports[`renders correctly: with "other" selected 1`] = `

    - onboarding.language + onboarding.build

    -
    `; diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/ManualTutorial-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/ManualTutorial-test.tsx.snap index 77e51dfb064..09df2c2fe0b 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/ManualTutorial-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/ManualTutorial-test.tsx.snap @@ -59,7 +59,6 @@ exports[`renders correctly: default 1`] = ` "tags": Array [], } } - displayRowLayout={true} open={false} stepNumber={2} /> diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/AnalysisCommand.tsx index dd66db28258..084813bedeb 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/AnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/AnalysisCommand.tsx @@ -19,97 +19,44 @@ */ import * as React from 'react'; import { getHostUrl } from 'sonar-ui-common/helpers/urls'; -import { LanguageConfig } from '../../types'; -import { getProjectKey } from '../ProjectAnalysisStep'; +import { BuildTools, ManualTutorialConfig } from '../../types'; import DotNet from './DotNet'; import JavaGradle from './JavaGradle'; import JavaMaven from './JavaMaven'; import Other from './Other'; -interface Props { - component?: T.Component; - organization?: string; - languageConfig: LanguageConfig; - small?: boolean; +export interface AnalysisCommandProps { + component: T.Component; + languageConfig: ManualTutorialConfig; token?: string; } -export default class AnalysisCommand extends React.PureComponent { - renderCommandForMaven = () => { - const { component, token } = this.props; - if (!token) { - return null; - } - return ( - - ); - }; +export default function AnalysisCommand(props: AnalysisCommandProps) { + const { component, languageConfig, token } = props; - renderCommandForGradle = () => { - const { component, token } = this.props; - if (!token) { - return null; - } - return ( - - ); - }; + if (!token) { + return null; + } - renderCommandForDotNet = () => { - const { component, languageConfig, small, token } = this.props; - const projectKey = getProjectKey(languageConfig, component); - if (!projectKey || !token) { - return null; - } - return ( - - ); - }; + const host = getHostUrl(); + const projectKey = component.key; - renderCommandForOther = () => { - const { component, languageConfig, token } = this.props; - const projectKey = getProjectKey(languageConfig, component); - if (!languageConfig || !projectKey || !languageConfig.os || !token) { - return null; - } - return ( - - ); - }; + switch (languageConfig.buildTool) { + case BuildTools.Maven: + return ; + + case BuildTools.Gradle: + return ; - render() { - const { languageConfig } = this.props; + case BuildTools.DotNet: + return ; - if (languageConfig.language === 'java') { - return languageConfig.javaBuild === 'maven' - ? this.renderCommandForMaven() - : this.renderCommandForGradle(); - } else if (languageConfig.language === 'dotnet') { - return this.renderCommandForDotNet(); - } else { - return this.renderCommandForOther(); - } + case BuildTools.Other: + return languageConfig.os !== undefined ? ( + + ) : null; + + default: + return null; } } diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNet.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNet.tsx index cb69448c200..2b83c0dac53 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNet.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNet.tsx @@ -23,32 +23,47 @@ import { Link } from 'react-router'; import { translate } from 'sonar-ui-common/helpers/l10n'; import CodeSnippet from '../../../common/CodeSnippet'; import InstanceMessage from '../../../common/InstanceMessage'; -import MSBuildScanner from './MSBuildScanner'; -export interface Props { +export interface DotNetProps { host: string; - organization?: string; projectKey: string; - small?: boolean; token: string; } -export default function DotNet(props: Props) { +export default function DotNet(props: DotNetProps) { + const { host, projectKey, token } = props; + const command1 = [ 'SonarScanner.MSBuild.exe begin', - `/k:"${props.projectKey}"`, - props.organization && `/d:sonar.organization="${props.organization}"`, - `/d:sonar.host.url="${props.host}"`, - `/d:sonar.login="${props.token}"` + `/k:"${projectKey}"`, + `/d:sonar.host.url="${host}"`, + `/d:sonar.login="${token}"` ]; const command2 = 'MsBuild.exe /t:Rebuild'; - const command3 = ['SonarScanner.MSBuild.exe end', `/d:sonar.login="${props.token}"`]; + const command3 = ['SonarScanner.MSBuild.exe end', `/d:sonar.login="${token}"`]; return (
    - +
    +

    {translate('onboarding.analysis.msbuild.header')}

    +

    + %PATH% }} + /> +

    +

    + + {translate('download_verb')} + +

    +

    {translate('onboarding.analysis.msbuild.execute')} @@ -58,7 +73,7 @@ export default function DotNet(props: Props) { - +

    +

    + + + {translate('here')} + + ) + }} + /> + +

    {translate('onboarding.analysis.java.gradle.text.2')}

    @@ -78,9 +92,7 @@ export default function JavaGradle(props: Props) { />

    - {props.projectKey - ? translate('onboarding.analysis.auto_refresh_after_analysis') - : translate('onboarding.analysis.browse_url_after_analysis')} + {translate('onboarding.analysis.auto_refresh_after_analysis')}

    ); diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/JavaMaven.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/JavaMaven.tsx index 060b0d3863e..e10ddab9d08 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/JavaMaven.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/JavaMaven.tsx @@ -24,20 +24,19 @@ import { translate } from 'sonar-ui-common/helpers/l10n'; import CodeSnippet from '../../../common/CodeSnippet'; import InstanceMessage from '../../../common/InstanceMessage'; -export interface Props { +export interface JavaMavenProps { host: string; - organization?: string; - projectKey?: string; + projectKey: string; token: string; } -export default function JavaMaven(props: Props) { +export default function JavaMaven(props: JavaMavenProps) { + const { host, projectKey, token } = props; const command = [ 'mvn sonar:sonar', - props.projectKey && `-Dsonar.projectKey=${props.projectKey}`, - props.organization && `-Dsonar.organization=${props.organization}`, - `-Dsonar.host.url=${props.host}`, - `-Dsonar.login=${props.token}` + `-Dsonar.projectKey=${projectKey}`, + `-Dsonar.host.url=${host}`, + `-Dsonar.login=${token}` ]; return ( @@ -61,9 +60,7 @@ export default function JavaMaven(props: Props) { />

    - {props.projectKey - ? translate('onboarding.analysis.auto_refresh_after_analysis') - : translate('onboarding.analysis.browse_url_after_analysis')} + {translate('onboarding.analysis.auto_refresh_after_analysis')}

    ); diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/MSBuildScanner.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/MSBuildScanner.tsx deleted file mode 100644 index f4f4195fd1e..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/MSBuildScanner.tsx +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 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 { FormattedMessage } from 'react-intl'; -import { Link } from 'react-router'; -import { translate } from 'sonar-ui-common/helpers/l10n'; - -interface Props { - className?: string; -} - -export default function MSBuildScanner(props: Props) { - return ( -
    -

    {translate('onboarding.analysis.msbuild.header')}

    -

    - %PATH% }} - /> -

    -

    - - {translate('download_verb')} - -

    -
    - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/Other.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/Other.tsx index 89ac7b6dbae..9ac51191ed3 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/Other.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/Other.tsx @@ -23,31 +23,48 @@ import { Link } from 'react-router'; import { translate } from 'sonar-ui-common/helpers/l10n'; import CodeSnippet from '../../../common/CodeSnippet'; import InstanceMessage from '../../../common/InstanceMessage'; +import { OSs } from '../../types'; import { quote } from '../../utils'; -import SQScanner from './SQScanner'; -export interface Props { +export interface OtherProps { host: string; - organization?: string; - os: string; + os: OSs; projectKey: string; token: string; } -export default function Other(props: Props) { - const q = quote(props.os); +export default function Other(props: OtherProps) { + const { host, os, projectKey, token } = props; + + const q = quote(os); const command = [ - props.os === 'win' ? 'sonar-scanner.bat' : 'sonar-scanner', - '-D' + q(`sonar.projectKey=${props.projectKey}`), - props.organization && '-D' + q(`sonar.organization=${props.organization}`), + os === OSs.Windows ? 'sonar-scanner.bat' : 'sonar-scanner', + '-D' + q(`sonar.projectKey=${projectKey}`), '-D' + q('sonar.sources=.'), - '-D' + q(`sonar.host.url=${props.host}`), - '-D' + q(`sonar.login=${props.token}`) + '-D' + q(`sonar.host.url=${host}`), + '-D' + q(`sonar.login=${token}`) ]; return (
    - +
    +

    {translate('onboarding.analysis.sq_scanner.header', os)}

    +

    + bin, + env_var: {os === OSs.Windows ? '%PATH%' : 'PATH'} + }} + /> +

    +

    + + {translate('download_verb')} + +

    +

    {translate('onboarding.analysis.sq_scanner.execute')} @@ -55,7 +72,7 @@ export default function Other(props: Props) { {transformedMessage =>

    {transformedMessage}

    }
    - +

    -

    - {translate('onboarding.analysis.sq_scanner.header', props.os)} -

    -

    - bin, - env_var: {props.os === 'win' ? '%PATH%' : 'PATH'} - }} - /> -

    -

    - - {translate('download_verb')} - -

    -

    - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/AnalysisCommand-test.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/AnalysisCommand-test.tsx index 6f8c57e4513..0322604ba66 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/AnalysisCommand-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/AnalysisCommand-test.tsx @@ -19,35 +19,31 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; -import AnalysisCommand from '../AnalysisCommand'; +import { mockComponent } from '../../../../../helpers/testMocks'; +import { BuildTools, OSs } from '../../../types'; +import AnalysisCommand, { AnalysisCommandProps } from '../AnalysisCommand'; jest.mock('sonar-ui-common/helpers/urls', () => ({ getHostUrl: () => 'HOST' })); -it('display java command', () => { +it('renders correctly', () => { + expect(shallowRender({ languageConfig: { buildTool: BuildTools.Gradle } })).toMatchSnapshot( + 'gradle' + ); + expect(shallowRender({ languageConfig: { buildTool: BuildTools.Maven } })).toMatchSnapshot( + 'maven' + ); + expect(shallowRender({ languageConfig: { buildTool: BuildTools.DotNet } })).toMatchSnapshot( + '.NET' + ); expect( - getWrapper({ languageConfig: { language: 'java', javaBuild: 'gradle' } }) - ).toMatchSnapshot(); - expect( - getWrapper({ languageConfig: { language: 'java', javaBuild: 'maven' } }) - ).toMatchSnapshot(); -}); - -it('display c# command', () => { - expect( - getWrapper({ languageConfig: { language: 'dotnet', projectKey: 'project-foo' } }) - ).toMatchSnapshot(); -}); - -it('display others command', () => { - expect( - getWrapper({ - languageConfig: { language: 'other', os: 'window', projectKey: 'project-foo' } - }) - ).toMatchSnapshot(); + shallowRender({ languageConfig: { buildTool: BuildTools.Other, os: OSs.Windows } }) + ).toMatchSnapshot('other'); }); -function getWrapper(props = {}) { - return shallow(); +function shallowRender(props: Partial = {}) { + return shallow( + + ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/DotNet-test.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/DotNet-test.tsx index 8f00456d2d4..62a213244f9 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/DotNet-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/DotNet-test.tsx @@ -19,19 +19,8 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; -import DotNet, { Props } from '../DotNet'; +import DotNet from '../DotNet'; it('DotNet renders correctly', () => { - expect(shallowRender).toMatchSnapshot(); - - expect( - shallowRender({ - organization: 'organization', - small: true - }) - ).toMatchSnapshot(); + expect(shallow()).toMatchSnapshot(); }); - -function shallowRender(props: Partial = {}) { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/JavaGradle-test.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/JavaGradle-test.tsx index 0fc13a7dba4..c03f7f0137f 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/JavaGradle-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/JavaGradle-test.tsx @@ -22,14 +22,7 @@ import * as React from 'react'; import JavaGradle from '../JavaGradle'; it('renders correctly', () => { - expect(shallow()).toMatchSnapshot(); expect( - shallow() - ).toMatchSnapshot(); -}); - -it('renders with projectKey', () => { - expect( - shallow() + shallow() ).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/JavaMaven-test.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/JavaMaven-test.tsx index 7304894fd13..3227854fe9f 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/JavaMaven-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/JavaMaven-test.tsx @@ -22,14 +22,7 @@ import * as React from 'react'; import JavaMaven from '../JavaMaven'; it('renders correctly', () => { - expect(shallow()).toMatchSnapshot(); expect( - shallow() - ).toMatchSnapshot(); -}); - -it('renders with projectKey', () => { - expect( - shallow() + shallow() ).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/MSBuildScanner-test.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/MSBuildScanner-test.tsx deleted file mode 100644 index 8da96cd4c40..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/MSBuildScanner-test.tsx +++ /dev/null @@ -1,26 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 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 MSBuildScanner from '../MSBuildScanner'; - -it('renders correctly', () => { - expect(shallow()).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/Other-test.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/Other-test.tsx index f4ab19c816f..696bf503cab 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/Other-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/Other-test.tsx @@ -19,18 +19,17 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; -import Other from '../Other'; +import { OSs } from '../../../types'; +import Other, { OtherProps } from '../Other'; it('renders correctly', () => { - expect( - shallow() - ).toMatchSnapshot(); - - expect( - shallow() - ).toMatchSnapshot(); - - expect( - shallow() - ).toMatchSnapshot(); + expect(shallowRender()).toMatchSnapshot('linux'); + expect(shallowRender({ os: OSs.Windows })).toMatchSnapshot('windows'); + expect(shallowRender({ os: OSs.MacOS })).toMatchSnapshot('macos'); }); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/SQScanner-test.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/SQScanner-test.tsx deleted file mode 100644 index 26a51aea994..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/SQScanner-test.tsx +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 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 SQScanner from '../SQScanner'; - -it('renders correctly', () => { - expect(shallow()).toMatchSnapshot(); - expect(shallow()).toMatchSnapshot(); - expect(shallow()).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap index 6afb09941d0..bb48fe6b885 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap @@ -1,32 +1,34 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`display c# command 1`] = ` +exports[`renders correctly: .NET 1`] = ` `; -exports[`display java command 1`] = ` +exports[`renders correctly: gradle 1`] = ` `; -exports[`display java command 2`] = ` +exports[`renders correctly: maven 1`] = ` `; -exports[`display others command 1`] = ` +exports[`renders correctly: other 1`] = ` `; diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/DotNet-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/DotNet-test.tsx.snap index 855871ad583..50fe953751c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/DotNet-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/DotNet-test.tsx.snap @@ -1,10 +1,40 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`DotNet renders correctly 1`] = `[Function]`; - -exports[`DotNet renders correctly 2`] = ` +exports[`DotNet renders correctly 1`] = `
    - +
    +

    + onboarding.analysis.msbuild.header +

    +

    + + %PATH% + , + } + } + /> +

    +

    + + download_verb + +

    +

    @@ -21,7 +51,6 @@ exports[`DotNet renders correctly 2`] = ` Array [ "SonarScanner.MSBuild.exe begin", "/k:\\"projectKey\\"", - "/d:sonar.organization=\\"organization\\"", "/d:sonar.host.url=\\"host\\"", "/d:sonar.login=\\"token\\"", ] diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/JavaGradle-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/JavaGradle-test.tsx.snap index 9aaa8263e36..a4a67e71781 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/JavaGradle-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/JavaGradle-test.tsx.snap @@ -14,131 +14,33 @@ exports[`renders correctly 1`] = `

    - onboarding.analysis.java.gradle.text.2 -

    - -

    - - onboarding.analysis.java.gradle.docs_link - , - } - } - /> -

    -

    - onboarding.analysis.browse_url_after_analysis -

    -

    -`; - -exports[`renders correctly 2`] = ` -
    -

    - onboarding.analysis.java.gradle.header -

    - - - - -

    - onboarding.analysis.java.gradle.text.2 -

    - -

    - - onboarding.analysis.java.gradle.docs_link - , + + + here + , + } } - } - /> -

    -

    - onboarding.analysis.browse_url_after_analysis + /> +

    -
    -`; - -exports[`renders with projectKey 1`] = ` -
    -

    - onboarding.analysis.java.gradle.header -

    - - - -

    @@ -148,8 +50,7 @@ exports[`renders with projectKey 1`] = ` snippet={ Array [ "./gradlew sonarqube", - "-Dsonar.projectKey=foo", - "-Dsonar.organization=organization", + "-Dsonar.projectKey=projectKey", "-Dsonar.host.url=host", "-Dsonar.login=token", ] diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap index c4e572ed480..6f8bf87db64 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap @@ -18,114 +18,7 @@ exports[`renders correctly 1`] = ` snippet={ Array [ "mvn sonar:sonar", - undefined, - undefined, - "-Dsonar.host.url=host", - "-Dsonar.login=token", - ] - } - /> -

    - - onboarding.analysis.java.maven.docs_link - , - } - } - /> -

    -

    - onboarding.analysis.browse_url_after_analysis -

    -
    -`; - -exports[`renders correctly 2`] = ` -
    -

    - onboarding.analysis.java.maven.header -

    -

    - -

    - -

    - - onboarding.analysis.java.maven.docs_link - , - } - } - /> -

    -

    - onboarding.analysis.browse_url_after_analysis -

    -
    -`; - -exports[`renders with projectKey 1`] = ` -
    -

    - onboarding.analysis.java.maven.header -

    -

    - -

    - -

    - onboarding.analysis.msbuild.header -

    -

    - - %PATH% - , - } - } - /> -

    -

    - - download_verb - -

    -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/Other-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/Other-test.tsx.snap index 6a822115cbf..5b11bd567db 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/Other-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/Other-test.tsx.snap @@ -1,10 +1,43 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`renders correctly 1`] = ` +exports[`renders correctly: linux 1`] = `
    - +
    +

    + onboarding.analysis.sq_scanner.header.linux +

    +

    + + bin + , + "env_var": + PATH + , + } + } + /> +

    +

    + + download_verb + +

    +

    @@ -16,15 +49,14 @@ exports[`renders correctly 1`] = ` @@ -51,11 +83,44 @@ exports[`renders correctly 1`] = `

    `; -exports[`renders correctly 2`] = ` +exports[`renders correctly: macos 1`] = `
    - +
    +

    + onboarding.analysis.sq_scanner.header.mac +

    +

    + + bin + , + "env_var": + PATH + , + } + } + /> +

    +

    + + download_verb + +

    +

    @@ -72,7 +137,6 @@ exports[`renders correctly 2`] = ` Array [ "sonar-scanner", "-Dsonar.projectKey=projectKey", - undefined, "-Dsonar.sources=.", "-Dsonar.host.url=host", "-Dsonar.login=token", @@ -102,11 +166,44 @@ exports[`renders correctly 2`] = `

    `; -exports[`renders correctly 3`] = ` +exports[`renders correctly: windows 1`] = `
    - +
    +

    + onboarding.analysis.sq_scanner.header.win +

    +

    + + bin + , + "env_var": + %PATH% + , + } + } + /> +

    +

    + + download_verb + +

    +

    @@ -118,15 +215,14 @@ exports[`renders correctly 3`] = ` diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/SQScanner-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/SQScanner-test.tsx.snap deleted file mode 100644 index dd388d90562..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/SQScanner-test.tsx.snap +++ /dev/null @@ -1,118 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders correctly 1`] = ` -
    -

    - onboarding.analysis.sq_scanner.header.win -

    -

    - - bin - , - "env_var": - %PATH% - , - } - } - /> -

    -

    - - download_verb - -

    -
    -`; - -exports[`renders correctly 2`] = ` -
    -

    - onboarding.analysis.sq_scanner.header.linux -

    -

    - - bin - , - "env_var": - PATH - , - } - } - /> -

    -

    - - download_verb - -

    -
    -`; - -exports[`renders correctly 3`] = ` -
    -

    - onboarding.analysis.sq_scanner.header.mac -

    -

    - - bin - , - "env_var": - PATH - , - } - } - /> -

    -

    - - download_verb - -

    -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/types.ts b/server/sonar-web/src/main/js/components/tutorials/types.ts index 659d13aac12..80e22751eda 100644 --- a/server/sonar-web/src/main/js/components/tutorials/types.ts +++ b/server/sonar-web/src/main/js/components/tutorials/types.ts @@ -23,10 +23,19 @@ export enum TutorialModes { GitLabCI = 'gitlab-ci' } -export interface LanguageConfig { - language?: string; - javaBuild?: string; - cFamilyCompiler?: string; - os?: string; - projectKey?: string; +export enum BuildTools { + Maven = 'maven', + Gradle = 'gradle', + DotNet = 'dotnet', + Other = 'other' } + +export enum OSs { + Linux = 'linux', + Windows = 'win', + MacOS = 'mac' +} + +export type ManualTutorialConfig = + | { buildTool?: BuildTools.Maven | BuildTools.Gradle | BuildTools.DotNet } + | { buildTool: BuildTools.Other; os?: OSs }; diff --git a/server/sonar-web/src/main/js/components/tutorials/utils.ts b/server/sonar-web/src/main/js/components/tutorials/utils.ts index 7845d0ad666..6b76ec37ee2 100644 --- a/server/sonar-web/src/main/js/components/tutorials/utils.ts +++ b/server/sonar-web/src/main/js/components/tutorials/utils.ts @@ -18,21 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { GithubBindingDefinition, ProjectAlmBindingResponse } from '../../types/alm-settings'; -import { LanguageConfig } from './types'; - -export function isLanguageConfigured(config?: LanguageConfig) { - if (!config) { - return false; - } - const { language, javaBuild, cFamilyCompiler, os, projectKey } = config; - const isJavaConfigured = language === 'java' && javaBuild != null; - const isDotNetConfigured = language === 'dotnet' && projectKey != null; - const isCFamilyConfigured = - language === 'c-family' && (cFamilyCompiler === 'msvc' || os != null) && projectKey != null; - const isOtherConfigured = language === 'other' && projectKey != null; - - return isJavaConfigured || isDotNetConfigured || isCFamilyConfigured || isOtherConfigured; -} export function quote(os: string): (s: string) => string { return os === 'win' ? (s: string) => `"${s}"` : (s: string) => s; diff --git a/server/sonar-web/src/main/js/helpers/__tests__/almIntegrations-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/almIntegrations-test.ts deleted file mode 100644 index 4b2b94a155e..00000000000 --- a/server/sonar-web/src/main/js/helpers/__tests__/almIntegrations-test.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 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 { - getAlmMembersUrl, - getUserAlmKey, - isBitbucket, - isGithub, - isVSTS, - sanitizeAlmId -} from '../almIntegrations'; -import { mockCurrentUser, mockLoggedInUser } from '../testMocks'; - -it('#getAlmMembersUrl', () => { - expect(getAlmMembersUrl('github', 'https://github.com/Foo')).toBe( - 'https://github.com/orgs/Foo/people' - ); - expect(getAlmMembersUrl('bitbucket', 'https://bitbucket.com/Foo/')).toBe( - 'https://bitbucket.com/Foo/profile/members' - ); -}); - -it('#isBitbucket', () => { - expect(isBitbucket('bitbucket')).toBe(true); - expect(isBitbucket('bitbucketcloud')).toBe(true); - expect(isBitbucket('github')).toBe(false); -}); - -it('#isGithub', () => { - expect(isGithub('github')).toBe(true); - expect(isGithub('bitbucket')).toBe(false); -}); - -it('#isVSTS', () => { - expect(isVSTS('microsoft')).toBe(true); - expect(isVSTS('github')).toBe(false); -}); - -it('#sanitizeAlmId', () => { - expect(sanitizeAlmId('bitbucketcloud')).toBe('bitbucket'); - expect(sanitizeAlmId('bitbucket')).toBe('bitbucket'); - expect(sanitizeAlmId('github')).toBe('github'); -}); - -describe('getUserAlmKey', () => { - it('should return sanitized almKey', () => { - expect(getUserAlmKey(mockLoggedInUser({ externalProvider: 'bitbucketcloud' }))).toBe( - 'bitbucket' - ); - }); - - it('should return undefined', () => { - expect(getUserAlmKey(mockCurrentUser())).toBeUndefined(); - expect(getUserAlmKey(mockCurrentUser({ isLoggedIn: undefined }))).toBeUndefined(); - }); -}); diff --git a/server/sonar-web/src/main/js/helpers/almIntegrations.ts b/server/sonar-web/src/main/js/helpers/almIntegrations.ts deleted file mode 100644 index 9b96c94b6fb..00000000000 --- a/server/sonar-web/src/main/js/helpers/almIntegrations.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 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 { isLoggedIn } from './users'; - -export function getAlmMembersUrl(key: string, url: string): string { - if (!url.endsWith('/')) { - url += '/'; - } - if (isGithub(key)) { - return url.replace('github.com/', 'github.com/orgs/') + 'people'; - } - return url + 'profile/members'; -} - -export function getUserAlmKey(user: T.CurrentUser) { - return isLoggedIn(user) && user.externalProvider - ? sanitizeAlmId(user.externalProvider) - : undefined; -} - -export function hasAdvancedALMIntegration(user: T.CurrentUser) { - return ( - isLoggedIn(user) && (isBitbucket(user.externalProvider) || isGithub(user.externalProvider)) - ); -} - -export function isBitbucket(almKey?: string): boolean { - return almKey ? almKey.startsWith('bitbucket') : false; -} - -export function isGithub(almKey?: string): boolean { - return almKey === 'github'; -} - -export function isVSTS(almKey?: string): boolean { - return almKey === 'microsoft'; -} - -export function sanitizeAlmId(almKey: string) { - if (isBitbucket(almKey)) { - return 'bitbucket'; - } - return almKey; -} 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 e74ce293438..de692f182bb 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -87,6 +87,7 @@ from=From global=Global github=GitHub help=Help +here=here hide=Hide inactive=Inactive info=Info @@ -3327,31 +3328,18 @@ onboarding.token.invalid_format=The token you have entered has invalid format. onboarding.analysis.header=Run analysis on your project onboarding.analysis.auto_refresh_after_analysis=Once the analysis is completed, this page will automatically refresh and you will be able to browse the analysis results. -onboarding.analysis.browse_url_after_analysis=Once the analysis is completed, you will be able to browse your project at the URL displayed at the end of the logs. onboarding.build=What is your build technology? onboarding.build.maven=Maven onboarding.build.gradle=Gradle onboarding.build.make=Make -onboarding.build.msbuild=MSBuild +onboarding.build.dotnet=.NET onboarding.build.other=Other (for JS, TS, Go, Python, PHP, ...) -onboarding.language=What is your project's main language? -onboarding.language.header=Which primary language are you using? -onboarding.language.java=Java -onboarding.language.java.build_technology=You are developing primarily in Java: what is your build technology? -onboarding.language.java.build_technology.maven=Maven -onboarding.language.java.build_technology.gradle=Gradle -onboarding.language.dotnet=C# or VB.NET -onboarding.language.c-family=C, C++, Objective-C -onboarding.language.c-family.compiler=Which compiler are you using? -onboarding.language.c-family.compiler.msvc=Microsoft Visual C++ -onboarding.language.c-family.compiler.clang-gcc=Clang or GCC -onboarding.language.other=Other (JS, TS, Go, Python, PHP, ...) -onboarding.language.os=What is your OS? -onboarding.language.os.linux=Linux -onboarding.language.os.win=Windows -onboarding.language.os.mac=macOS +onboarding.build.other.os=What is your OS? +onboarding.build.other.os.linux=Linux +onboarding.build.other.os.win=Windows +onboarding.build.other.os.mac=macOS onboarding.analysis.docs=Please visit the {link} for more details. @@ -3368,6 +3356,7 @@ onboarding.analysis.java.gradle.header=Execute the Scanner for Gradle from your onboarding.analysis.java.gradle.header.ci=Execute the Scanner for Gradle from your CI onboarding.analysis.java.gradle.text.1=Running an analysis with Gradle is straighforward. You just need to declare the {plugin_code} plugin in your {filename} file: onboarding.analysis.java.gradle.text.2=and run the following command: +onboarding.analysis.java.gradle.latest_version=You can find the latest version of the Gradle plugin {link}. onboarding.analysis.java.gradle.docs_link=official documentation of the Scanner for Gradle onboarding.analysis.java.gradle.header.sonarcloud=Execute the Scanner for Gradle from Travis onboarding.analysis.java.gradle.text.1.sonarcloud=Declare the {plugin} plugin in your {file} file: @@ -3530,18 +3519,18 @@ onboarding.tutorial.with.jenkins.jenkinsfile.maven.step3.help2.sentence=The name onboarding.tutorial.with.jenkins.jenkinsfile.maven.step3.help2.sentence.path=Maven > Maven installations onboarding.tutorial.with.jenkins.jenkinsfile.maven.step3.help2.sentence.name=Name onboarding.tutorial.with.jenkins.jenkinsfile.gradle.step2.sentence=Add the following to your {file} file: -onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.replace.sentence=Make sure to replace {default_msbuild} and {default_scanner} with the names you gave to your MSBuild and SonarScanner for MSBuild tools {in_jenkins}. -onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.replace.sentence.default_msbuild=Default MSBuild -onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.replace.sentence.default_scanner=SonarScanner for MSBuild -onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.replace.sentence.in_jenkins=in Jenkins -onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help1.sentence=To get the name of these tools in Jenkins, navigate to {path}. -onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help1.sentence.path=Manage Jenkins > Global Tool Configuration -onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help2.sentence=For your MSBuild tool, the name is located under the {path} section, in the {name} field. -onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help2.sentence.path=MSBuild > MSBuild installations -onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help2.sentence.name=Name -onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help3.sentence=For your SonarScanner for MSBuild tool, the name is located under the {path} section, in the {name} field. -onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help3.sentence.path=SonarScanner for MSBuild > SonarScanner for MSBuild installations -onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help3.sentence.name=Name +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.replace.sentence=Make sure to replace {default_msbuild} and {default_scanner} with the names you gave to your MSBuild and SonarScanner for MSBuild tools {in_jenkins}. +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.replace.sentence.default_msbuild=Default MSBuild +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.replace.sentence.default_scanner=SonarScanner for MSBuild +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.replace.sentence.in_jenkins=in Jenkins +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help1.sentence=To get the name of these tools in Jenkins, navigate to {path}. +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help1.sentence.path=Manage Jenkins > Global Tool Configuration +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help2.sentence=For your MSBuild tool, the name is located under the {path} section, in the {name} field. +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help2.sentence.path=MSBuild > MSBuild installations +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help2.sentence.name=Name +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help3.sentence=For your SonarScanner for MSBuild tool, the name is located under the {path} section, in the {name} field. +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help3.sentence.path=SonarScanner for MSBuild > SonarScanner for MSBuild installations +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help3.sentence.name=Name onboarding.tutorial.with.jenkins.jenkinsfile.other.step2.sentence=Create a {file} file in your repository and paste the following code: onboarding.tutorial.with.jenkins.jenkinsfile.other.step3.replace.sentence=Make sure to replace {default} with the name you gave to your SonarQube Scanner tool {in_jenkins}. onboarding.tutorial.with.jenkins.jenkinsfile.other.step3.replace.sentence.default=SonarScanner -- 2.39.5