]> source.dussan.org Git - sonarqube.git/commitdiff
rewrite app utils in ts (#773)
authorStas Vilchik <stas.vilchik@sonarsource.com>
Fri, 5 Oct 2018 07:57:16 +0000 (09:57 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 10 Oct 2018 07:23:00 +0000 (09:23 +0200)
server/sonar-web/src/main/js/app/utils/getHistory.js [deleted file]
server/sonar-web/src/main/js/app/utils/getHistory.ts [new file with mode: 0644]
server/sonar-web/src/main/js/app/utils/handleRequiredAuthentication.js [deleted file]
server/sonar-web/src/main/js/app/utils/handleRequiredAuthentication.ts [new file with mode: 0644]
server/sonar-web/src/main/js/app/utils/handleRequiredAuthorization.js [deleted file]
server/sonar-web/src/main/js/app/utils/handleRequiredAuthorization.ts [new file with mode: 0644]
server/sonar-web/src/main/js/app/utils/startReactApp.js [deleted file]
server/sonar-web/src/main/js/app/utils/startReactApp.tsx [new file with mode: 0644]

diff --git a/server/sonar-web/src/main/js/app/utils/getHistory.js b/server/sonar-web/src/main/js/app/utils/getHistory.js
deleted file mode 100644 (file)
index de27292..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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 { useRouterHistory } from 'react-router';
-import { createHistory } from 'history';
-
-let history;
-
-const ensureHistory = () => {
-  history = useRouterHistory(createHistory)({
-    basename: window.baseUrl + '/'
-  });
-  return history;
-};
-
-export default () => (history ? history : ensureHistory());
diff --git a/server/sonar-web/src/main/js/app/utils/getHistory.ts b/server/sonar-web/src/main/js/app/utils/getHistory.ts
new file mode 100644 (file)
index 0000000..e23f7c5
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+import { useRouterHistory } from 'react-router';
+import { createHistory, History } from 'history';
+
+let history: History;
+
+function ensureHistory() {
+  history = useRouterHistory(createHistory)({
+    // do not use `getBaseUrl` from `helpers/urls` to no import this file with all its dependecies
+    basename: (window as any).baseUrl + '/'
+  });
+  return history;
+}
+
+export default function getHistory() {
+  return history ? history : ensureHistory();
+}
diff --git a/server/sonar-web/src/main/js/app/utils/handleRequiredAuthentication.js b/server/sonar-web/src/main/js/app/utils/handleRequiredAuthentication.js
deleted file mode 100644 (file)
index bc3a3b9..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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 getHistory from './getHistory';
-
-export default () => {
-  const history = getHistory();
-  const returnTo = window.location.pathname + window.location.search + window.location.hash;
-  history.replace({
-    pathname: '/sessions/new',
-    query: { return_to: returnTo }
-  });
-};
diff --git a/server/sonar-web/src/main/js/app/utils/handleRequiredAuthentication.ts b/server/sonar-web/src/main/js/app/utils/handleRequiredAuthentication.ts
new file mode 100644 (file)
index 0000000..aaf5732
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+import getHistory from './getHistory';
+
+export default function handleRequiredAuthentication() {
+  const history = getHistory();
+  const returnTo = window.location.pathname + window.location.search + window.location.hash;
+  history.replace({
+    pathname: '/sessions/new',
+    query: { return_to: returnTo } // eslint-disable-line camelcase
+  });
+}
diff --git a/server/sonar-web/src/main/js/app/utils/handleRequiredAuthorization.js b/server/sonar-web/src/main/js/app/utils/handleRequiredAuthorization.js
deleted file mode 100644 (file)
index eaa2cf8..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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 getStore from './getStore';
-import getHistory from './getHistory';
-import { requireAuthorization } from '../../store/appState';
-
-export default () => {
-  const store = getStore();
-  const history = getHistory();
-
-  const returnTo = window.location.pathname + window.location.search + window.location.hash;
-
-  store.dispatch(requireAuthorization());
-  history.replace({
-    pathname: '/sessions/new',
-    query: { return_to: returnTo }
-  });
-};
diff --git a/server/sonar-web/src/main/js/app/utils/handleRequiredAuthorization.ts b/server/sonar-web/src/main/js/app/utils/handleRequiredAuthorization.ts
new file mode 100644 (file)
index 0000000..a3a32b3
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+import getStore from './getStore';
+import getHistory from './getHistory';
+import { requireAuthorization } from '../../store/appState';
+
+export default function handleRequiredAuthorization() {
+  const store = getStore();
+  const history = getHistory();
+
+  const returnTo = window.location.pathname + window.location.search + window.location.hash;
+
+  store.dispatch(requireAuthorization());
+  history.replace({
+    pathname: '/sessions/new',
+    query: { return_to: returnTo } // eslint-disable-line camelcase
+  });
+}
diff --git a/server/sonar-web/src/main/js/app/utils/startReactApp.js b/server/sonar-web/src/main/js/app/utils/startReactApp.js
deleted file mode 100644 (file)
index 474e9f5..0000000
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * 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.
- */
-/* eslint-disable react/jsx-sort-props */
-import React from 'react';
-import { render } from 'react-dom';
-import { Router, Route, IndexRoute, Redirect } from 'react-router';
-import { Provider } from 'react-redux';
-import { IntlProvider } from 'react-intl';
-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 componentRoutes from '../../apps/component/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() {
-  const { action } = this.state.location;
-
-  if (action === 'PUSH') {
-    window.scrollTo(0, 0);
-  }
-}
-
-const startReactApp = (lang, currentUser, appState) => {
-  const el = document.getElementById('content');
-
-  const history = getHistory();
-  const store = getStore(currentUser, appState);
-
-  render(
-    <Provider store={store}>
-      <IntlProvider defaultLocale={lang} locale={lang}>
-        <Router history={history} onUpdate={handleUpdate}>
-          <Route
-            path="/account/issues"
-            onEnter={(_, replace) => {
-              replace({ pathname: '/issues', query: { myIssues: 'true', resolved: 'false' } });
-            }}
-          />
-
-          <Route
-            path="/codingrules"
-            onEnter={(nextState, replace) => {
-              replace('/coding_rules' + window.location.hash);
-            }}
-          />
-
-          <Route
-            path="/dashboard/index/:key"
-            onEnter={(nextState, replace) => {
-              replace({ pathname: '/dashboard', query: { id: nextState.params.key } });
-            }}
-          />
-
-          <Route
-            path="/issues/search"
-            onEnter={(nextState, replace) => {
-              replace('/issues' + window.location.hash);
-            }}
-          />
-
-          <Redirect from="/admin" to="/admin/settings" />
-          <Redirect from="/background_tasks" to="/admin/background_tasks" />
-          <Redirect from="/component/index" to="/component" />
-          <Redirect from="/component_issues" to="/project/issues" />
-          <Redirect from="/dashboard/index" to="/dashboard" />
-          <Redirect from="/governance" to="/portfolio" />
-          <Redirect from="/groups" to="/admin/groups" />
-          <Redirect from="/extension/governance/portfolios" to="/portfolios" />
-          <Redirect from="/metrics" to="/admin/custom_metrics" />
-          <Redirect from="/permission_templates" to="/admin/permission_templates" />
-          <Redirect from="/profiles/index" to="/profiles" />
-          <Redirect from="/projects_admin" to="/admin/projects_management" />
-          <Redirect from="/quality_gates/index" to="/quality_gates" />
-          <Redirect from="/roles/global" to="/admin/permissions" />
-          <Redirect from="/settings" to="/admin/settings" />
-          <Redirect from="/settings/encryption" to="/admin/settings/encryption" />
-          <Redirect from="/settings/index" to="/admin/settings" />
-          <Redirect from="/sessions/login" to="/sessions/new" />
-          <Redirect from="/system" to="/admin/system" />
-          <Redirect from="/system/index" to="/admin/system" />
-          <Redirect from="/view" to="/portfolio" />
-          <Redirect from="/users" to="/admin/users" />
-
-          <Route
-            path="markdown/help"
-            component={lazyLoad(() => import('../components/MarkdownHelp'))}
-          />
-
-          <Route component={lazyLoad(() => import('../components/SimpleContainer'))}>
-            <Route path="maintenance">{maintenanceRoutes}</Route>
-            <Route path="setup">{setupRoutes}</Route>
-          </Route>
-
-          <Route component={MigrationContainer}>
-            <Route component={lazyLoad(() => import('../components/SimpleSessionsContainer'))}>
-              <Route path="/sessions" childRoutes={sessionsRoutes} />
-            </Route>
-
-            <Route path="/" component={App}>
-              <IndexRoute component={lazyLoad(() => import('../components/Landing'))} />
-              <Route path="about" childRoutes={aboutRoutes} />
-
-              <Route component={GlobalContainer}>
-                <Route path="account" childRoutes={accountRoutes} />
-                <Route path="coding_rules" childRoutes={codingRulesRoutes} />
-                <Route path="component" childRoutes={componentRoutes} />
-                <Route path="documentation" childRoutes={documentationRoutes} />
-                <Route path="explore" component={Explore}>
-                  <Route path="issues" component={ExploreIssues} />
-                  <Route path="projects" component={ExploreProjects} />
-                </Route>
-                <Route
-                  path="extension/:pluginKey/:extensionKey"
-                  component={lazyLoad(() => import('../components/extensions/GlobalPageExtension'))}
-                />
-                <Route path="issues" component={IssuesPageSelector} />
-                <Route path="onboarding" childRoutes={onboardingRoutes} />
-                {isSonarCloud() && (
-                  <Route
-                    path="create-organization"
-                    component={lazyLoad(() =>
-                      import('../../apps/create/organization/CreateOrganization')
-                    )}
-                  />
-                )}
-                <Route path="organizations" childRoutes={organizationsRoutes} />
-                <Route path="projects" childRoutes={projectsRoutes} />
-                <Route path="quality_gates" childRoutes={qualityGatesRoutes} />
-                <Route
-                  path="portfolios"
-                  component={lazyLoad(() => import('../components/extensions/PortfoliosPage'))}
-                />
-                <Route path="profiles" childRoutes={qualityProfilesRoutes} />
-                <Route path="web_api" childRoutes={webAPIRoutes} />
-
-                <Route component={lazyLoad(() => import('../components/ComponentContainer'))}>
-                  <Route path="code" childRoutes={codeRoutes} />
-                  <Route path="component_measures" childRoutes={componentMeasuresRoutes} />
-                  <Route path="dashboard" childRoutes={overviewRoutes} />
-                  <Route path="portfolio" childRoutes={portfolioRoutes} />
-                  <Route path="project/activity" childRoutes={projectActivityRoutes} />
-                  <Route
-                    path="project/extension/:pluginKey/:extensionKey"
-                    component={lazyLoad(() =>
-                      import('../components/extensions/ProjectPageExtension')
-                    )}
-                  />
-                  <Route path="project/issues" component={Issues} />
-                  <Route
-                    path="project/security_reports/:type"
-                    component={lazyLoad(() => import('../../apps/securityReports/components/App'))}
-                  />
-                  <Route path="project/quality_gate" childRoutes={projectQualityGateRoutes} />
-                  <Route
-                    path="project/quality_profiles"
-                    childRoutes={projectQualityProfilesRoutes}
-                  />
-                  <Route component={lazyLoad(() => import('../components/ProjectAdminContainer'))}>
-                    <Route path="custom_measures" childRoutes={customMeasuresRoutes} />
-                    <Route
-                      path="project/admin/extension/:pluginKey/:extensionKey"
-                      component={lazyLoad(() =>
-                        import('../components/extensions/ProjectAdminPageExtension')
-                      )}
-                    />
-                    <Route path="project/background_tasks" childRoutes={backgroundTasksRoutes} />
-                    <Route path="project/branches" childRoutes={projectBranchesRoutes} />
-                    <Route path="project/settings" childRoutes={settingsRoutes} />
-                    <Route path="project_roles" childRoutes={projectPermissionsRoutes} />
-                    <Route path="project/webhooks" childRoutes={webhooksRoutes} />
-                    <Route
-                      path="project/deletion"
-                      component={lazyLoad(() => import('../../apps/projectDeletion/App'))}
-                    />
-                    <Route
-                      path="project/links"
-                      component={lazyLoad(() => import('../../apps/projectLinks/App'))}
-                    />
-                    <Route
-                      path="project/key"
-                      component={lazyLoad(() => import('../../apps/project-admin/key/Key'))}
-                    />
-                  </Route>
-                </Route>
-
-                <Route
-                  component={lazyLoad(() => import('../components/AdminContainer'))}
-                  path="admin">
-                  <Route
-                    path="extension/:pluginKey/:extensionKey"
-                    component={lazyLoad(() =>
-                      import('../components/extensions/GlobalAdminPageExtension')
-                    )}
-                  />
-                  <Route path="background_tasks" childRoutes={backgroundTasksRoutes} />
-                  <Route path="custom_metrics" childRoutes={customMetricsRoutes} />
-                  <Route path="groups" childRoutes={groupsRoutes} />
-                  <Route path="permission_templates" childRoutes={permissionTemplatesRoutes} />
-                  <Route path="roles/global" childRoutes={globalPermissionsRoutes} />
-                  <Route path="permissions" childRoutes={globalPermissionsRoutes} />
-                  <Route path="projects_management" childRoutes={projectsManagementRoutes} />
-                  <Route path="settings" childRoutes={settingsRoutes} />
-                  <Route path="system" childRoutes={systemRoutes} />
-                  <Route path="marketplace" childRoutes={marketplaceRoutes} />
-                  <Route path="users" childRoutes={usersRoutes} />
-                  <Route path="webhooks" childRoutes={webhooksRoutes} />
-                </Route>
-              </Route>
-              <Route
-                path="not_found"
-                component={lazyLoad(() => import('../components/NotFound'))}
-              />
-              <Route path="*" component={lazyLoad(() => import('../components/NotFound'))} />
-            </Route>
-          </Route>
-        </Router>
-      </IntlProvider>
-    </Provider>,
-    el
-  );
-};
-
-export default startReactApp;
diff --git a/server/sonar-web/src/main/js/app/utils/startReactApp.tsx b/server/sonar-web/src/main/js/app/utils/startReactApp.tsx
new file mode 100644 (file)
index 0000000..78bd52c
--- /dev/null
@@ -0,0 +1,319 @@
+/*
+ * 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.
+ */
+/* 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 componentRoutes from '../../apps/component/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';
+import { CurrentUser, AppState } from '../types';
+
+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?: CurrentUser,
+  appState?: AppState
+) {
+  const el = document.getElementById('content');
+
+  const history = getHistory();
+  const store = getStore(currentUser, appState);
+
+  render(
+    <Provider store={store}>
+      <IntlProvider defaultLocale={lang} locale={lang}>
+        <Router history={history} onUpdate={handleUpdate}>
+          <Route
+            path="/account/issues"
+            onEnter={(_, replace) => {
+              replace({ pathname: '/issues', query: { myIssues: 'true', resolved: 'false' } });
+            }}
+          />
+
+          <Route
+            path="/codingrules"
+            onEnter={(_, replace) => {
+              replace('/coding_rules' + window.location.hash);
+            }}
+          />
+
+          <Route
+            path="/dashboard/index/:key"
+            onEnter={(nextState, replace) => {
+              replace({ pathname: '/dashboard', query: { id: nextState.params.key } });
+            }}
+          />
+
+          <Route
+            path="/issues/search"
+            onEnter={(_, replace) => {
+              replace('/issues' + window.location.hash);
+            }}
+          />
+
+          <Redirect from="/admin" to="/admin/settings" />
+          <Redirect from="/background_tasks" to="/admin/background_tasks" />
+          <Redirect from="/component/index" to="/component" />
+          <Redirect from="/component_issues" to="/project/issues" />
+          <Redirect from="/dashboard/index" to="/dashboard" />
+          <Redirect from="/governance" to="/portfolio" />
+          <Redirect from="/groups" to="/admin/groups" />
+          <Redirect from="/extension/governance/portfolios" to="/portfolios" />
+          <Redirect from="/metrics" to="/admin/custom_metrics" />
+          <Redirect from="/permission_templates" to="/admin/permission_templates" />
+          <Redirect from="/profiles/index" to="/profiles" />
+          <Redirect from="/projects_admin" to="/admin/projects_management" />
+          <Redirect from="/quality_gates/index" to="/quality_gates" />
+          <Redirect from="/roles/global" to="/admin/permissions" />
+          <Redirect from="/settings" to="/admin/settings" />
+          <Redirect from="/settings/encryption" to="/admin/settings/encryption" />
+          <Redirect from="/settings/index" to="/admin/settings" />
+          <Redirect from="/sessions/login" to="/sessions/new" />
+          <Redirect from="/system" to="/admin/system" />
+          <Redirect from="/system/index" to="/admin/system" />
+          <Redirect from="/view" to="/portfolio" />
+          <Redirect from="/users" to="/admin/users" />
+
+          <Route
+            path="markdown/help"
+            component={lazyLoad(() => import('../components/MarkdownHelp'))}
+          />
+
+          <Route component={lazyLoad(() => import('../components/SimpleContainer'))}>
+            <Route path="maintenance">{maintenanceRoutes}</Route>
+            <Route path="setup">{setupRoutes}</Route>
+          </Route>
+
+          <Route component={MigrationContainer}>
+            <Route component={lazyLoad(() => import('../components/SimpleSessionsContainer'))}>
+              <RouteWithChildRoutes path="/sessions" childRoutes={sessionsRoutes} />
+            </Route>
+
+            <Route path="/" component={App}>
+              <IndexRoute component={lazyLoad(() => import('../components/Landing'))} />
+              <RouteWithChildRoutes path="about" childRoutes={aboutRoutes} />
+
+              <Route component={GlobalContainer}>
+                <RouteWithChildRoutes path="account" childRoutes={accountRoutes} />
+                <RouteWithChildRoutes path="coding_rules" childRoutes={codingRulesRoutes} />
+                <RouteWithChildRoutes path="component" childRoutes={componentRoutes} />
+                <RouteWithChildRoutes path="documentation" childRoutes={documentationRoutes} />
+                <Route path="explore" component={Explore}>
+                  <Route path="issues" component={ExploreIssues} />
+                  <Route path="projects" component={ExploreProjects} />
+                </Route>
+                <Route
+                  path="extension/:pluginKey/:extensionKey"
+                  component={lazyLoad(() => import('../components/extensions/GlobalPageExtension'))}
+                />
+                <Route path="issues" component={IssuesPageSelector} />
+                <RouteWithChildRoutes path="onboarding" childRoutes={onboardingRoutes} />
+                {isSonarCloud() && (
+                  <Route
+                    path="create-organization"
+                    component={lazyLoad(() =>
+                      import('../../apps/create/organization/CreateOrganization')
+                    )}
+                  />
+                )}
+                <RouteWithChildRoutes path="organizations" childRoutes={organizationsRoutes} />
+                <RouteWithChildRoutes path="projects" childRoutes={projectsRoutes} />
+                <RouteWithChildRoutes path="quality_gates" childRoutes={qualityGatesRoutes} />
+                <Route
+                  path="portfolios"
+                  component={lazyLoad(() => import('../components/extensions/PortfoliosPage'))}
+                />
+                <RouteWithChildRoutes path="profiles" childRoutes={qualityProfilesRoutes} />
+                <RouteWithChildRoutes path="web_api" childRoutes={webAPIRoutes} />
+
+                <Route component={lazyLoad(() => import('../components/ComponentContainer'))}>
+                  <RouteWithChildRoutes path="code" childRoutes={codeRoutes} />
+                  <RouteWithChildRoutes
+                    path="component_measures"
+                    childRoutes={componentMeasuresRoutes}
+                  />
+                  <RouteWithChildRoutes path="dashboard" childRoutes={overviewRoutes} />
+                  <RouteWithChildRoutes path="portfolio" childRoutes={portfolioRoutes} />
+                  <RouteWithChildRoutes
+                    path="project/activity"
+                    childRoutes={projectActivityRoutes}
+                  />
+                  <Route
+                    path="project/extension/:pluginKey/:extensionKey"
+                    component={lazyLoad(() =>
+                      import('../components/extensions/ProjectPageExtension')
+                    )}
+                  />
+                  <Route path="project/issues" component={Issues} />
+                  <Route
+                    path="project/security_reports/:type"
+                    component={lazyLoad(() => import('../../apps/securityReports/components/App'))}
+                  />
+                  <RouteWithChildRoutes
+                    path="project/quality_gate"
+                    childRoutes={projectQualityGateRoutes}
+                  />
+                  <RouteWithChildRoutes
+                    path="project/quality_profiles"
+                    childRoutes={projectQualityProfilesRoutes}
+                  />
+                  <Route component={lazyLoad(() => import('../components/ProjectAdminContainer'))}>
+                    <RouteWithChildRoutes
+                      path="custom_measures"
+                      childRoutes={customMeasuresRoutes}
+                    />
+                    <Route
+                      path="project/admin/extension/:pluginKey/:extensionKey"
+                      component={lazyLoad(() =>
+                        import('../components/extensions/ProjectAdminPageExtension')
+                      )}
+                    />
+                    <RouteWithChildRoutes
+                      path="project/background_tasks"
+                      childRoutes={backgroundTasksRoutes}
+                    />
+                    <RouteWithChildRoutes
+                      path="project/branches"
+                      childRoutes={projectBranchesRoutes}
+                    />
+                    <RouteWithChildRoutes path="project/settings" childRoutes={settingsRoutes} />
+                    <RouteWithChildRoutes
+                      path="project_roles"
+                      childRoutes={projectPermissionsRoutes}
+                    />
+                    <RouteWithChildRoutes path="project/webhooks" childRoutes={webhooksRoutes} />
+                    <Route
+                      path="project/deletion"
+                      component={lazyLoad(() => import('../../apps/projectDeletion/App'))}
+                    />
+                    <Route
+                      path="project/links"
+                      component={lazyLoad(() => import('../../apps/projectLinks/App'))}
+                    />
+                    <Route
+                      path="project/key"
+                      component={lazyLoad(() => import('../../apps/project-admin/key/Key'))}
+                    />
+                  </Route>
+                </Route>
+
+                <Route
+                  component={lazyLoad(() => import('../components/AdminContainer'))}
+                  path="admin">
+                  <Route
+                    path="extension/:pluginKey/:extensionKey"
+                    component={lazyLoad(() =>
+                      import('../components/extensions/GlobalAdminPageExtension')
+                    )}
+                  />
+                  <RouteWithChildRoutes
+                    path="background_tasks"
+                    childRoutes={backgroundTasksRoutes}
+                  />
+                  <RouteWithChildRoutes path="custom_metrics" childRoutes={customMetricsRoutes} />
+                  <RouteWithChildRoutes path="groups" childRoutes={groupsRoutes} />
+                  <RouteWithChildRoutes
+                    path="permission_templates"
+                    childRoutes={permissionTemplatesRoutes}
+                  />
+                  <RouteWithChildRoutes path="roles/global" childRoutes={globalPermissionsRoutes} />
+                  <RouteWithChildRoutes path="permissions" childRoutes={globalPermissionsRoutes} />
+                  <RouteWithChildRoutes
+                    path="projects_management"
+                    childRoutes={projectsManagementRoutes}
+                  />
+                  <RouteWithChildRoutes path="settings" childRoutes={settingsRoutes} />
+                  <RouteWithChildRoutes path="system" childRoutes={systemRoutes} />
+                  <RouteWithChildRoutes path="marketplace" childRoutes={marketplaceRoutes} />
+                  <RouteWithChildRoutes path="users" childRoutes={usersRoutes} />
+                  <RouteWithChildRoutes path="webhooks" childRoutes={webhooksRoutes} />
+                </Route>
+              </Route>
+              <Route
+                path="not_found"
+                component={lazyLoad(() => import('../components/NotFound'))}
+              />
+              <Route path="*" component={lazyLoad(() => import('../components/NotFound'))} />
+            </Route>
+          </Route>
+        </Router>
+      </IntlProvider>
+    </Provider>,
+    el
+  );
+}