1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*
* SonarQube
* Copyright (C) 2009-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { NumberedList, NumberedListItem, TutorialStep } from 'design-system';
import * as React from 'react';
import { translate } from '../../../helpers/l10n';
import { Component } from '../../../types/types';
import { withCLanguageFeature } from '../../hoc/withCLanguageFeature';
import BuildConfigSelection from '../components/BuildConfigSelection';
import { BuildTools, TutorialConfig, TutorialModes } from '../types';
import CFamily from './buildtool-steps/CFamily';
import DotNet from './buildtool-steps/DotNet';
import Gradle from './buildtool-steps/Gradle';
import Maven from './buildtool-steps/Maven';
import Other from './buildtool-steps/Other';
const BUILDTOOL_COMPONENT_MAP: {
[x in BuildTools]: React.ComponentType<React.PropsWithChildren<LanguageProps>>;
} = {
[BuildTools.Maven]: Maven,
[BuildTools.Gradle]: Gradle,
[BuildTools.DotNet]: DotNet,
[BuildTools.Cpp]: CFamily,
[BuildTools.ObjectiveC]: CFamily,
[BuildTools.Other]: Other,
};
export interface LanguageProps {
baseUrl: string;
component: Component;
config: TutorialConfig;
}
export interface JenkinsfileStepProps {
baseUrl: string;
component: Component;
hasCLanguageFeature: boolean;
setDone: (done: boolean) => void;
}
export function JenkinsStep(props: Readonly<JenkinsfileStepProps>) {
const { component, hasCLanguageFeature, baseUrl, setDone } = props;
const [config, setConfig] = React.useState<TutorialConfig>({});
React.useEffect(() => {
setDone(Boolean(config.buildTool));
}, [config.buildTool, setDone]);
const BuildToolComponent = config.buildTool && BUILDTOOL_COMPONENT_MAP[config.buildTool];
return (
<TutorialStep title={translate('onboarding.tutorial.with.jenkins.jenkinsfile.title')}>
<NumberedList>
<NumberedListItem>
<BuildConfigSelection
ci={TutorialModes.Jenkins}
config={config}
supportCFamily={hasCLanguageFeature}
onSetConfig={setConfig}
/>
</NumberedListItem>
{BuildToolComponent && (
<BuildToolComponent config={config} component={component} baseUrl={baseUrl} />
)}
</NumberedList>
</TutorialStep>
);
}
export default withCLanguageFeature(JenkinsStep);
|