]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-14352 Azure DevOps tutorial for CE
authorJeremy Davis <jeremy.davis@sonarsource.com>
Tue, 26 Jan 2021 16:53:44 +0000 (17:53 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 4 Feb 2021 20:07:06 +0000 (20:07 +0000)
server/sonar-web/src/main/js/components/tutorials/azure-pipelines/BranchAnalysisStepContent.tsx
server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/BranchAnalysisStepContent-test.tsx
server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/BranchAnalysisStepContent-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index c79ff921b11c591921d8202cdb77216a3940c429..211661ac723c89b31ef8cac027415a9072e37ae5 100644 (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);
index 9b7757e40806b1d6d78b3dc7a0ea17438d828f70..16e004a6c3893ee4c40a0386fccd5ef5836b9942 100644 (file)
  */
 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}
index 07602310f0f685023ec8f3c45234bdb8ddb84f81..2af6fbe23a922ada958d1be3377a0d7b5230e03c 100644 (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
index 318ff9800d4890aec7a7f24590b03c5dc761dbc0..50ef223c1433111dae8016c9fe17346bc41408f0 100644 (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