Browse Source

SONAR-14352 Azure DevOps tutorial for CE

tags/8.7.0.41497
Jeremy Davis 3 years ago
parent
commit
23ea081c88

+ 35
- 19
server/sonar-web/src/main/js/components/tutorials/azure-pipelines/BranchAnalysisStepContent.tsx View File

@@ -24,10 +24,12 @@ import { ClipboardIconButton } from 'sonar-ui-common/components/controls/clipboa
import { Alert } from 'sonar-ui-common/components/ui/Alert';
import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n';
import CodeSnippet from '../../common/CodeSnippet';
import { withAppState } from '../../hoc/withAppState';
import RenderOptions from '../components/RenderOptions';
import SentenceWithHighlights from '../components/SentenceWithHighlights';

export interface BranchesAnalysisStepProps {
appState: T.AppState;
component: T.Component;
onStepValidationChange: (isValid: boolean) => void;
}
@@ -39,8 +41,12 @@ export enum BuildTechnology {
Other = 'other'
}

export default function BranchAnalysisStepContent(props: BranchesAnalysisStepProps) {
const { component, onStepValidationChange } = props;
export function BranchAnalysisStepContent(props: BranchesAnalysisStepProps) {
const {
appState: { branchesEnabled },
component,
onStepValidationChange
} = props;

const [buildTechnology, setBuildTechnology] = React.useState<BuildTechnology | undefined>();

@@ -179,29 +185,39 @@ sonar.projectKey=${component.key}`;
</li>
<li>
<SentenceWithHighlights
translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.continous_integration"
translationKey={
branchesEnabled
? 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.continous_integration'
: 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.continous_integration.no_branches'
}
highlightKeys={['tab', 'continuous_integration']}
/>
</li>
<hr />
<FormattedMessage
id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.branch_protection"
defaultMessage={translate(
'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.branch_protection'
)}
values={{
link: (
<Link to="/documentation/analysis/azuredevops-integration/" target="_blank">
{translate(
'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.branch_protection.link'
)}
</Link>
)
}}
/>
{branchesEnabled && (
<>
<hr />
<FormattedMessage
id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.branch_protection"
defaultMessage={translate(
'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.branch_protection'
)}
values={{
link: (
<Link to="/documentation/analysis/azuredevops-integration/" target="_blank">
{translate(
'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.branch_protection.link'
)}
</Link>
)
}}
/>
</>
)}
</>
)}
</ol>
</>
);
}

export default withAppState(BranchAnalysisStepContent);

+ 8
- 4
server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/BranchAnalysisStepContent-test.tsx View File

@@ -19,16 +19,19 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
import { mockComponent } from '../../../../helpers/testMocks';
import { mockAppState, mockComponent } from '../../../../helpers/testMocks';
import RenderOptions from '../../components/RenderOptions';
import BranchAnalysisStepContent, {
import {
BranchAnalysisStepContent,
BranchesAnalysisStepProps,
BuildTechnology
} from '../BranchAnalysisStepContent';

it('should render correctly', () => {
const wrapper = shallowRender();
expect(wrapper).toMatchSnapshot();
expect(shallowRender()).toMatchSnapshot('branches enabled');
expect(shallowRender({ appState: mockAppState({ branchesEnabled: false }) })).toMatchSnapshot(
'branches not enabled'
);
});

it.each([
@@ -49,6 +52,7 @@ it.each([
function shallowRender(props: Partial<BranchesAnalysisStepProps> = {}) {
return shallow(
<BranchAnalysisStepContent
appState={mockAppState({ branchesEnabled: true })}
component={mockComponent()}
onStepValidationChange={jest.fn()}
{...props}

+ 25
- 1
server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/BranchAnalysisStepContent-test.tsx.snap View File

@@ -1,6 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should render correctly 1`] = `
exports[`should render correctly: branches enabled 1`] = `
<Fragment>
<span>
onboarding.build
</span>
<RenderOptions
name="buildTechnology"
onCheck={[Function]}
optionLabelKey="onboarding.build"
options={
Array [
"dotnet",
"maven",
"gradle",
"other",
]
}
/>
<ol
className="list-styled big-spacer-top"
/>
</Fragment>
`;

exports[`should render correctly: branches not enabled 1`] = `
<Fragment>
<span>
onboarding.build

+ 4
- 1
sonar-core/src/main/resources/org/sonar/l10n/core.properties View File

@@ -3498,7 +3498,7 @@ onboarding.tutorial.with.azure_pipelines.ServiceEndpoint.step3.sentence=Enter a
onboarding.tutorial.with.azure_pipelines.ServiceEndpoint.step4.sentence=Enter your SonarQube server url: {url} {button}
onboarding.tutorial.with.azure_pipelines.ServiceEndpoint.step5.sentence=Enter an existing token, or a newly generated one
onboarding.tutorial.with.azure_pipelines.ServiceEndpoint.step6.sentence=Create the service connection
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.title=Configure Branch analysis
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.title=Configure analysis
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.sentence=In Azure DevOps Server, create or edit a {pipeline} and add a new {task} task {before} your build task
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.sentence.pipeline=Build Pipeline
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.sentence.task=Prepare Analysis Configuration
@@ -3530,6 +3530,9 @@ onboarding.tutorial.with.azure_pipelines.BranchAnalysis.publish_qg.sentence.task
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.continous_integration.sentence=Under the {tab} tab of your pipeline, check {continuous_integration} and select all the branches for which you want the SonarQube analysis to run automatically
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.continous_integration.sentence.tab=Triggers
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.continous_integration.sentence.continuous_integration=Enable continuous integration
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.continous_integration.no_branches.sentence=Under the {tab} tab of your pipeline, check {continuous_integration} and select the main branch
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.continous_integration.no_branches.sentence.tab=Triggers
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.continous_integration.no_branches.sentence.continuous_integration=Enable continuous integration
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.branch_protection=To make sure your Pull Requests are analyzed automatically and aren't merged when they're failing their quality gate, check out the {link}.
onboarding.tutorial.with.azure_pipelines.BranchAnalysis.branch_protection.link=documentation
onboarding.tutorial.with.azure_pipelines.SaveAndRun.title=Save and run your pipeline

Loading…
Cancel
Save