diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/tutorials/onboarding/AnalysisStep.js')
-rw-r--r-- | server/sonar-web/src/main/js/apps/tutorials/onboarding/AnalysisStep.js | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/AnalysisStep.js b/server/sonar-web/src/main/js/apps/tutorials/onboarding/AnalysisStep.js new file mode 100644 index 00000000000..78db84e6ef9 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/AnalysisStep.js @@ -0,0 +1,181 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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. + */ +// @flow +import React from 'react'; +import Step from './Step'; +import LanguageStep from './LanguageStep'; +import type { Result } from './LanguageStep'; +import JavaMaven from './commands/JavaMaven'; +import JavaGradle from './commands/JavaGradle'; +import DotNet from './commands/DotNet'; +import Msvc from './commands/Msvc'; +import ClangGCC from './commands/ClangGCC'; +import Other from './commands/Other'; +import { translate } from '../../../helpers/l10n'; + +type Props = {| + open: boolean, + organization?: string, + sonarCloud: boolean, + stepNumber: number, + token: string +|}; + +type State = { + result?: Result +}; + +export default class AnalysisStep extends React.PureComponent { + props: Props; + state: State = {}; + + handleLanguageSelect = (result?: Result) => { + this.setState({ result }); + }; + + handleLanguageReset = () => { + this.setState({ result: undefined }); + }; + + getHost = () => window.location.origin + window.baseUrl; + + renderForm = () => { + return ( + <div className="boxed-group-inner"> + <div className="flex-columns"> + <div className="flex-column flex-column-half bordered-right"> + <LanguageStep + onDone={this.handleLanguageSelect} + onReset={this.handleLanguageReset} + sonarCloud={this.props.sonarCloud} + /> + </div> + <div className="flex-column flex-column-half"> + {this.renderCommand()} + </div> + </div> + </div> + ); + }; + + renderFormattedCommand = (...lines: Array<string>) => ( + <pre>{lines.join(' ' + '\\' + '\n' + ' ')}</pre> + ); + + renderCommand = () => { + const { result } = this.state; + + if (!result) { + return null; + } + + if (result.language === 'java') { + return result.javaBuild === 'maven' + ? this.renderCommandForMaven() + : this.renderCommandForGradle(); + } else if (result.language === 'dotnet') { + return this.renderCommandForDotNet(); + } else if (result.language === 'c-family') { + return result.cFamilyCompiler === 'msvc' + ? this.renderCommandForMSVC() + : this.renderCommandForClangGCC(); + } else { + return this.renderCommandForOther(); + } + }; + + renderCommandForMaven = () => ( + <JavaMaven + host={this.getHost()} + organization={this.props.organization} + token={this.props.token} + /> + ); + + renderCommandForGradle = () => ( + <JavaGradle + host={this.getHost()} + organization={this.props.organization} + token={this.props.token} + /> + ); + + renderCommandForDotNet = () => { + return ( + <DotNet + host={this.getHost()} + organization={this.props.organization} + // $FlowFixMe + projectKey={this.state.result.projectKey} + token={this.props.token} + /> + ); + }; + + renderCommandForMSVC = () => { + return ( + <Msvc + host={this.getHost()} + organization={this.props.organization} + // $FlowFixMe + projectKey={this.state.result.projectKey} + token={this.props.token} + /> + ); + }; + + renderCommandForClangGCC = () => ( + <ClangGCC + host={this.getHost()} + organization={this.props.organization} + // $FlowFixMe + os={this.state.result.os} + // $FlowFixMe + projectKey={this.state.result.projectKey} + token={this.props.token} + /> + ); + + renderCommandForOther = () => ( + <Other + host={this.getHost()} + organization={this.props.organization} + // $FlowFixMe + os={this.state.result.os} + // $FlowFixMe + projectKey={this.state.result.projectKey} + token={this.props.token} + /> + ); + + renderResult = () => null; + + render() { + return ( + <Step + open={this.props.open} + renderForm={this.renderForm} + renderResult={this.renderResult} + stepNumber={this.props.stepNumber} + stepTitle={translate('onboarding.analysis.header')} + /> + ); + } +} |