/* * SonarQube * Copyright (C) 2009-2016 SonarSource SA * mailto:contact 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 React from 'react'; import keyBy from 'lodash/keyBy'; import LoginSection from './LoginSection'; import LoginForm from './LoginForm'; import AboutProjects from './AboutProjects'; import AboutCleanCode from './AboutCleanCode'; import AboutIssues from './AboutIssues'; import AboutQualityGates from './AboutQualityGates'; import AboutLeakPeriod from './AboutLeakPeriod'; import AboutStandards from './AboutStandards'; import AboutScanners from './AboutScanners'; import { translate } from '../../../helpers/l10n'; import '../styles.css'; import { searchProjects } from '../../../api/components'; import { getFacet } from '../../../api/issues'; export default class AboutApp extends React.Component { state = { loading: true }; componentDidMount () { this.mounted = true; this.loadData(); } componentWillUnmount () { this.mounted = false; } loadProjects () { return searchProjects({ ps: 1 }).then(r => r.paging.total); } loadIssues () { return getFacet({ resolved: false }, 'types').then(r => keyBy(r.facet, 'val')); } loadData () { Promise.all([ window.sonarqube.appStarted, this.loadProjects(), this.loadIssues() ]).then(responses => { if (this.mounted) { const [options, projectsCount, issueTypes] = responses; this.setState({ projectsCount, issueTypes, logoUrl: options.logoUrl, logoWidth: options.logoWidth, loading: false }); } }); } render () { if (this.state.loading) { return null; } const isAuthenticated = !!window.SS.user; const { signUpAllowed, landingText } = window.sonarqube; const loginFormShown = !isAuthenticated && this.props.location.query.login !== undefined; const logoUrl = this.state.logoUrl || `${window.baseUrl}/images/logo.svg`; const logoWidth = this.state.logoWidth || 100; const logoHeight = 30; const logoTitle = this.state.logoUrl ? '' : translate('layout.sonar.slogan'); return (
{logoTitle}/
{loginFormShown ? (
) : (
{!isAuthenticated && }
)} {signUpAllowed && (
No account yet? Sign up
)}
{landingText.length > 0 && (
)}
); } }