]> source.dussan.org Git - sonarqube.git/blob
60bfbf86b15bdbbd2510ab6dabc907ff748dc403
[sonarqube.git] /
1 /*
2  * SonarQube
3  * Copyright (C) 2009-2021 SonarSource SA
4  * mailto:info AT sonarsource DOT com
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 3 of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20
21 import * as React from 'react';
22 import { FormattedMessage } from 'react-intl';
23 import { ClipboardIconButton } from 'sonar-ui-common/components/controls/clipboard';
24 import { translate } from 'sonar-ui-common/helpers/l10n';
25 import CodeSnippet from '../../../common/CodeSnippet';
26 import SentenceWithHighlights from '../../components/SentenceWithHighlights';
27 import { BuildTools } from '../../types';
28
29 export enum PrepareType {
30   JavaMavenGradle,
31   StandAlone,
32   MSBuild
33 }
34
35 export interface PrepareAnalysisCommandProps {
36   buildTool: BuildTools;
37   kind: PrepareType;
38   projectKey: string;
39 }
40
41 export default function PrepareAnalysisCommand(props: PrepareAnalysisCommandProps) {
42   const { buildTool, kind, projectKey } = props;
43
44   const ADDITIONAL_PROPERTY = 'sonar.cfamily.build-wrapper-output=<output directory>';
45
46   const MAVEN_GRADLE_PROPS_SNIPPET = `# Additional properties that will be passed to the scanner,
47 # Put one key=value per line, example:
48 # sonar.exclusions=**/*.bin
49 sonar.projectKey=${projectKey}`;
50
51   return (
52     <ul className="list-styled">
53       <li>
54         <SentenceWithHighlights
55           translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.endpoint"
56           highlightKeys={['endpoint']}
57         />
58       </li>
59       <li>
60         <FormattedMessage
61           id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis"
62           defaultMessage={translate(
63             'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis'
64           )}
65           values={{
66             section: (
67               <strong>
68                 {translate(
69                   'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis.section'
70                 )}
71               </strong>
72             ),
73             run_analysis_value: (
74               <strong>
75                 {translate(
76                   'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis.values',
77                   buildTool
78                 )}
79               </strong>
80             )
81           }}
82         />
83       </li>
84
85       {kind === PrepareType.StandAlone && (
86         <>
87           <li>
88             <SentenceWithHighlights
89               translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.manual"
90               highlightKeys={['mode']}
91             />
92           </li>
93
94           <li>
95             <FormattedMessage
96               id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence"
97               defaultMessage={translate(
98                 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence'
99               )}
100               values={{
101                 project_key: (
102                   <b>
103                     {translate(
104                       'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence.project_key'
105                     )}
106                   </b>
107                 ),
108                 key: <code className="rule">{projectKey}</code>,
109                 button: <ClipboardIconButton copyValue={projectKey} />
110               }}
111             />
112           </li>
113           {buildTool === BuildTools.CFamily && (
114             <li>
115               <FormattedMessage
116                 id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp"
117                 defaultMessage={translate(
118                   'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp'
119                 )}
120                 values={{
121                   advanced: (
122                     <b>
123                       {translate(
124                         'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp.advanced'
125                       )}
126                     </b>
127                   ),
128                   additional: (
129                     <b>
130                       {translate(
131                         'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp.additional'
132                       )}
133                     </b>
134                   ),
135                   property: <code className="rule">{ADDITIONAL_PROPERTY}</code>,
136                   button: <ClipboardIconButton copyValue={ADDITIONAL_PROPERTY} />
137                 }}
138               />
139             </li>
140           )}
141         </>
142       )}
143
144       {kind === PrepareType.JavaMavenGradle && (
145         <li>
146           <SentenceWithHighlights
147             translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.advanced_properties"
148             highlightKeys={['section', 'properties']}
149           />
150           :
151           <CodeSnippet snippet={MAVEN_GRADLE_PROPS_SNIPPET} />
152         </li>
153       )}
154       {kind === PrepareType.MSBuild && (
155         <li>
156           <FormattedMessage
157             id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence"
158             defaultMessage={translate(
159               'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence'
160             )}
161             values={{
162               project_key: (
163                 <b>
164                   {translate(
165                     'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence.project_key'
166                   )}
167                 </b>
168               ),
169               key: <code className="rule">{projectKey}</code>,
170               button: <ClipboardIconButton copyValue={projectKey} />
171             }}
172           />
173         </li>
174       )}
175     </ul>
176   );
177 }