From: Mathieu Suen Date: Fri, 4 Jun 2021 14:57:22 +0000 (+0200) Subject: SONAR-14893 Adding Bitbucket pipline tutorial X-Git-Tag: 9.0.0.45539~131 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3dfbc3a323b0cdf77a082b3522f230736f717165;p=sonarqube.git SONAR-14893 Adding Bitbucket pipline tutorial --- 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 e2d2afbf34d..b724e53b3b6 100644 --- a/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx @@ -22,6 +22,7 @@ import { translate } from 'sonar-ui-common/helpers/l10n'; import { getBaseUrl } from 'sonar-ui-common/helpers/urls'; import { AlmKeys, AlmSettingsInstance, ProjectAlmBindingResponse } from '../../types/alm-settings'; import AzurePipelinesTutorial from './azure-pipelines/AzurePipelinesTutorial'; +import BitbucketPipelinesTutorial from './bitbucket-pipelines/BitbucketPipelinesTutorial'; import GitHubActionTutorial from './github-action/GitHubActionTutorial'; import GitLabCITutorial from './gitlabci/GitLabCITutorial'; import JenkinsTutorial from './jenkins/JenkinsTutorial'; @@ -120,6 +121,22 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender )} + {projectBinding?.alm === AlmKeys.BitbucketCloud && ( + + )} + {jenkinsAvailable && ( + + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/AnalysisCommand-test.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/AnalysisCommand-test.tsx new file mode 100644 index 00000000000..fe163ec5ba7 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/AnalysisCommand-test.tsx @@ -0,0 +1,45 @@ +/* + * 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, mockComponent } from '../../../../helpers/testMocks'; +import { BuildTools } from '../../types'; +import { AnalysisCommand, AnalysisCommandProps } from '../AnalysisCommand'; + +it.each([[BuildTools.DotNet], [BuildTools.Gradle], [BuildTools.Maven], [BuildTools.Other]])( + 'should render correctly for %s', + buildTool => { + expect(shallowRender({ buildTool })).toMatchSnapshot(); + expect( + shallowRender({ appState: mockAppState({ branchesEnabled: true }), buildTool }) + ).toMatchSnapshot('with branch enabled'); + } +); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx new file mode 100644 index 00000000000..655744180b6 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx @@ -0,0 +1,51 @@ +/* + * 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 { + mockAlmSettingsInstance, + mockProjectBitbucketCloudBindingResponse +} from '../../../../helpers/mocks/alm-settings'; +import { mockComponent, mockLoggedInUser } from '../../../../helpers/testMocks'; +import Step from '../../components/Step'; +import BitbucketPipelinesTutorial, { + BitbucketPipelinesTutorialProps +} from '../BitbucketPipelinesTutorial'; + +it('should render correctly', () => { + const wrapper = shallowRender(); + expect(wrapper).toMatchSnapshot('For variable steps'); + const stepYaml = wrapper.find(Step).at(1); + stepYaml.simulate('open'); + expect(wrapper).toMatchSnapshot('For yaml steps'); +}); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/PreambuleYaml-test.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/PreambuleYaml-test.tsx new file mode 100644 index 00000000000..c8c5a5248c2 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/PreambuleYaml-test.tsx @@ -0,0 +1,37 @@ +/* + * 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 { mockComponent } from '../../../../helpers/testMocks'; +import { BuildTools } from '../../types'; +import { PreambuleYaml, PreambuleYamlProps } from '../PreambuleYaml'; + +it.each([[BuildTools.DotNet], [BuildTools.Gradle], [BuildTools.Maven], [BuildTools.Other]])( + 'should render correctly for %s', + buildTool => { + expect(shallowRender({ buildTool })).toMatchSnapshot(); + } +); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/RepositoryVariables-test.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/RepositoryVariables-test.tsx new file mode 100644 index 00000000000..14413ebaf8c --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/RepositoryVariables-test.tsx @@ -0,0 +1,45 @@ +/* + * 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 { + mockAlmSettingsInstance, + mockProjectBitbucketCloudBindingResponse +} from '../../../../helpers/mocks/alm-settings'; +import { mockComponent, mockLoggedInUser } from '../../../../helpers/testMocks'; +import RepositoryVariables, { RepositoryVariablesProps } from '../RepositoryVariables'; + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot(); +}); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap new file mode 100644 index 00000000000..51a6080106e --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap @@ -0,0 +1,469 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly for dotnet 1`] = ` + + + + +`; + +exports[`should render correctly for dotnet: with branch enabled 1`] = ` + + + + +`; + +exports[`should render correctly for gradle 1`] = ` + + + + +`; + +exports[`should render correctly for gradle: with branch enabled 1`] = ` + + + + +`; + +exports[`should render correctly for maven 1`] = ` + + + + +`; + +exports[`should render correctly for maven: with branch enabled 1`] = ` + + + + +`; + +exports[`should render correctly for other 1`] = ` + + + + +`; + +exports[`should render correctly for other: with branch enabled 1`] = ` + + + + +`; diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-test.tsx.snap new file mode 100644 index 00000000000..0e33b556ff6 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-test.tsx.snap @@ -0,0 +1,41 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly: For variable steps 1`] = ` + + + + +`; + +exports[`should render correctly: For yaml steps 1`] = ` + + + + +`; diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/PreambuleYaml-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/PreambuleYaml-test.tsx.snap new file mode 100644 index 00000000000..79f07d67d61 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/PreambuleYaml-test.tsx.snap @@ -0,0 +1,101 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly for dotnet 1`] = `""`; + +exports[`should render correctly for gradle 1`] = ` +
  • + + + build.gradle + + + , + "sq": + org.sonarqube + , + } + } + /> + +
  • +`; + +exports[`should render correctly for maven 1`] = ` +
  • + + + pom.xml + + + , + } + } + /> + +
  • +`; + +exports[`should render correctly for other 1`] = ` + +`; diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/RepositoryVariables-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/RepositoryVariables-test.tsx.snap new file mode 100644 index 00000000000..2bd194884dd --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/RepositoryVariables-test.tsx.snap @@ -0,0 +1,161 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +
    +

    + + onboarding.tutorial.with.bitbucket_pipelines.variables.intro.link + , + } + } + /> +

    +
      +
    1. + + + SONAR_TOKEN + + +
    2. + +
    3. + +
    4. +
    5. + +
    6. +
    +
    +
      +
    1. + + + SONAR_HOST_URL + + +
    2. +
    3. + , + "field": + onboarding.tutorial.env_variables.field + , + "value": + test + , + } + } + /> +
    4. +
    5. + +
    6. +
    + +
    +`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/CreateYmlFile.tsx b/server/sonar-web/src/main/js/components/tutorials/components/CreateYmlFile.tsx new file mode 100644 index 00000000000..395aadbc729 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/components/CreateYmlFile.tsx @@ -0,0 +1,50 @@ +/* + * 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 { FormattedMessage } from 'react-intl'; +import { ClipboardIconButton } from 'sonar-ui-common/components/controls/clipboard'; +import { translate } from 'sonar-ui-common/helpers/l10n'; +import CodeSnippet from '../../common/CodeSnippet'; + +export interface CreateYmlFileProps { + yamlFileName: string; + yamlTemplate: string; +} + +export default function CreateYmlFile(props: CreateYmlFileProps) { + const { yamlTemplate, yamlFileName } = props; + return ( +
  • + + {yamlFileName} + + + ) + }} + /> + +
  • + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/YamlFileStep.tsx b/server/sonar-web/src/main/js/components/tutorials/components/YamlFileStep.tsx new file mode 100644 index 00000000000..007c9a8a975 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/components/YamlFileStep.tsx @@ -0,0 +1,65 @@ +/* + * 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 } from 'sonar-ui-common/helpers/l10n'; +import RenderOptions from '../components/RenderOptions'; +import { BuildTools } from '../types'; +import AllSet from './AllSet'; + +export interface YamlFileStepProps { + children?: (buildTool?: BuildTools) => React.ReactElement<{}>; +} + +export interface AnalysisCommandProps { + appState: T.AppState; + buildTool?: BuildTools; + component: T.Component; +} + +export default function YamlFileStep(props: YamlFileStepProps) { + const { children } = props; + const buildTools = [BuildTools.Maven, BuildTools.Gradle, BuildTools.DotNet, BuildTools.Other]; + const [buildToolSelected, setBuildToolSelected] = React.useState(); + + return ( + <> +
      +
    1. + {translate('onboarding.build')} + + setBuildToolSelected(value as BuildTools)} + options={buildTools} + optionLabelKey="onboarding.build" + /> +
    2. + {children && children(buildToolSelected)} +
    + {buildToolSelected !== undefined && ( + <> +
    + + + )} + + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/CreateYmlFile-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/CreateYmlFile-test.tsx new file mode 100644 index 00000000000..136fee4fade --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/CreateYmlFile-test.tsx @@ -0,0 +1,33 @@ +/* + * 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 { GradleProps } from '../../github-action/commands/Gradle'; +import CreateYmlFile, { CreateYmlFileProps } from '../CreateYmlFile'; + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot(); +}); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/YamlFileStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/YamlFileStep-test.tsx new file mode 100644 index 00000000000..9b70ee7c486 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/YamlFileStep-test.tsx @@ -0,0 +1,30 @@ +/* + * 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 YamlFileStep, { YamlFileStepProps } from '../YamlFileStep'; + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot(); +}); + +function shallowRender(props: Partial = {}) { + return shallow(); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/CreateYmlFile-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/CreateYmlFile-test.tsx.snap new file mode 100644 index 00000000000..098d9b25cc7 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/CreateYmlFile-test.tsx.snap @@ -0,0 +1,29 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +
  • + + + test.yml + + + , + } + } + /> + +
  • +`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/YamlFileStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/YamlFileStep-test.tsx.snap new file mode 100644 index 00000000000..4682c79068d --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/YamlFileStep-test.tsx.snap @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` + +
      +
    1. + onboarding.build + +
    2. +
    +
    +`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx index 61eded63854..6779481065a 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx @@ -21,8 +21,9 @@ import * as React from 'react'; import { translate } from 'sonar-ui-common/helpers/l10n'; import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../../types/alm-settings'; import Step from '../components/Step'; +import YamlFileStep from '../components/YamlFileStep'; +import AnalysisCommand from './AnalysisCommand'; import SecretStep from './SecretStep'; -import YamlFileStep from './YamlFileStep'; export enum Steps { CREATE_SECRET = 1, @@ -63,7 +64,11 @@ export default function GitHubActionTutorial(props: GitHubActionTutorialProps) { setStep(Steps.YAML)} open={step === Steps.YAML} - renderForm={() => } + renderForm={() => ( + + {buildTool => } + + )} stepNumber={Steps.YAML} stepTitle={translate('onboarding.tutorial.with.github_action.yaml.title')} /> diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/YamlFileStep.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/YamlFileStep.tsx deleted file mode 100644 index e76055a96e3..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/YamlFileStep.tsx +++ /dev/null @@ -1,60 +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 } from 'sonar-ui-common/helpers/l10n'; -import AllSet from '../components/AllSet'; -import RenderOptions from '../components/RenderOptions'; -import { BuildTools } from '../types'; -import AnalysisCommand from './AnalysisCommand'; - -export interface YamlFileStepProps { - component: T.Component; -} - -export default function YamlFileStep(props: YamlFileStepProps) { - const { component } = props; - const buildTools = [BuildTools.Maven, BuildTools.Gradle, BuildTools.DotNet, BuildTools.Other]; - const [buildToolSelected, setBuildToolSelected] = React.useState(); - - return ( - <> -
      -
    1. - {translate('onboarding.build')} - - setBuildToolSelected(value as BuildTools)} - options={buildTools} - optionLabelKey="onboarding.build" - /> -
    2. - -
    - {buildToolSelected !== undefined && ( - <> -
    - - - )} - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/YamlFileStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/YamlFileStep-test.tsx deleted file mode 100644 index 1d1f3c07d1b..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/YamlFileStep-test.tsx +++ /dev/null @@ -1,31 +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 { mockComponent } from '../../../../helpers/testMocks'; -import YamlFileStep, { YamlFileStepProps } from '../YamlFileStep'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/YamlFileStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/YamlFileStep-test.tsx.snap deleted file mode 100644 index 8f3bfa8a26a..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/YamlFileStep-test.tsx.snap +++ /dev/null @@ -1,50 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -
      -
    1. - onboarding.build - -
    2. - -
    -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CreateYmlFile.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CreateYmlFile.tsx deleted file mode 100644 index e7c47ed263d..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CreateYmlFile.tsx +++ /dev/null @@ -1,49 +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 { FormattedMessage } from 'react-intl'; -import { ClipboardIconButton } from 'sonar-ui-common/components/controls/clipboard'; -import { translate } from 'sonar-ui-common/helpers/l10n'; -import CodeSnippet from '../../../common/CodeSnippet'; - -export interface CreateYmlFileProps { - yamlTemplate: string; -} - -export default function CreateYmlFile(props: CreateYmlFileProps) { - const { yamlTemplate } = props; - return ( -
  • - - .github/workflows/build.yml - - - ) - }} - /> - -
  • - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/DotNet.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/DotNet.tsx index f8a5d5edb14..c99e812057f 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/DotNet.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/DotNet.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import CreateYmlFile from './CreateYmlFile'; +import CreateYmlFile from '../../components/CreateYmlFile'; export interface DotNetProps { branchesEnabled?: boolean; @@ -73,5 +73,10 @@ jobs: export default function DotNet(props: DotNetProps) { const { component, branchesEnabled } = props; - return ; + return ( + + ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Gradle.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Gradle.tsx index 6f3d323f13f..42cffc2d98c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Gradle.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Gradle.tsx @@ -22,8 +22,8 @@ import { FormattedMessage } from 'react-intl'; import { ClipboardIconButton } from 'sonar-ui-common/components/controls/clipboard'; import { translate } from 'sonar-ui-common/helpers/l10n'; import CodeSnippet from '../../../common/CodeSnippet'; +import CreateYmlFile from '../../components/CreateYmlFile'; import { buildGradleSnippet } from '../../utils'; -import CreateYmlFile from './CreateYmlFile'; export interface GradleProps { branchesEnabled?: boolean; @@ -73,8 +73,8 @@ export default function Gradle(props: GradleProps) { <>
  • @@ -87,7 +87,10 @@ export default function Gradle(props: GradleProps) { />
  • - + ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/JavaMaven.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/JavaMaven.tsx index cbafc007bf5..54d21e2232c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/JavaMaven.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/JavaMaven.tsx @@ -22,8 +22,8 @@ import { FormattedMessage } from 'react-intl'; import { ClipboardIconButton } from 'sonar-ui-common/components/controls/clipboard'; import { translate } from 'sonar-ui-common/helpers/l10n'; import CodeSnippet from '../../../common/CodeSnippet'; +import CreateYmlFile from '../../components/CreateYmlFile'; import { mavenPomSnippet } from '../../utils'; -import CreateYmlFile from './CreateYmlFile'; export interface JavaMavenProps { branchesEnabled?: boolean; @@ -73,8 +73,8 @@ export default function JavaMaven(props: JavaMavenProps) { <>
  • @@ -86,7 +86,10 @@ export default function JavaMaven(props: JavaMavenProps) { />
  • - + ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx index 11320042f68..ea4f93e419f 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import CreateYmlFile from '../../components/CreateYmlFile'; import DefaultProjectKey from '../../components/DefaultProjectKey'; -import CreateYmlFile from './CreateYmlFile'; export interface OthersProps { branchesEnabled?: boolean; @@ -75,7 +75,10 @@ export default function Others(props: OthersProps) { return ( <> - + ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/CreateYmlFile-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/CreateYmlFile-test.tsx deleted file mode 100644 index 9dfe3cbcb55..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/CreateYmlFile-test.tsx +++ /dev/null @@ -1,31 +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 CreateYmlFile, { CreateYmlFileProps } from '../CreateYmlFile'; -import { GradleProps } from '../Gradle'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/CreateYmlFile-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/CreateYmlFile-test.tsx.snap deleted file mode 100644 index 61e32f72b14..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/CreateYmlFile-test.tsx.snap +++ /dev/null @@ -1,29 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
  • - - - .github/workflows/build.yml - - - , - } - } - /> - -
  • -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/DotNet-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/DotNet-test.tsx.snap index ae1bd7ae9cd..afb06fa5683 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/DotNet-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/DotNet-test.tsx.snap @@ -2,6 +2,7 @@ exports[`should render correctly 1`] = ` @@ -41,6 +41,7 @@ sonarqube { /> @@ -123,6 +124,7 @@ sonarqube { /> @@ -30,6 +30,7 @@ exports[`should render correctly 1`] = ` /> @@ -101,6 +102,7 @@ exports[`should render correctly: without branch enabled 1`] = ` />