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;
}
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>();
</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);
*/
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([
function shallowRender(props: Partial<BranchesAnalysisStepProps> = {}) {
return shallow(
<BranchAnalysisStepContent
+ appState={mockAppState({ branchesEnabled: true })}
component={mockComponent()}
onStepValidationChange={jest.fn()}
{...props}
// 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
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
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