/* * SonarQube * Copyright (C) 2009-2019 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. */ /* eslint-disable react/jsx-sort-props */ import * as React from 'react'; import { render } from 'react-dom'; import { Router, Route, IndexRoute, Redirect, RouteProps, RouteConfig } from 'react-router'; import { Provider } from 'react-redux'; import { IntlProvider } from 'react-intl'; import { Location } from 'history'; import getStore from './getStore'; import getHistory from './getHistory'; import MigrationContainer from '../components/MigrationContainer'; import App from '../components/App'; import GlobalContainer from '../components/GlobalContainer'; import aboutRoutes from '../../apps/about/routes'; import accountRoutes from '../../apps/account/routes'; import backgroundTasksRoutes from '../../apps/background-tasks/routes'; import codeRoutes from '../../apps/code/routes'; import codingRulesRoutes from '../../apps/coding-rules/routes'; import componentMeasuresRoutes from '../../apps/component-measures/routes'; import customMeasuresRoutes from '../../apps/custom-measures/routes'; import groupsRoutes from '../../apps/groups/routes'; import Issues from '../../apps/issues/components/AppContainer'; import Explore from '../../apps/explore/Explore'; import ExploreIssues from '../../apps/explore/ExploreIssues'; import ExploreProjects from '../../apps/explore/ExploreProjects'; import IssuesPageSelector from '../../apps/issues/IssuesPageSelector'; import marketplaceRoutes from '../../apps/marketplace/routes'; import customMetricsRoutes from '../../apps/custom-metrics/routes'; import overviewRoutes from '../../apps/overview/routes'; import onboardingRoutes from '../../apps/tutorials/routes'; import organizationsRoutes from '../../apps/organizations/routes'; import permissionTemplatesRoutes from '../../apps/permission-templates/routes'; import portfolioRoutes from '../../apps/portfolio/routes'; import projectActivityRoutes from '../../apps/projectActivity/routes'; import projectBranchesRoutes from '../../apps/projectBranches/routes'; import projectQualityGateRoutes from '../../apps/projectQualityGate/routes'; import projectQualityProfilesRoutes from '../../apps/projectQualityProfiles/routes'; import projectsRoutes from '../../apps/projects/routes'; import projectsManagementRoutes from '../../apps/projectsManagement/routes'; import qualityGatesRoutes from '../../apps/quality-gates/routes'; import qualityProfilesRoutes from '../../apps/quality-profiles/routes'; import sessionsRoutes from '../../apps/sessions/routes'; import settingsRoutes from '../../apps/settings/routes'; import systemRoutes from '../../apps/system/routes'; import usersRoutes from '../../apps/users/routes'; import webAPIRoutes from '../../apps/web-api/routes'; import documentationRoutes from '../../apps/documentation/routes'; import webhooksRoutes from '../../apps/webhooks/routes'; import { maintenanceRoutes, setupRoutes } from '../../apps/maintenance/routes'; import { globalPermissionsRoutes, projectPermissionsRoutes } from '../../apps/permissions/routes'; import { lazyLoad } from '../../components/lazyLoad'; import { isSonarCloud } from '../../helpers/system'; function handleUpdate(this: { state: { location: Location } }) { const { action } = this.state.location; if (action === 'PUSH') { window.scrollTo(0, 0); } } // this is not an official api const RouteWithChildRoutes = Route as React.ComponentClass< RouteProps & { childRoutes: RouteConfig } >; export default function startReactApp( lang: string, currentUser?: T.CurrentUser, appState?: T.AppState ) { const el = document.getElementById('content'); const history = getHistory(); const store = getStore(currentUser, appState); render( { replace({ pathname: '/issues', query: { myIssues: 'true', resolved: 'false' } }); }} /> { replace('/coding_rules' + window.location.hash); }} /> { replace({ pathname: '/dashboard', query: { id: nextState.params.key } }); }} /> { replace('/issues' + window.location.hash); }} /> import('../components/MarkdownHelp'))} /> import('../components/SimpleContainer'))}> {maintenanceRoutes} {setupRoutes} import('../components/SimpleSessionsContainer'))}> import('../components/Landing'))} /> {!isSonarCloud() && ( )} import('../components/extensions/GlobalPageExtension'))} /> {isSonarCloud() && ( import('../../apps/create/organization/CreateOrganization') )} /> )} import('../components/extensions/PortfoliosPage'))} /> import('../components/ComponentContainer'))}> import('../components/extensions/ProjectPageExtension') )} /> import('../../apps/securityReports/components/App'))} /> import('../components/ProjectAdminContainer'))}> {!isSonarCloud() && ( )} import('../components/extensions/ProjectAdminPageExtension') )} /> import('../../apps/projectDeletion/App'))} /> import('../../apps/projectLinks/App'))} /> import('../../apps/project-admin/key/Key'))} /> import('../components/AdminContainer'))} path="admin"> import('../components/extensions/GlobalAdminPageExtension') )} /> import('../components/NotFound'))} /> import('../components/NotFound'))} /> , el ); }