]> source.dussan.org Git - sonarqube.git/blob
08131943c922d7fb5a1c76c5553d3b4cc593b7ac
[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 import * as React from 'react';
21 import { translate } from '../../../helpers/l10n';
22 import {
23   AlmKeys,
24   AlmSettingsInstance,
25   ProjectAlmBindingResponse
26 } from '../../../types/alm-settings';
27 import AllSetStep from '../components/AllSetStep';
28 import FinishButton from '../components/FinishButton';
29 import Step from '../components/Step';
30 import YamlFileStep from '../components/YamlFileStep';
31 import AnalysisCommand from './AnalysisCommand';
32 import RepositoryVariables from './RepositoryVariables';
33
34 export enum Steps {
35   REPOSITORY_VARIABLES = 1,
36   YAML = 2,
37   ALL_SET = 3
38 }
39
40 export interface BitbucketPipelinesTutorialProps {
41   almBinding?: AlmSettingsInstance;
42   baseUrl: string;
43   component: T.Component;
44   currentUser: T.LoggedInUser;
45   projectBinding?: ProjectAlmBindingResponse;
46   willRefreshAutomatically?: boolean;
47 }
48
49 export default function BitbucketPipelinesTutorial(props: BitbucketPipelinesTutorialProps) {
50   const {
51     almBinding,
52     baseUrl,
53     currentUser,
54     component,
55     projectBinding,
56     willRefreshAutomatically
57   } = props;
58
59   const [step, setStep] = React.useState<Steps>(Steps.REPOSITORY_VARIABLES);
60   return (
61     <>
62       <Step
63         finished={step > Steps.REPOSITORY_VARIABLES}
64         onOpen={() => setStep(Steps.REPOSITORY_VARIABLES)}
65         open={step === Steps.REPOSITORY_VARIABLES}
66         renderForm={() => (
67           <RepositoryVariables
68             almBinding={almBinding}
69             baseUrl={baseUrl}
70             component={component}
71             currentUser={currentUser}
72             onDone={() => setStep(Steps.YAML)}
73             projectBinding={projectBinding}
74           />
75         )}
76         stepNumber={Steps.REPOSITORY_VARIABLES}
77         stepTitle={translate('onboarding.tutorial.with.bitbucket_pipelines.create_secret.title')}
78       />
79       <Step
80         finished={step > Steps.YAML}
81         onOpen={() => setStep(Steps.YAML)}
82         open={step === Steps.YAML}
83         renderForm={() => (
84           <YamlFileStep>
85             {buildTool => (
86               <>
87                 <AnalysisCommand buildTool={buildTool} component={component} />
88                 <FinishButton onClick={() => setStep(Steps.ALL_SET)} />
89               </>
90             )}
91           </YamlFileStep>
92         )}
93         stepNumber={Steps.YAML}
94         stepTitle={translate('onboarding.tutorial.with.bitbucket_pipelines.yaml.title')}
95       />
96       <AllSetStep
97         alm={almBinding?.alm || AlmKeys.BitbucketCloud}
98         open={step === Steps.ALL_SET}
99         stepNumber={Steps.ALL_SET}
100         willRefreshAutomatically={willRefreshAutomatically}
101       />
102     </>
103   );
104 }