@@ -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 | |||
}; | |||
@@ -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(); | |||
}); | |||
@@ -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`] = ` | |||
<div | |||
className="boxed-group-inner" | |||
> | |||
@@ -10,7 +10,7 @@ exports[`should render correctly for Gradle 1`] = ` | |||
<li> | |||
onboarding.build | |||
<RenderOptions | |||
checked="gradle" | |||
checked="dotnet" | |||
name="buildtool" | |||
onCheck={[Function]} | |||
optionLabelKey="onboarding.build" | |||
@@ -18,13 +18,13 @@ exports[`should render correctly for Gradle 1`] = ` | |||
Array [ | |||
"maven", | |||
"gradle", | |||
"msbuild", | |||
"dotnet", | |||
"other", | |||
] | |||
} | |||
/> | |||
</li> | |||
<Gradle | |||
<DotNet | |||
component={ | |||
Object { | |||
"breadcrumbs": Array [], | |||
@@ -122,7 +122,7 @@ exports[`should render correctly for Gradle 1`] = ` | |||
</div> | |||
`; | |||
exports[`should render correctly for MSBuild 1`] = ` | |||
exports[`should render correctly for Gradle 1`] = ` | |||
<div | |||
className="boxed-group-inner" | |||
> | |||
@@ -132,7 +132,7 @@ exports[`should render correctly for MSBuild 1`] = ` | |||
<li> | |||
onboarding.build | |||
<RenderOptions | |||
checked="msbuild" | |||
checked="gradle" | |||
name="buildtool" | |||
onCheck={[Function]} | |||
optionLabelKey="onboarding.build" | |||
@@ -140,13 +140,13 @@ exports[`should render correctly for MSBuild 1`] = ` | |||
Array [ | |||
"maven", | |||
"gradle", | |||
"msbuild", | |||
"dotnet", | |||
"other", | |||
] | |||
} | |||
/> | |||
</li> | |||
<MSBuild | |||
<Gradle | |||
component={ | |||
Object { | |||
"breadcrumbs": Array [], | |||
@@ -262,7 +262,7 @@ exports[`should render correctly for Maven 1`] = ` | |||
Array [ | |||
"maven", | |||
"gradle", | |||
"msbuild", | |||
"dotnet", | |||
"other", | |||
] | |||
} | |||
@@ -384,7 +384,7 @@ exports[`should render correctly for Other 1`] = ` | |||
Array [ | |||
"maven", | |||
"gradle", | |||
"msbuild", | |||
"dotnet", | |||
"other", | |||
] | |||
} | |||
@@ -515,7 +515,7 @@ exports[`should render correctly: initial content 1`] = ` | |||
Array [ | |||
"maven", | |||
"gradle", | |||
"msbuild", | |||
"dotnet", | |||
"other", | |||
] | |||
} |
@@ -24,7 +24,7 @@ import CodeSnippet from '../../../common/CodeSnippet'; | |||
import SentenceWithFilename from '../../components/SentenceWithFilename'; | |||
import SentenceWithHighlights from '../../components/SentenceWithHighlights'; | |||
export interface MSBuildProps { | |||
export interface DotNetProps { | |||
component: T.Component; | |||
} | |||
@@ -44,7 +44,7 @@ const jenkinsfileSnippet = (key: string) => `node { | |||
} | |||
`; | |||
export default function MSBuild({ component }: MSBuildProps) { | |||
export default function DotNet({ component }: DotNetProps) { | |||
return ( | |||
<li className="abs-width-600"> | |||
<SentenceWithFilename | |||
@@ -55,7 +55,7 @@ export default function MSBuild({ component }: MSBuildProps) { | |||
<p className="text-middle"> | |||
<SentenceWithHighlights | |||
highlightKeys={['default_msbuild', 'default_scanner', 'in_jenkins']} | |||
translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.replace" | |||
translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.replace" | |||
/> | |||
<HelpTooltip | |||
className="little-spacer-left" | |||
@@ -64,19 +64,19 @@ export default function MSBuild({ component }: MSBuildProps) { | |||
<p className="spacer-bottom"> | |||
<SentenceWithHighlights | |||
highlightKeys={['path']} | |||
translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help1" | |||
translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help1" | |||
/> | |||
</p> | |||
<p className="spacer-bottom"> | |||
<SentenceWithHighlights | |||
highlightKeys={['path', 'name']} | |||
translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help2" | |||
translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help2" | |||
/> | |||
</p> | |||
<p> | |||
<SentenceWithHighlights | |||
highlightKeys={['path', 'name']} | |||
translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help3" | |||
translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help3" | |||
/> | |||
</p> | |||
</> |
@@ -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<MSBuildProps> = {}) { | |||
return shallow<MSBuildProps>(<MSBuild component={mockComponent()} {...props} />); | |||
function shallowRender(props: Partial<DotNetProps> = {}) { | |||
return shallow<DotNetProps>(<DotNet component={mockComponent()} {...props} />); | |||
} |
@@ -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" | |||
/> | |||
<HelpTooltip | |||
className="little-spacer-left" | |||
@@ -38,7 +38,7 @@ exports[`should render correctly 1`] = ` | |||
"path", | |||
] | |||
} | |||
translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help1" | |||
translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help1" | |||
/> | |||
</p> | |||
<p | |||
@@ -51,7 +51,7 @@ exports[`should render correctly 1`] = ` | |||
"name", | |||
] | |||
} | |||
translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.msbuild.step2.help2" | |||
translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help2" | |||
/> | |||
</p> | |||
<p> | |||
@@ -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" | |||
/> | |||
</p> | |||
</React.Fragment> |
@@ -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<Props, State> { | |||
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 ( | |||
<> | |||
<div> | |||
<h4 className="spacer-bottom">{translate('onboarding.build')}</h4> | |||
<RadioToggle | |||
name="language" | |||
onCheck={this.handleBuildToolChange} | |||
options={buildTools.map(tool => ({ | |||
label: translate('onboarding.build', tool), | |||
value: tool | |||
}))} | |||
value={config.buildTool} | |||
/> | |||
</div> | |||
{config.buildTool === BuildTools.Other && ( | |||
<RenderOptions | |||
checked={config.os} | |||
name="os" | |||
onCheck={this.handleOSChange} | |||
optionLabelKey="onboarding.build.other.os" | |||
options={[OSs.Linux, OSs.Windows, OSs.MacOS]} | |||
titleLabelKey="onboarding.build.other.os" | |||
/> | |||
)} | |||
</> | |||
); | |||
} | |||
} |
@@ -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 ( | |||
<RenderOptions | |||
checked={props.os} | |||
name="os" | |||
onCheck={props.setOS} | |||
optionLabelKey="onboarding.language.os" | |||
options={['linux', 'win', 'mac']} | |||
titleLabelKey="onboarding.language.os" | |||
/> | |||
); | |||
} | |||
export default class LanguageForm extends React.PureComponent<Props, State> { | |||
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 = () => ( | |||
<RenderOptions | |||
checked={this.state.javaBuild} | |||
name="java-build" | |||
onCheck={this.handleJavaBuildChange} | |||
optionLabelKey="onboarding.language.java.build_technology" | |||
options={['maven', 'gradle']} | |||
titleLabelKey="onboarding.language.java.build_technology" | |||
/> | |||
); | |||
render() { | |||
const { language } = this.state; | |||
const languages = ['java', 'dotnet', 'other']; | |||
return ( | |||
<> | |||
<div> | |||
<h4 className="spacer-bottom">{translate('onboarding.language')}</h4> | |||
<RadioToggle | |||
name="language" | |||
onCheck={this.handleLanguageChange} | |||
options={languages.map(language => ({ | |||
label: translate('onboarding.language', language), | |||
value: language | |||
}))} | |||
value={language} | |||
/> | |||
</div> | |||
{language === 'java' && this.renderJavaBuild()} | |||
{language === 'other' && <RenderOS os={this.state.os} setOS={this.handleOSChange} />} | |||
</> | |||
); | |||
} | |||
} |
@@ -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<Props, State> { | |||
const { component, currentUser } = this.props; | |||
const { step, token } = this.state; | |||
const almKey = (component.alm && component.alm.key) || currentUser.externalProvider; | |||
return ( | |||
<> | |||
<div className="page-header big-spacer-bottom"> | |||
@@ -64,27 +62,22 @@ export default class ManualTutorial extends React.PureComponent<Props, State> { | |||
</p> | |||
</div> | |||
{!isVSTS(almKey) && ( | |||
<> | |||
<TokenStep | |||
currentUser={currentUser} | |||
finished={Boolean(this.state.token)} | |||
initialTokenName={`Analyze "${component.name}"`} | |||
onContinue={this.handleTokenDone} | |||
onOpen={this.handleTokenOpen} | |||
open={step === Steps.TOKEN} | |||
stepNumber={1} | |||
/> | |||
<TokenStep | |||
currentUser={currentUser} | |||
finished={Boolean(this.state.token)} | |||
initialTokenName={`Analyze "${component.name}"`} | |||
onContinue={this.handleTokenDone} | |||
onOpen={this.handleTokenOpen} | |||
open={step === Steps.TOKEN} | |||
stepNumber={1} | |||
/> | |||
<ProjectAnalysisStep | |||
component={component} | |||
displayRowLayout={true} | |||
open={step === Steps.ANALYSIS} | |||
stepNumber={2} | |||
token={token} | |||
/> | |||
</> | |||
)} | |||
<ProjectAnalysisStep | |||
component={component} | |||
open={step === Steps.ANALYSIS} | |||
stepNumber={2} | |||
token={token} | |||
/> | |||
</> | |||
); | |||
} |
@@ -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<Props, State> { | |||
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 = ( | |||
<LanguageForm | |||
component={this.props.component} | |||
onDone={this.handleLanguageSelect} | |||
onReset={this.handleLanguageReset} | |||
organization={this.props.organization} | |||
/> | |||
); | |||
const analysisComponent = this.state.config && ( | |||
<AnalysisCommand | |||
component={this.props.component} | |||
languageConfig={this.state.config} | |||
organization={this.props.organization} | |||
small={true} | |||
token={this.props.token} | |||
/> | |||
); | |||
if (this.props.displayRowLayout) { | |||
return ( | |||
<div className="boxed-group-inner"> | |||
<div className="display-flex-column"> | |||
{languageComponent} | |||
{analysisComponent && <div className="huge-spacer-top">{analysisComponent}</div>} | |||
</div> | |||
</div> | |||
); | |||
} | |||
return ( | |||
<div className="boxed-group-inner"> | |||
<div className="flex-columns"> | |||
<div className="flex-column flex-column-half bordered-right">{languageComponent}</div> | |||
<div className="flex-column flex-column-half">{analysisComponent}</div> | |||
<div className="display-flex-column"> | |||
<BuildToolForm component={this.props.component} onDone={this.handleBuildToolSelect} /> | |||
{this.state.config && ( | |||
<div className="huge-spacer-top"> | |||
<AnalysisCommand | |||
component={this.props.component} | |||
languageConfig={this.state.config} | |||
token={this.props.token} | |||
/> | |||
</div> | |||
)} | |||
</div> | |||
</div> | |||
); |
@@ -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( | |||
<LanguageForm component={mockComponent()} onDone={onDone} onReset={jest.fn()} /> | |||
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( | |||
<LanguageForm component={mockComponent()} onDone={onDone} onReset={jest.fn()} /> | |||
); | |||
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( | |||
<LanguageForm component={mockComponent()} onDone={onDone} onReset={jest.fn()} /> | |||
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<BuildToolForm['props']> = {}) { | |||
return shallow<BuildToolForm>( | |||
<BuildToolForm component={mockComponent()} onDone={jest.fn()} {...props} /> | |||
); | |||
} |
@@ -1,12 +1,12 @@ | |||
// Jest Snapshot v1, https://goo.gl/fbAQLP | |||
exports[`selects c# 1`] = ` | |||
exports[`renders correctly: default 1`] = ` | |||
<Fragment> | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.language | |||
onboarding.build | |||
</h4> | |||
<RadioToggle | |||
disabled={false} | |||
@@ -15,32 +15,36 @@ exports[`selects c# 1`] = ` | |||
options={ | |||
Array [ | |||
Object { | |||
"label": "onboarding.language.java", | |||
"value": "java", | |||
"label": "onboarding.build.maven", | |||
"value": "maven", | |||
}, | |||
Object { | |||
"label": "onboarding.language.dotnet", | |||
"label": "onboarding.build.gradle", | |||
"value": "gradle", | |||
}, | |||
Object { | |||
"label": "onboarding.build.dotnet", | |||
"value": "dotnet", | |||
}, | |||
Object { | |||
"label": "onboarding.language.other", | |||
"label": "onboarding.build.other", | |||
"value": "other", | |||
}, | |||
] | |||
} | |||
value="dotnet" | |||
value={null} | |||
/> | |||
</div> | |||
</Fragment> | |||
`; | |||
exports[`selects java 1`] = ` | |||
exports[`renders correctly: with "maven" selected 1`] = ` | |||
<Fragment> | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.language | |||
onboarding.build | |||
</h4> | |||
<RadioToggle | |||
disabled={false} | |||
@@ -49,44 +53,36 @@ exports[`selects java 1`] = ` | |||
options={ | |||
Array [ | |||
Object { | |||
"label": "onboarding.language.java", | |||
"value": "java", | |||
"label": "onboarding.build.maven", | |||
"value": "maven", | |||
}, | |||
Object { | |||
"label": "onboarding.language.dotnet", | |||
"label": "onboarding.build.gradle", | |||
"value": "gradle", | |||
}, | |||
Object { | |||
"label": "onboarding.build.dotnet", | |||
"value": "dotnet", | |||
}, | |||
Object { | |||
"label": "onboarding.language.other", | |||
"label": "onboarding.build.other", | |||
"value": "other", | |||
}, | |||
] | |||
} | |||
value="java" | |||
value="maven" | |||
/> | |||
</div> | |||
<RenderOptions | |||
name="java-build" | |||
onCheck={[Function]} | |||
optionLabelKey="onboarding.language.java.build_technology" | |||
options={ | |||
Array [ | |||
"maven", | |||
"gradle", | |||
] | |||
} | |||
titleLabelKey="onboarding.language.java.build_technology" | |||
/> | |||
</Fragment> | |||
`; | |||
exports[`selects other 1`] = ` | |||
exports[`renders correctly: with "other" selected 1`] = ` | |||
<Fragment> | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.language | |||
onboarding.build | |||
</h4> | |||
<RadioToggle | |||
disabled={false} | |||
@@ -95,15 +91,19 @@ exports[`selects other 1`] = ` | |||
options={ | |||
Array [ | |||
Object { | |||
"label": "onboarding.language.java", | |||
"value": "java", | |||
"label": "onboarding.build.maven", | |||
"value": "maven", | |||
}, | |||
Object { | |||
"label": "onboarding.build.gradle", | |||
"value": "gradle", | |||
}, | |||
Object { | |||
"label": "onboarding.language.dotnet", | |||
"label": "onboarding.build.dotnet", | |||
"value": "dotnet", | |||
}, | |||
Object { | |||
"label": "onboarding.language.other", | |||
"label": "onboarding.build.other", | |||
"value": "other", | |||
}, | |||
] | |||
@@ -111,8 +111,18 @@ exports[`selects other 1`] = ` | |||
value="other" | |||
/> | |||
</div> | |||
<RenderOS | |||
setOS={[Function]} | |||
<RenderOptions | |||
name="os" | |||
onCheck={[Function]} | |||
optionLabelKey="onboarding.build.other.os" | |||
options={ | |||
Array [ | |||
"linux", | |||
"win", | |||
"mac", | |||
] | |||
} | |||
titleLabelKey="onboarding.build.other.os" | |||
/> | |||
</Fragment> | |||
`; |
@@ -59,7 +59,6 @@ exports[`renders correctly: default 1`] = ` | |||
"tags": Array [], | |||
} | |||
} | |||
displayRowLayout={true} | |||
open={false} | |||
stepNumber={2} | |||
/> |
@@ -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<Props> { | |||
renderCommandForMaven = () => { | |||
const { component, token } = this.props; | |||
if (!token) { | |||
return null; | |||
} | |||
return ( | |||
<JavaMaven | |||
host={getHostUrl()} | |||
organization={this.props.organization} | |||
projectKey={component && component.key} | |||
token={token} | |||
/> | |||
); | |||
}; | |||
export default function AnalysisCommand(props: AnalysisCommandProps) { | |||
const { component, languageConfig, token } = props; | |||
renderCommandForGradle = () => { | |||
const { component, token } = this.props; | |||
if (!token) { | |||
return null; | |||
} | |||
return ( | |||
<JavaGradle | |||
host={getHostUrl()} | |||
organization={this.props.organization} | |||
projectKey={component && component.key} | |||
token={token} | |||
/> | |||
); | |||
}; | |||
if (!token) { | |||
return null; | |||
} | |||
renderCommandForDotNet = () => { | |||
const { component, languageConfig, small, token } = this.props; | |||
const projectKey = getProjectKey(languageConfig, component); | |||
if (!projectKey || !token) { | |||
return null; | |||
} | |||
return ( | |||
<DotNet | |||
host={getHostUrl()} | |||
organization={this.props.organization} | |||
projectKey={projectKey} | |||
small={small} | |||
token={token} | |||
/> | |||
); | |||
}; | |||
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 ( | |||
<Other | |||
host={getHostUrl()} | |||
organization={this.props.organization} | |||
os={languageConfig.os} | |||
projectKey={projectKey} | |||
token={token} | |||
/> | |||
); | |||
}; | |||
switch (languageConfig.buildTool) { | |||
case BuildTools.Maven: | |||
return <JavaMaven host={host} projectKey={projectKey} token={token} />; | |||
case BuildTools.Gradle: | |||
return <JavaGradle host={host} projectKey={projectKey} token={token} />; | |||
render() { | |||
const { languageConfig } = this.props; | |||
case BuildTools.DotNet: | |||
return <DotNet host={host} projectKey={projectKey} token={token} />; | |||
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 ? ( | |||
<Other host={host} os={languageConfig.os} projectKey={projectKey} token={token} /> | |||
) : null; | |||
default: | |||
return null; | |||
} | |||
} |
@@ -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 ( | |||
<div> | |||
<MSBuildScanner /> | |||
<div> | |||
<h4 className="spacer-bottom">{translate('onboarding.analysis.msbuild.header')}</h4> | |||
<p className="spacer-bottom markdown"> | |||
<FormattedMessage | |||
defaultMessage={translate('onboarding.analysis.msbuild.text')} | |||
id="onboarding.analysis.msbuild.text" | |||
values={{ code: <code>%PATH%</code> }} | |||
/> | |||
</p> | |||
<p> | |||
<Link | |||
className="button" | |||
to="/documentation/analysis/scan/sonarscanner-for-msbuild/" | |||
target="_blank"> | |||
{translate('download_verb')} | |||
</Link> | |||
</p> | |||
</div> | |||
<h4 className="huge-spacer-top spacer-bottom"> | |||
{translate('onboarding.analysis.msbuild.execute')} | |||
@@ -58,7 +73,7 @@ export default function DotNet(props: Props) { | |||
</InstanceMessage> | |||
<CodeSnippet isOneLine={true} snippet={command1} /> | |||
<CodeSnippet isOneLine={true} snippet={command2} /> | |||
<CodeSnippet isOneLine={props.small} snippet={command3} /> | |||
<CodeSnippet isOneLine={true} snippet={command3} /> | |||
<p className="big-spacer-top markdown"> | |||
<FormattedMessage | |||
defaultMessage={translate('onboarding.analysis.docs')} |
@@ -24,22 +24,21 @@ import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import CodeSnippet from '../../../common/CodeSnippet'; | |||
import InstanceMessage from '../../../common/InstanceMessage'; | |||
export interface Props { | |||
export interface JavaGradleProps { | |||
host: string; | |||
organization?: string; | |||
projectKey?: string; | |||
projectKey: string; | |||
token: string; | |||
} | |||
export default function JavaGradle(props: Props) { | |||
const config = 'plugins {\n id "org.sonarqube" version "2.7"\n}'; | |||
export default function JavaGradle(props: JavaGradleProps) { | |||
const { host, projectKey, token } = props; | |||
const config = 'plugins {\n id "org.sonarqube" version "3.0"\n}'; | |||
const command = [ | |||
'./gradlew sonarqube', | |||
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 ( | |||
@@ -60,6 +59,21 @@ export default function JavaGradle(props: Props) { | |||
)} | |||
</InstanceMessage> | |||
<CodeSnippet snippet={config} /> | |||
<p className="big-spacer-bottom markdown"> | |||
<em className="small text-muted"> | |||
<FormattedMessage | |||
defaultMessage={translate('onboarding.analysis.java.gradle.latest_version')} | |||
id="onboarding.analysis.java.gradle.latest_version" | |||
values={{ | |||
link: ( | |||
<Link to="/documentation/analysis/scan/sonarscanner-for-gradle/" target="_blank"> | |||
{translate('here')} | |||
</Link> | |||
) | |||
}} | |||
/> | |||
</em> | |||
</p> | |||
<p className="spacer-top spacer-bottom markdown"> | |||
{translate('onboarding.analysis.java.gradle.text.2')} | |||
</p> | |||
@@ -78,9 +92,7 @@ export default function JavaGradle(props: Props) { | |||
/> | |||
</p> | |||
<p className="big-spacer-top markdown"> | |||
{props.projectKey | |||
? translate('onboarding.analysis.auto_refresh_after_analysis') | |||
: translate('onboarding.analysis.browse_url_after_analysis')} | |||
{translate('onboarding.analysis.auto_refresh_after_analysis')} | |||
</p> | |||
</div> | |||
); |
@@ -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) { | |||
/> | |||
</p> | |||
<p className="big-spacer-top markdown"> | |||
{props.projectKey | |||
? translate('onboarding.analysis.auto_refresh_after_analysis') | |||
: translate('onboarding.analysis.browse_url_after_analysis')} | |||
{translate('onboarding.analysis.auto_refresh_after_analysis')} | |||
</p> | |||
</div> | |||
); |
@@ -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 ( | |||
<div className={props.className}> | |||
<h4 className="spacer-bottom">{translate('onboarding.analysis.msbuild.header')}</h4> | |||
<p className="spacer-bottom markdown"> | |||
<FormattedMessage | |||
defaultMessage={translate('onboarding.analysis.msbuild.text')} | |||
id="onboarding.analysis.msbuild.text" | |||
values={{ code: <code>%PATH%</code> }} | |||
/> | |||
</p> | |||
<p> | |||
<Link | |||
className="button" | |||
to="/documentation/analysis/scan/sonarscanner-for-msbuild/" | |||
target="_blank"> | |||
{translate('download_verb')} | |||
</Link> | |||
</p> | |||
</div> | |||
); | |||
} |
@@ -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 ( | |||
<div> | |||
<SQScanner os={props.os} /> | |||
<div> | |||
<h4 className="spacer-bottom">{translate('onboarding.analysis.sq_scanner.header', os)}</h4> | |||
<p className="spacer-bottom markdown"> | |||
<FormattedMessage | |||
defaultMessage={translate('onboarding.analysis.sq_scanner.text')} | |||
id="onboarding.analysis.sq_scanner.text" | |||
values={{ | |||
dir: <code>bin</code>, | |||
env_var: <code>{os === OSs.Windows ? '%PATH%' : 'PATH'}</code> | |||
}} | |||
/> | |||
</p> | |||
<p> | |||
<Link className="button" to="/documentation/analysis/scan/sonarscanner/" target="_blank"> | |||
{translate('download_verb')} | |||
</Link> | |||
</p> | |||
</div> | |||
<h4 className="huge-spacer-top spacer-bottom"> | |||
{translate('onboarding.analysis.sq_scanner.execute')} | |||
@@ -55,7 +72,7 @@ export default function Other(props: Props) { | |||
<InstanceMessage message={translate('onboarding.analysis.sq_scanner.execute.text')}> | |||
{transformedMessage => <p className="spacer-bottom markdown">{transformedMessage}</p>} | |||
</InstanceMessage> | |||
<CodeSnippet isOneLine={props.os === 'win'} snippet={command} /> | |||
<CodeSnippet isOneLine={os === OSs.Windows} snippet={command} /> | |||
<p className="big-spacer-top markdown"> | |||
<FormattedMessage | |||
defaultMessage={translate('onboarding.analysis.sq_scanner.docs')} |
@@ -1,53 +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; | |||
os: string; | |||
} | |||
export default function SQScanner(props: Props) { | |||
return ( | |||
<div className={props.className}> | |||
<h4 className="spacer-bottom"> | |||
{translate('onboarding.analysis.sq_scanner.header', props.os)} | |||
</h4> | |||
<p className="spacer-bottom markdown"> | |||
<FormattedMessage | |||
defaultMessage={translate('onboarding.analysis.sq_scanner.text')} | |||
id="onboarding.analysis.sq_scanner.text" | |||
values={{ | |||
dir: <code>bin</code>, | |||
env_var: <code>{props.os === 'win' ? '%PATH%' : 'PATH'}</code> | |||
}} | |||
/> | |||
</p> | |||
<p> | |||
<Link className="button" to="/documentation/analysis/scan/sonarscanner/" target="_blank"> | |||
{translate('download_verb')} | |||
</Link> | |||
</p> | |||
</div> | |||
); | |||
} |
@@ -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(<AnalysisCommand languageConfig={{}} token="myToken" {...props} />); | |||
function shallowRender(props: Partial<AnalysisCommandProps> = {}) { | |||
return shallow<AnalysisCommandProps>( | |||
<AnalysisCommand component={mockComponent()} languageConfig={{}} token="myToken" {...props} /> | |||
); | |||
} |
@@ -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(<DotNet host="host" projectKey="projectKey" token="token" />)).toMatchSnapshot(); | |||
}); | |||
function shallowRender(props: Partial<Props> = {}) { | |||
return shallow(<DotNet host="host" projectKey="projectKey" token="token" {...props} />); | |||
} |
@@ -22,14 +22,7 @@ import * as React from 'react'; | |||
import JavaGradle from '../JavaGradle'; | |||
it('renders correctly', () => { | |||
expect(shallow(<JavaGradle host="host" token="token" />)).toMatchSnapshot(); | |||
expect( | |||
shallow(<JavaGradle host="host" organization="organization" token="token" />) | |||
).toMatchSnapshot(); | |||
}); | |||
it('renders with projectKey', () => { | |||
expect( | |||
shallow(<JavaGradle host="host" organization="organization" projectKey="foo" token="token" />) | |||
shallow(<JavaGradle host="host" projectKey="projectKey" token="token" />) | |||
).toMatchSnapshot(); | |||
}); |
@@ -22,14 +22,7 @@ import * as React from 'react'; | |||
import JavaMaven from '../JavaMaven'; | |||
it('renders correctly', () => { | |||
expect(shallow(<JavaMaven host="host" token="token" />)).toMatchSnapshot(); | |||
expect( | |||
shallow(<JavaMaven host="host" organization="organization" token="token" />) | |||
).toMatchSnapshot(); | |||
}); | |||
it('renders with projectKey', () => { | |||
expect( | |||
shallow(<JavaMaven host="host" organization="organization" projectKey="foo" token="token" />) | |||
shallow(<JavaMaven host="host" projectKey="projectKey" token="token" />) | |||
).toMatchSnapshot(); | |||
}); |
@@ -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(<MSBuildScanner />)).toMatchSnapshot(); | |||
}); |
@@ -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(<Other host="host" os="win" projectKey="projectKey" token="token" />) | |||
).toMatchSnapshot(); | |||
expect( | |||
shallow(<Other host="host" os="linux" projectKey="projectKey" token="token" />) | |||
).toMatchSnapshot(); | |||
expect( | |||
shallow(<Other host="host" os="linux" projectKey="projectKey" token="token" />) | |||
).toMatchSnapshot(); | |||
expect(shallowRender()).toMatchSnapshot('linux'); | |||
expect(shallowRender({ os: OSs.Windows })).toMatchSnapshot('windows'); | |||
expect(shallowRender({ os: OSs.MacOS })).toMatchSnapshot('macos'); | |||
}); | |||
function shallowRender(props: Partial<OtherProps> = {}) { | |||
return shallow<OtherProps>( | |||
<Other host="host" os={OSs.Linux} projectKey="projectKey" token="token" {...props} /> | |||
); | |||
} |
@@ -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(<SQScanner os="win" />)).toMatchSnapshot(); | |||
expect(shallow(<SQScanner os="linux" />)).toMatchSnapshot(); | |||
expect(shallow(<SQScanner os="mac" />)).toMatchSnapshot(); | |||
}); |
@@ -1,32 +1,34 @@ | |||
// Jest Snapshot v1, https://goo.gl/fbAQLP | |||
exports[`display c# command 1`] = ` | |||
exports[`renders correctly: .NET 1`] = ` | |||
<DotNet | |||
host="HOST" | |||
projectKey="project-foo" | |||
projectKey="my-project" | |||
token="myToken" | |||
/> | |||
`; | |||
exports[`display java command 1`] = ` | |||
exports[`renders correctly: gradle 1`] = ` | |||
<JavaGradle | |||
host="HOST" | |||
projectKey="my-project" | |||
token="myToken" | |||
/> | |||
`; | |||
exports[`display java command 2`] = ` | |||
exports[`renders correctly: maven 1`] = ` | |||
<JavaMaven | |||
host="HOST" | |||
projectKey="my-project" | |||
token="myToken" | |||
/> | |||
`; | |||
exports[`display others command 1`] = ` | |||
exports[`renders correctly: other 1`] = ` | |||
<Other | |||
host="HOST" | |||
os="window" | |||
projectKey="project-foo" | |||
os="win" | |||
projectKey="my-project" | |||
token="myToken" | |||
/> | |||
`; |
@@ -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`] = ` | |||
<div> | |||
<MSBuildScanner /> | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.analysis.msbuild.header | |||
</h4> | |||
<p | |||
className="spacer-bottom markdown" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.msbuild.text" | |||
id="onboarding.analysis.msbuild.text" | |||
values={ | |||
Object { | |||
"code": <code> | |||
%PATH% | |||
</code>, | |||
} | |||
} | |||
/> | |||
</p> | |||
<p> | |||
<Link | |||
className="button" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner-for-msbuild/" | |||
> | |||
download_verb | |||
</Link> | |||
</p> | |||
</div> | |||
<h4 | |||
className="huge-spacer-top spacer-bottom" | |||
> | |||
@@ -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\\"", | |||
] |
@@ -14,131 +14,33 @@ exports[`renders correctly 1`] = ` | |||
</InstanceMessage> | |||
<CodeSnippet | |||
snippet="plugins { | |||
id \\"org.sonarqube\\" version \\"2.7\\" | |||
id \\"org.sonarqube\\" version \\"3.0\\" | |||
}" | |||
/> | |||
<p | |||
className="spacer-top spacer-bottom markdown" | |||
> | |||
onboarding.analysis.java.gradle.text.2 | |||
</p> | |||
<CodeSnippet | |||
snippet={ | |||
Array [ | |||
"./gradlew sonarqube", | |||
undefined, | |||
undefined, | |||
"-Dsonar.host.url=host", | |||
"-Dsonar.login=token", | |||
] | |||
} | |||
/> | |||
<p | |||
className="big-spacer-top markdown" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.docs" | |||
id="onboarding.analysis.docs" | |||
values={ | |||
Object { | |||
"link": <Link | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner-for-gradle/" | |||
> | |||
onboarding.analysis.java.gradle.docs_link | |||
</Link>, | |||
} | |||
} | |||
/> | |||
</p> | |||
<p | |||
className="big-spacer-top markdown" | |||
> | |||
onboarding.analysis.browse_url_after_analysis | |||
</p> | |||
</div> | |||
`; | |||
exports[`renders correctly 2`] = ` | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.analysis.java.gradle.header | |||
</h4> | |||
<InstanceMessage | |||
message="onboarding.analysis.java.gradle.text.1" | |||
> | |||
<Component /> | |||
</InstanceMessage> | |||
<CodeSnippet | |||
snippet="plugins { | |||
id \\"org.sonarqube\\" version \\"2.7\\" | |||
}" | |||
/> | |||
<p | |||
className="spacer-top spacer-bottom markdown" | |||
className="big-spacer-bottom markdown" | |||
> | |||
onboarding.analysis.java.gradle.text.2 | |||
</p> | |||
<CodeSnippet | |||
snippet={ | |||
Array [ | |||
"./gradlew sonarqube", | |||
undefined, | |||
"-Dsonar.organization=organization", | |||
"-Dsonar.host.url=host", | |||
"-Dsonar.login=token", | |||
] | |||
} | |||
/> | |||
<p | |||
className="big-spacer-top markdown" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.docs" | |||
id="onboarding.analysis.docs" | |||
values={ | |||
Object { | |||
"link": <Link | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner-for-gradle/" | |||
> | |||
onboarding.analysis.java.gradle.docs_link | |||
</Link>, | |||
<em | |||
className="small text-muted" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.java.gradle.latest_version" | |||
id="onboarding.analysis.java.gradle.latest_version" | |||
values={ | |||
Object { | |||
"link": <Link | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner-for-gradle/" | |||
> | |||
here | |||
</Link>, | |||
} | |||
} | |||
} | |||
/> | |||
</p> | |||
<p | |||
className="big-spacer-top markdown" | |||
> | |||
onboarding.analysis.browse_url_after_analysis | |||
/> | |||
</em> | |||
</p> | |||
</div> | |||
`; | |||
exports[`renders with projectKey 1`] = ` | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.analysis.java.gradle.header | |||
</h4> | |||
<InstanceMessage | |||
message="onboarding.analysis.java.gradle.text.1" | |||
> | |||
<Component /> | |||
</InstanceMessage> | |||
<CodeSnippet | |||
snippet="plugins { | |||
id \\"org.sonarqube\\" version \\"2.7\\" | |||
}" | |||
/> | |||
<p | |||
className="spacer-top spacer-bottom markdown" | |||
> | |||
@@ -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", | |||
] |
@@ -18,114 +18,7 @@ exports[`renders correctly 1`] = ` | |||
snippet={ | |||
Array [ | |||
"mvn sonar:sonar", | |||
undefined, | |||
undefined, | |||
"-Dsonar.host.url=host", | |||
"-Dsonar.login=token", | |||
] | |||
} | |||
/> | |||
<p | |||
className="big-spacer-top markdown" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.docs" | |||
id="onboarding.analysis.docs" | |||
values={ | |||
Object { | |||
"link": <Link | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner-for-gradle/" | |||
> | |||
onboarding.analysis.java.maven.docs_link | |||
</Link>, | |||
} | |||
} | |||
/> | |||
</p> | |||
<p | |||
className="big-spacer-top markdown" | |||
> | |||
onboarding.analysis.browse_url_after_analysis | |||
</p> | |||
</div> | |||
`; | |||
exports[`renders correctly 2`] = ` | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.analysis.java.maven.header | |||
</h4> | |||
<p | |||
className="spacer-bottom markdown" | |||
> | |||
<InstanceMessage | |||
message="onboarding.analysis.java.maven.text" | |||
/> | |||
</p> | |||
<CodeSnippet | |||
snippet={ | |||
Array [ | |||
"mvn sonar:sonar", | |||
undefined, | |||
"-Dsonar.organization=organization", | |||
"-Dsonar.host.url=host", | |||
"-Dsonar.login=token", | |||
] | |||
} | |||
/> | |||
<p | |||
className="big-spacer-top markdown" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.docs" | |||
id="onboarding.analysis.docs" | |||
values={ | |||
Object { | |||
"link": <Link | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner-for-gradle/" | |||
> | |||
onboarding.analysis.java.maven.docs_link | |||
</Link>, | |||
} | |||
} | |||
/> | |||
</p> | |||
<p | |||
className="big-spacer-top markdown" | |||
> | |||
onboarding.analysis.browse_url_after_analysis | |||
</p> | |||
</div> | |||
`; | |||
exports[`renders with projectKey 1`] = ` | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.analysis.java.maven.header | |||
</h4> | |||
<p | |||
className="spacer-bottom markdown" | |||
> | |||
<InstanceMessage | |||
message="onboarding.analysis.java.maven.text" | |||
/> | |||
</p> | |||
<CodeSnippet | |||
snippet={ | |||
Array [ | |||
"mvn sonar:sonar", | |||
"-Dsonar.projectKey=foo", | |||
"-Dsonar.organization=organization", | |||
"-Dsonar.projectKey=projectKey", | |||
"-Dsonar.host.url=host", | |||
"-Dsonar.login=token", | |||
] |
@@ -1,37 +0,0 @@ | |||
// Jest Snapshot v1, https://goo.gl/fbAQLP | |||
exports[`renders correctly 1`] = ` | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.analysis.msbuild.header | |||
</h4> | |||
<p | |||
className="spacer-bottom markdown" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.msbuild.text" | |||
id="onboarding.analysis.msbuild.text" | |||
values={ | |||
Object { | |||
"code": <code> | |||
%PATH% | |||
</code>, | |||
} | |||
} | |||
/> | |||
</p> | |||
<p> | |||
<Link | |||
className="button" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner-for-msbuild/" | |||
> | |||
download_verb | |||
</Link> | |||
</p> | |||
</div> | |||
`; |
@@ -1,10 +1,43 @@ | |||
// Jest Snapshot v1, https://goo.gl/fbAQLP | |||
exports[`renders correctly 1`] = ` | |||
exports[`renders correctly: linux 1`] = ` | |||
<div> | |||
<SQScanner | |||
os="win" | |||
/> | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.analysis.sq_scanner.header.linux | |||
</h4> | |||
<p | |||
className="spacer-bottom markdown" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.sq_scanner.text" | |||
id="onboarding.analysis.sq_scanner.text" | |||
values={ | |||
Object { | |||
"dir": <code> | |||
bin | |||
</code>, | |||
"env_var": <code> | |||
PATH | |||
</code>, | |||
} | |||
} | |||
/> | |||
</p> | |||
<p> | |||
<Link | |||
className="button" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner/" | |||
> | |||
download_verb | |||
</Link> | |||
</p> | |||
</div> | |||
<h4 | |||
className="huge-spacer-top spacer-bottom" | |||
> | |||
@@ -16,15 +49,14 @@ exports[`renders correctly 1`] = ` | |||
<Component /> | |||
</InstanceMessage> | |||
<CodeSnippet | |||
isOneLine={true} | |||
isOneLine={false} | |||
snippet={ | |||
Array [ | |||
"sonar-scanner.bat", | |||
"-D\\"sonar.projectKey=projectKey\\"", | |||
undefined, | |||
"-D\\"sonar.sources=.\\"", | |||
"-D\\"sonar.host.url=host\\"", | |||
"-D\\"sonar.login=token\\"", | |||
"sonar-scanner", | |||
"-Dsonar.projectKey=projectKey", | |||
"-Dsonar.sources=.", | |||
"-Dsonar.host.url=host", | |||
"-Dsonar.login=token", | |||
] | |||
} | |||
/> | |||
@@ -51,11 +83,44 @@ exports[`renders correctly 1`] = ` | |||
</div> | |||
`; | |||
exports[`renders correctly 2`] = ` | |||
exports[`renders correctly: macos 1`] = ` | |||
<div> | |||
<SQScanner | |||
os="linux" | |||
/> | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.analysis.sq_scanner.header.mac | |||
</h4> | |||
<p | |||
className="spacer-bottom markdown" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.sq_scanner.text" | |||
id="onboarding.analysis.sq_scanner.text" | |||
values={ | |||
Object { | |||
"dir": <code> | |||
bin | |||
</code>, | |||
"env_var": <code> | |||
PATH | |||
</code>, | |||
} | |||
} | |||
/> | |||
</p> | |||
<p> | |||
<Link | |||
className="button" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner/" | |||
> | |||
download_verb | |||
</Link> | |||
</p> | |||
</div> | |||
<h4 | |||
className="huge-spacer-top spacer-bottom" | |||
> | |||
@@ -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`] = ` | |||
</div> | |||
`; | |||
exports[`renders correctly 3`] = ` | |||
exports[`renders correctly: windows 1`] = ` | |||
<div> | |||
<SQScanner | |||
os="linux" | |||
/> | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.analysis.sq_scanner.header.win | |||
</h4> | |||
<p | |||
className="spacer-bottom markdown" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.sq_scanner.text" | |||
id="onboarding.analysis.sq_scanner.text" | |||
values={ | |||
Object { | |||
"dir": <code> | |||
bin | |||
</code>, | |||
"env_var": <code> | |||
%PATH% | |||
</code>, | |||
} | |||
} | |||
/> | |||
</p> | |||
<p> | |||
<Link | |||
className="button" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner/" | |||
> | |||
download_verb | |||
</Link> | |||
</p> | |||
</div> | |||
<h4 | |||
className="huge-spacer-top spacer-bottom" | |||
> | |||
@@ -118,15 +215,14 @@ exports[`renders correctly 3`] = ` | |||
<Component /> | |||
</InstanceMessage> | |||
<CodeSnippet | |||
isOneLine={false} | |||
isOneLine={true} | |||
snippet={ | |||
Array [ | |||
"sonar-scanner", | |||
"-Dsonar.projectKey=projectKey", | |||
undefined, | |||
"-Dsonar.sources=.", | |||
"-Dsonar.host.url=host", | |||
"-Dsonar.login=token", | |||
"sonar-scanner.bat", | |||
"-D\\"sonar.projectKey=projectKey\\"", | |||
"-D\\"sonar.sources=.\\"", | |||
"-D\\"sonar.host.url=host\\"", | |||
"-D\\"sonar.login=token\\"", | |||
] | |||
} | |||
/> |
@@ -1,118 +0,0 @@ | |||
// Jest Snapshot v1, https://goo.gl/fbAQLP | |||
exports[`renders correctly 1`] = ` | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.analysis.sq_scanner.header.win | |||
</h4> | |||
<p | |||
className="spacer-bottom markdown" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.sq_scanner.text" | |||
id="onboarding.analysis.sq_scanner.text" | |||
values={ | |||
Object { | |||
"dir": <code> | |||
bin | |||
</code>, | |||
"env_var": <code> | |||
%PATH% | |||
</code>, | |||
} | |||
} | |||
/> | |||
</p> | |||
<p> | |||
<Link | |||
className="button" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner/" | |||
> | |||
download_verb | |||
</Link> | |||
</p> | |||
</div> | |||
`; | |||
exports[`renders correctly 2`] = ` | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.analysis.sq_scanner.header.linux | |||
</h4> | |||
<p | |||
className="spacer-bottom markdown" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.sq_scanner.text" | |||
id="onboarding.analysis.sq_scanner.text" | |||
values={ | |||
Object { | |||
"dir": <code> | |||
bin | |||
</code>, | |||
"env_var": <code> | |||
PATH | |||
</code>, | |||
} | |||
} | |||
/> | |||
</p> | |||
<p> | |||
<Link | |||
className="button" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner/" | |||
> | |||
download_verb | |||
</Link> | |||
</p> | |||
</div> | |||
`; | |||
exports[`renders correctly 3`] = ` | |||
<div> | |||
<h4 | |||
className="spacer-bottom" | |||
> | |||
onboarding.analysis.sq_scanner.header.mac | |||
</h4> | |||
<p | |||
className="spacer-bottom markdown" | |||
> | |||
<FormattedMessage | |||
defaultMessage="onboarding.analysis.sq_scanner.text" | |||
id="onboarding.analysis.sq_scanner.text" | |||
values={ | |||
Object { | |||
"dir": <code> | |||
bin | |||
</code>, | |||
"env_var": <code> | |||
PATH | |||
</code>, | |||
} | |||
} | |||
/> | |||
</p> | |||
<p> | |||
<Link | |||
className="button" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
target="_blank" | |||
to="/documentation/analysis/scan/sonarscanner/" | |||
> | |||
download_verb | |||
</Link> | |||
</p> | |||
</div> | |||
`; |
@@ -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 }; |
@@ -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; |
@@ -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(); | |||
}); | |||
}); |
@@ -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; | |||
} |
@@ -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 |