/* * SonarQube * Copyright (C) 2009-2018 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 = {| onFinish: (projectKey?: string) => void, onReset: () => void, 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 | void */) => { this.setState({ result }); const projectKey = result && result.language !== 'java' ? result.projectKey : undefined; this.props.onFinish(projectKey); }; handleLanguageReset = () => { this.setState({ result: undefined }); this.props.onReset(); }; getHost = () => window.location.origin + window.baseUrl; renderForm = () => { return (
{this.renderCommand()}
); }; renderFormattedCommand = (...lines /*: Array */) => (
{lines.join(' ' + '\\' + '\n' + '  ')}
); 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 = () => ( ); renderCommandForGradle = () => ( ); renderCommandForDotNet = () => { return ( ); }; renderCommandForMSVC = () => { return ( ); }; renderCommandForClangGCC = () => ( ); renderCommandForOther = () => ( ); renderResult = () => null; render() { return ( {}} open={this.props.open} renderForm={this.renderForm} renderResult={this.renderResult} stepNumber={this.props.stepNumber} stepTitle={translate('onboarding.analysis.header')} /> ); } }