]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13147 lazyloading
authorJeremy Davis <jeremy.davis@sonarsource.com>
Mon, 2 Mar 2020 15:00:29 +0000 (16:00 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 6 Mar 2020 20:04:32 +0000 (20:04 +0000)
69 files changed:
server/sonar-web/src/main/js/app/components/App.tsx
server/sonar-web/src/main/js/app/components/SimpleSessionsContainer.tsx
server/sonar-web/src/main/js/app/components/StartupModal.tsx
server/sonar-web/src/main/js/app/components/embed-docs-modal/EmbedDocsPopupHelper.tsx
server/sonar-web/src/main/js/app/components/nav/component/ComponentNavWarnings.tsx
server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavWarnings-test.tsx.snap
server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx
server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx
server/sonar-web/src/main/js/app/components/search/Search.tsx
server/sonar-web/src/main/js/app/utils/startReactApp.tsx
server/sonar-web/src/main/js/apps/about/routes.ts
server/sonar-web/src/main/js/apps/account/routes.ts
server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx
server/sonar-web/src/main/js/apps/background-tasks/routes.ts
server/sonar-web/src/main/js/apps/code/routes.ts
server/sonar-web/src/main/js/apps/coding-rules/routes.ts
server/sonar-web/src/main/js/apps/component-measures/routes.ts
server/sonar-web/src/main/js/apps/custom-measures/routes.ts
server/sonar-web/src/main/js/apps/custom-metrics/routes.ts
server/sonar-web/src/main/js/apps/documentation/routes.ts
server/sonar-web/src/main/js/apps/groups/routes.ts
server/sonar-web/src/main/js/apps/issues/IssuesPageSelector.tsx [deleted file]
server/sonar-web/src/main/js/apps/issues/__tests__/IssuesPageSelector-test.tsx [deleted file]
server/sonar-web/src/main/js/apps/issues/__tests__/__snapshots__/IssuesPageSelector-test.tsx.snap [deleted file]
server/sonar-web/src/main/js/apps/issues/components/App.tsx
server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx
server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx
server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx
server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesSourceViewer-test.tsx.snap
server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx
server/sonar-web/src/main/js/apps/maintenance/routes.tsx
server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx
server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap
server/sonar-web/src/main/js/apps/marketplace/routes.ts
server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjects.tsx
server/sonar-web/src/main/js/apps/organizations/routes.ts
server/sonar-web/src/main/js/apps/overview/components/App.tsx
server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx
server/sonar-web/src/main/js/apps/overview/routes.ts
server/sonar-web/src/main/js/apps/permission-templates/routes.ts
server/sonar-web/src/main/js/apps/permissions/routes.ts
server/sonar-web/src/main/js/apps/portfolio/routes.ts
server/sonar-web/src/main/js/apps/projectActivity/routes.ts
server/sonar-web/src/main/js/apps/projectBaseline/routes.ts
server/sonar-web/src/main/js/apps/projectBranches/routes.ts
server/sonar-web/src/main/js/apps/projectQualityGate/routes.ts
server/sonar-web/src/main/js/apps/projectQualityProfiles/routes.ts
server/sonar-web/src/main/js/apps/projects/components/AllProjectsContainer.tsx
server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx
server/sonar-web/src/main/js/apps/projects/routes.ts
server/sonar-web/src/main/js/apps/projectsManagement/routes.ts
server/sonar-web/src/main/js/apps/quality-gates/routes.ts
server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultActivation.tsx
server/sonar-web/src/main/js/apps/quality-profiles/routes.ts
server/sonar-web/src/main/js/apps/sessions/routes.ts
server/sonar-web/src/main/js/apps/settings/routes.ts
server/sonar-web/src/main/js/apps/system/routes.ts
server/sonar-web/src/main/js/apps/tutorials/routes.ts
server/sonar-web/src/main/js/apps/users/routes.ts
server/sonar-web/src/main/js/apps/web-api/routes.ts
server/sonar-web/src/main/js/apps/webhooks/routes.ts
server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.tsx
server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx
server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx
server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerBase-test.tsx.snap
server/sonar-web/src/main/js/components/controls/DateInput.tsx
server/sonar-web/src/main/js/components/docs/DocTooltip.tsx
server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocTooltip-test.tsx.snap
server/sonar-web/src/main/js/components/workspace/Workspace.tsx

index 0c06dbe39a623c36f2e9aebbbe99d809f02010c0..3e0fe5e63a5b73e3a01b992ac36dae9241a0bdd5 100644 (file)
  */
 import * as React from 'react';
 import { connect } from 'react-redux';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { fetchMyOrganizations } from '../../apps/account/organizations/actions';
 import { isSonarCloud } from '../../helpers/system';
 import { isLoggedIn } from '../../helpers/users';
 import { fetchLanguages } from '../../store/rootActions';
 import { getAppState, getCurrentUser, getGlobalSettingValue, Store } from '../../store/rootReducer';
 
-const PageTracker = lazyLoad(() => import('./PageTracker'));
+const PageTracker = lazyLoadComponent(() => import('./PageTracker'));
 
 interface StateProps {
   appState: T.AppState | undefined;
index 4d7081762c545201c37e48a4f6b91024d916684b..e860884adce65e9385fbb7fb71bc25c0a9c1f297 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import * as React from 'react';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import GlobalFooterContainer from './GlobalFooterContainer';
 
-const PageTracker = lazyLoad(() => import('./PageTracker'));
+const PageTracker = lazyLoadComponent(() => import('./PageTracker'));
 
 interface Props {
   children?: React.ReactNode;
index 196b62829340e2bcf78c483a9d2ef0cb4d743423..c5bb1efa37a297de98b87c6fa93aa1a14f4f5153 100644 (file)
@@ -20,7 +20,7 @@
 import * as differenceInDays from 'date-fns/difference_in_days';
 import * as React from 'react';
 import { connect } from 'react-redux';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { parseDate, toShortNotSoISOString } from 'sonar-ui-common/helpers/dates';
 import { hasMessage } from 'sonar-ui-common/helpers/l10n';
 import { get, save } from 'sonar-ui-common/helpers/storage';
@@ -33,8 +33,10 @@ import { skipOnboarding } from '../../store/users';
 import { EditionKey } from '../../types/editions';
 import { OnboardingContext } from './OnboardingContext';
 
-const OnboardingModal = lazyLoad(() => import('../../apps/tutorials/onboarding/OnboardingModal'));
-const LicensePromptModal = lazyLoad(
+const OnboardingModal = lazyLoadComponent(() =>
+  import('../../apps/tutorials/onboarding/OnboardingModal')
+);
+const LicensePromptModal = lazyLoadComponent(
   () => import('../../apps/marketplace/components/LicensePromptModal'),
   'LicensePromptModal'
 );
index 4e82ef25566fdc5b7149a00a8a90a703089cdb19..9f8d84e27e3f4c4864b8fbb12e22a531c3ecc3b9 100644 (file)
@@ -21,10 +21,10 @@ import * as React from 'react';
 import { ButtonLink } from 'sonar-ui-common/components/controls/buttons';
 import Toggler from 'sonar-ui-common/components/controls/Toggler';
 import HelpIcon from 'sonar-ui-common/components/icons/HelpIcon';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { translate } from 'sonar-ui-common/helpers/l10n';
 
-const EmbedDocsPopup = lazyLoad(() => import('./EmbedDocsPopup'));
+const EmbedDocsPopup = lazyLoadComponent(() => import('./EmbedDocsPopup'));
 
 interface State {
   helpOpen: boolean;
index 62a259481748d5f661b2027e980e72603aa0f8ab..f377731fb6fcd13e6fdb1e48c8afa4560eba6e75 100644 (file)
  */
 import * as React from 'react';
 import { FormattedMessage } from 'react-intl';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { Alert } from 'sonar-ui-common/components/ui/Alert';
 import { translate } from 'sonar-ui-common/helpers/l10n';
 
-const AnalysisWarningsModal = lazyLoad(() =>
-  import('../../../../components/common/AnalysisWarningsModal')
+const AnalysisWarningsModal = lazyLoadComponent(
+  () => import('../../../../components/common/AnalysisWarningsModal'),
+  'AnalysisWarningsModal'
 );
 
 interface Props {
index 0a72b432624eeb3d9de6635f2cc056e422f9dcf1..03033721f88ca08b634629a6eeafef5c5e22dc27 100644 (file)
@@ -30,7 +30,7 @@ exports[`should render 1`] = `
       }
     />
   </Alert>
-  <LazyLoader
+  <AnalysisWarningsModal
     onClose={[Function]}
     warnings={
       Array [
index 8b27ccfbf98f738382f2cfbbac643e7c59e1f2ca..27c84ab5f8a6e06b98140ceb1c9b3e4d5551632d 100644 (file)
@@ -19,7 +19,7 @@
  */
 import * as React from 'react';
 import { connect } from 'react-redux';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import NavBar from 'sonar-ui-common/components/ui/NavBar';
 import { parseDate } from 'sonar-ui-common/helpers/dates';
 import {
@@ -47,12 +47,12 @@ import GlobalNavExplore from './GlobalNavExplore';
 import GlobalNavMenu from './GlobalNavMenu';
 import GlobalNavUserContainer from './GlobalNavUserContainer';
 
-const GlobalNavPlus = lazyLoad(() => import('./GlobalNavPlus'), 'GlobalNavPlus');
-const NotificationsSidebar = lazyLoad(
+const GlobalNavPlus = lazyLoadComponent(() => import('./GlobalNavPlus'), 'GlobalNavPlus');
+const NotificationsSidebar = lazyLoadComponent(
   () => import('../../notifications/NotificationsSidebar'),
   'NotificationsSidebar'
 );
-const NavLatestNotification = lazyLoad(
+const NavLatestNotification = lazyLoadComponent(
   () => import('../../notifications/NavLatestNotification'),
   'NavLatestNotification'
 );
index 7e0b5d171f9ec66b897348b3078eddb574db5fd4..fc2bb9107ee2f9c2d3a122ebca596f823a68f7b4 100644 (file)
@@ -200,4 +200,4 @@ export class GlobalNavPlus extends React.PureComponent<Props & WithRouterProps,
   }
 }
 
-export default withRouter(GlobalNavPlus);
+export default withRouter<Props>(GlobalNavPlus);
index 31bf701130f2f84bcd200634f45902c69d150846..7db674fef924b4d5cf9fe8751794269e2e861325 100644 (file)
@@ -26,7 +26,7 @@ import { DropdownOverlay } from 'sonar-ui-common/components/controls/Dropdown';
 import OutsideClickHandler from 'sonar-ui-common/components/controls/OutsideClickHandler';
 import SearchBox from 'sonar-ui-common/components/controls/SearchBox';
 import ClockIcon from 'sonar-ui-common/components/icons/ClockIcon';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner';
 import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n';
 import { scrollToElement } from 'sonar-ui-common/helpers/scrolling';
@@ -36,8 +36,8 @@ import RecentHistory from '../RecentHistory';
 import './Search.css';
 import { ComponentResult, More, Results, sortQualifiers } from './utils';
 
-const SearchResults = lazyLoad(() => import('./SearchResults'));
-const SearchResult = lazyLoad(() => import('./SearchResult'));
+const SearchResults = lazyLoadComponent(() => import('./SearchResults'));
+const SearchResult = lazyLoadComponent(() => import('./SearchResult'));
 
 interface OwnProps {
   appState: Pick<T.AppState, 'organizationsEnabled'>;
index a901bca0c2aa0fd677d7ea92b96fcc601271d419..251018d38e71662dea211b165b8a95bb662044bf 100644 (file)
@@ -26,7 +26,6 @@ import { HelmetProvider } from 'react-helmet-async';
 import { IntlProvider } from 'react-intl';
 import { Provider } from 'react-redux';
 import { IndexRoute, Redirect, Route, RouteConfig, RouteProps, Router } from 'react-router';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
 import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { ThemeProvider } from 'sonar-ui-common/components/theme';
 import getHistory from 'sonar-ui-common/helpers/getHistory';
@@ -44,7 +43,6 @@ import ExploreIssues from '../../apps/explore/ExploreIssues';
 import ExploreProjects from '../../apps/explore/ExploreProjects';
 import groupsRoutes from '../../apps/groups/routes';
 import Issues from '../../apps/issues/components/AppContainer';
-import IssuesPageSelector from '../../apps/issues/IssuesPageSelector';
 import { maintenanceRoutes, setupRoutes } from '../../apps/maintenance/routes';
 import marketplaceRoutes from '../../apps/marketplace/routes';
 import organizationsRoutes from '../../apps/organizations/routes';
@@ -151,7 +149,7 @@ function renderRedirects() {
 
 function renderComponentRoutes() {
   return (
-    <Route component={lazyLoad(() => import('../components/ComponentContainer'))}>
+    <Route component={lazyLoadComponent(() => import('../components/ComponentContainer'))}>
       <RouteWithChildRoutes path="code" childRoutes={codeRoutes} />
       <RouteWithChildRoutes path="component_measures" childRoutes={componentMeasuresRoutes} />
       <RouteWithChildRoutes path="dashboard" childRoutes={overviewRoutes} />
@@ -159,7 +157,7 @@ function renderComponentRoutes() {
       <RouteWithChildRoutes path="project/activity" childRoutes={projectActivityRoutes} />
       <Route
         path="project/extension/:pluginKey/:extensionKey"
-        component={lazyLoad(() => import('../components/extensions/ProjectPageExtension'))}
+        component={lazyLoadComponent(() => import('../components/extensions/ProjectPageExtension'))}
       />
       <Route
         path="project/issues"
@@ -191,11 +189,13 @@ function renderComponentRoutes() {
         path="project/quality_profiles"
         childRoutes={projectQualityProfilesRoutes}
       />
-      <Route component={lazyLoad(() => import('../components/ProjectAdminContainer'))}>
+      <Route component={lazyLoadComponent(() => import('../components/ProjectAdminContainer'))}>
         <RouteWithChildRoutes path="custom_measures" childRoutes={customMeasuresRoutes} />
         <Route
           path="project/admin/extension/:pluginKey/:extensionKey"
-          component={lazyLoad(() => import('../components/extensions/ProjectAdminPageExtension'))}
+          component={lazyLoadComponent(() =>
+            import('../components/extensions/ProjectAdminPageExtension')
+          )}
         />
         <RouteWithChildRoutes path="project/background_tasks" childRoutes={backgroundTasksRoutes} />
         <RouteWithChildRoutes path="project/baseline" childRoutes={projectBaselineRoutes} />
@@ -205,13 +205,16 @@ function renderComponentRoutes() {
         <RouteWithChildRoutes path="project/webhooks" childRoutes={webhooksRoutes} />
         <Route
           path="project/deletion"
-          component={lazyLoad(() => import('../../apps/projectDeletion/App'))}
+          component={lazyLoadComponent(() => import('../../apps/projectDeletion/App'))}
         />
         <Route
           path="project/links"
-          component={lazyLoad(() => import('../../apps/projectLinks/App'))}
+          component={lazyLoadComponent(() => import('../../apps/projectLinks/App'))}
+        />
+        <Route
+          path="project/key"
+          component={lazyLoadComponent(() => import('../../apps/projectKey/Key'))}
         />
-        <Route path="project/key" component={lazyLoad(() => import('../../apps/projectKey/Key'))} />
       </Route>
     </Route>
   );
@@ -219,10 +222,12 @@ function renderComponentRoutes() {
 
 function renderAdminRoutes() {
   return (
-    <Route component={lazyLoad(() => import('../components/AdminContainer'))} path="admin">
+    <Route component={lazyLoadComponent(() => import('../components/AdminContainer'))} path="admin">
       <Route
         path="extension/:pluginKey/:extensionKey"
-        component={lazyLoad(() => import('../components/extensions/GlobalAdminPageExtension'))}
+        component={lazyLoadComponent(() =>
+          import('../components/extensions/GlobalAdminPageExtension')
+        )}
       />
       <RouteWithChildRoutes path="background_tasks" childRoutes={backgroundTasksRoutes} />
       <RouteWithChildRoutes path="custom_metrics" childRoutes={customMetricsRoutes} />
@@ -259,21 +264,26 @@ export default function startReactApp(
 
               <Route
                 path="markdown/help"
-                component={lazyLoad(() => import('../components/MarkdownHelp'))}
+                component={lazyLoadComponent(() => import('../components/MarkdownHelp'))}
               />
 
-              <Route component={lazyLoad(() => import('../components/SimpleContainer'))}>
+              <Route component={lazyLoadComponent(() => import('../components/SimpleContainer'))}>
                 <Route path="maintenance">{maintenanceRoutes}</Route>
                 <Route path="setup">{setupRoutes}</Route>
               </Route>
 
               <Route component={MigrationContainer}>
-                <Route component={lazyLoad(() => import('../components/SimpleSessionsContainer'))}>
+                <Route
+                  component={lazyLoadComponent(() =>
+                    import('../components/SimpleSessionsContainer')
+                  )}>
                   <RouteWithChildRoutes path="/sessions" childRoutes={sessionsRoutes} />
                 </Route>
 
                 <Route path="/" component={App}>
-                  <IndexRoute component={lazyLoad(() => import('../components/Landing'))} />
+                  <IndexRoute
+                    component={lazyLoadComponent(() => import('../components/Landing'))}
+                  />
                   <RouteWithChildRoutes path="about" childRoutes={aboutRoutes} />
 
                   <Route component={GlobalContainer}>
@@ -286,18 +296,20 @@ export default function startReactApp(
                     </Route>
                     <Route
                       path="extension/:pluginKey/:extensionKey"
-                      component={lazyLoad(() =>
+                      component={lazyLoadComponent(() =>
                         import('../components/extensions/GlobalPageExtension')
                       )}
                     />
-                    <Route path="issues" component={IssuesPageSelector} />
+                    <Route path="issues" component={Issues} />
                     <RouteWithChildRoutes path="onboarding" childRoutes={onboardingRoutes} />
                     <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'))}
+                      component={lazyLoadComponent(() =>
+                        import('../components/extensions/PortfoliosPage')
+                      )}
                     />
                     <RouteWithChildRoutes path="profiles" childRoutes={qualityProfilesRoutes} />
                     <RouteWithChildRoutes path="web_api" childRoutes={webAPIRoutes} />
@@ -308,9 +320,12 @@ export default function startReactApp(
                   </Route>
                   <Route
                     path="not_found"
-                    component={lazyLoad(() => import('../components/NotFound'))}
+                    component={lazyLoadComponent(() => import('../components/NotFound'))}
+                  />
+                  <Route
+                    path="*"
+                    component={lazyLoadComponent(() => import('../components/NotFound'))}
                   />
-                  <Route path="*" component={lazyLoad(() => import('../components/NotFound'))} />
                 </Route>
               </Route>
             </Router>
index 1f191646d3fc692f441fec76a324b1c7e1db140e..597a857f9440830e5cd1410e464fd0c07a878294 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
-const routes = [{ indexRoute: { component: lazyLoad(() => import('./components/AboutApp')) } }];
+const routes = [
+  { indexRoute: { component: lazyLoadComponent(() => import('./components/AboutApp')) } }
+];
 
 export default routes;
index 69866937fdf39461fa541d96b8d546cf6eef12c5..8fc8ed5cefd4c6b4f6323c34fe21c98ceed24b18 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    component: lazyLoad(() => import('./components/Account')),
+    component: lazyLoadComponent(() => import('./components/Account')),
     childRoutes: [
       {
-        indexRoute: { component: lazyLoad(() => import('./profile/Profile')) }
+        indexRoute: { component: lazyLoadComponent(() => import('./profile/Profile')) }
       },
       {
         path: 'security',
-        component: lazyLoad(() => import('./components/Security'))
+        component: lazyLoadComponent(() => import('./components/Security'))
       },
       {
         path: 'projects',
-        component: lazyLoad(() => import('./projects/ProjectsContainer'))
+        component: lazyLoadComponent(() => import('./projects/ProjectsContainer'))
       },
       {
         path: 'notifications',
-        component: lazyLoad(() => import('./notifications/Notifications'))
+        component: lazyLoadComponent(() => import('./notifications/Notifications'))
       },
       {
         path: 'organizations',
-        component: lazyLoad(() => import('./organizations/UserOrganizations'))
+        component: lazyLoadComponent(() => import('./organizations/UserOrganizations'))
       }
     ]
   }
index 99e159dc4cb136eb910dc8475b7a83e57f8dcbc1..f9352185a8557010713f7cf0c6c511ff29a1cf71 100644 (file)
@@ -22,13 +22,13 @@ import ActionsDropdown, {
   ActionsDropdownItem
 } from 'sonar-ui-common/components/controls/ActionsDropdown';
 import ConfirmModal from 'sonar-ui-common/components/controls/ConfirmModal';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n';
 import { STATUSES } from '../constants';
 import ScannerContext from './ScannerContext';
 import Stacktrace from './Stacktrace';
 
-const AnalysisWarningsModal = lazyLoad(
+const AnalysisWarningsModal = lazyLoadComponent(
   () => import('../../../components/common/AnalysisWarningsModal'),
   'AnalysisWarningsModal'
 );
index 32ba890ac8f1e4e9f589e629b668fd1b42a49a5e..7f600552b5130bf0bf9cd8e3b852c0a74dcaac11 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/BackgroundTasksApp')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/BackgroundTasksApp')) }
   }
 ];
 
index 168c5c58de68acecdf411d816d2affb5933a463a..92b03bc56073c8b9a190bc5a7277cf194d6b98fc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/App')) }
   }
 ];
 
index c52c905b0f34a0f74b447d5f57f40d98f6a5f76c..c40a5571355e0ff347bf58579ea4c3ee175065a5 100644 (file)
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { RedirectFunction, RouterState } from 'react-router';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { parseQuery, serializeQuery } from './query';
 
 function parseHash(hash: string): T.RawQuery {
@@ -47,7 +47,7 @@ const routes = [
           replace({ pathname: nextState.location.pathname, query: normalizedQuery });
         }
       },
-      component: lazyLoad(() => import('./components/App'))
+      component: lazyLoadComponent(() => import('./components/App'))
     }
   }
 ];
index 2499b15eb9b400d226234464fd2a091a6241126d..07d80dda92ccf1a0263f732f6059f9b250e4d8df 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { RedirectFunction, RouterState } from 'react-router';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/App')) }
   },
   {
     path: 'domain/:domainName',
index 168c5c58de68acecdf411d816d2affb5933a463a..92b03bc56073c8b9a190bc5a7277cf194d6b98fc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/App')) }
   }
 ];
 
index 168c5c58de68acecdf411d816d2affb5933a463a..92b03bc56073c8b9a190bc5a7277cf194d6b98fc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/App')) }
   }
 ];
 
index 1e488c6b290621b7da2318cc1181ae0eddf980a4..061f011e9811ff01f828db3d6f46a34bd6442d7e 100644 (file)
@@ -17,9 +17,9 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
-const App = lazyLoad(() => import(/* webpackChunkName: "docs" */ './components/App'));
+const App = lazyLoadComponent(() => import(/* webpackChunkName: "docs" */ './components/App'));
 
 const routes = [{ indexRoute: { component: App } }, { path: '**', indexRoute: { component: App } }];
 
index 168c5c58de68acecdf411d816d2affb5933a463a..92b03bc56073c8b9a190bc5a7277cf194d6b98fc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/App')) }
   }
 ];
 
diff --git a/server/sonar-web/src/main/js/apps/issues/IssuesPageSelector.tsx b/server/sonar-web/src/main/js/apps/issues/IssuesPageSelector.tsx
deleted file mode 100644 (file)
index 286f065..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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 * as React from 'react';
-import { withCurrentUser } from '../../components/hoc/withCurrentUser';
-import { Location } from '../../components/hoc/withRouter';
-import { isSonarCloud } from '../../helpers/system';
-import { isLoggedIn } from '../../helpers/users';
-import AppContainer from './components/AppContainer';
-
-export interface Props {
-  currentUser: T.CurrentUser;
-  location: Location;
-}
-
-export function IssuesPage({ currentUser, location }: Props) {
-  const myIssues = (isLoggedIn(currentUser) && isSonarCloud()) || undefined;
-  return <AppContainer location={location} myIssues={myIssues} />;
-}
-
-export default withCurrentUser(IssuesPage);
diff --git a/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesPageSelector-test.tsx b/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesPageSelector-test.tsx
deleted file mode 100644 (file)
index e8bcac8..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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 { shallow } from 'enzyme';
-import * as React from 'react';
-import { isSonarCloud } from '../../../helpers/system';
-import { mockCurrentUser, mockLocation, mockLoggedInUser } from '../../../helpers/testMocks';
-import { IssuesPage, Props } from '../IssuesPageSelector';
-
-jest.mock('../../../helpers/system', () => ({ isSonarCloud: jest.fn().mockReturnValue(false) }));
-
-it('should render normal issues page', () => {
-  expect(shallowRender()).toMatchSnapshot();
-  expect(
-    shallowRender({ currentUser: mockLoggedInUser() })
-      .find('Connect(IssuesAppContainer)')
-      .prop('myIssues')
-  ).toBeFalsy();
-  (isSonarCloud as jest.Mock).mockReturnValueOnce(true);
-  expect(
-    shallowRender()
-      .find('Connect(IssuesAppContainer)')
-      .prop('myIssues')
-  ).toBeFalsy();
-});
-
-it('should render my issues page', () => {
-  (isSonarCloud as jest.Mock).mockReturnValueOnce(true);
-  expect(
-    shallowRender({ currentUser: mockLoggedInUser() })
-      .find('Connect(IssuesAppContainer)')
-      .prop('myIssues')
-  ).toBeTruthy();
-});
-
-function shallowRender(props: Partial<Props> = {}) {
-  return shallow(
-    <IssuesPage currentUser={mockCurrentUser()} location={mockLocation()} {...props} />
-  );
-}
diff --git a/server/sonar-web/src/main/js/apps/issues/__tests__/__snapshots__/IssuesPageSelector-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/__tests__/__snapshots__/IssuesPageSelector-test.tsx.snap
deleted file mode 100644 (file)
index cc2de94..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render normal issues page 1`] = `
-<Connect(IssuesAppContainer)
-  location={
-    Object {
-      "action": "PUSH",
-      "hash": "",
-      "key": "key",
-      "pathname": "/path",
-      "query": Object {},
-      "search": "",
-      "state": Object {},
-    }
-  }
-/>
-`;
index cb4c4eac2879f0aea142f89f3bea77fcc4115ed2..cf838a1407aed792680ecc939c33fbce6030f947 100644 (file)
@@ -22,7 +22,6 @@ import { debounce, keyBy, omit, without } from 'lodash';
 import * as React from 'react';
 import { Helmet } from 'react-helmet-async';
 import { FormattedMessage } from 'react-intl';
-import { connect } from 'react-redux';
 import { Button } from 'sonar-ui-common/components/controls/buttons';
 import Checkbox from 'sonar-ui-common/components/controls/Checkbox';
 import ListFooter from 'sonar-ui-common/components/controls/ListFooter';
@@ -41,7 +40,7 @@ import Suggestions from '../../../app/components/embed-docs-modal/Suggestions';
 import EmptySearch from '../../../components/common/EmptySearch';
 import FiltersHeader from '../../../components/common/FiltersHeader';
 import ScreenPositionHelper from '../../../components/common/ScreenPositionHelper';
-import { Location, Router, withRouter } from '../../../components/hoc/withRouter';
+import { Location, Router } from '../../../components/hoc/withRouter';
 import '../../../components/search-navigator.css';
 import {
   fillBranchLike,
@@ -50,7 +49,6 @@ import {
   isSameBranchLike
 } from '../../../helpers/branch-like';
 import { isSonarCloud } from '../../../helpers/system';
-import { fetchBranchStatus } from '../../../store/rootActions';
 import { BranchLike } from '../../../types/branch-like';
 import * as actions from '../actions';
 import ConciseIssuesList from '../conciseIssuesList/ConciseIssuesList';
@@ -104,10 +102,10 @@ interface Props {
   fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>;
   fetchIssues: (query: T.RawQuery, requestOrganizations?: boolean) => Promise<FetchIssuesPromise>;
   hideAuthorFacet?: boolean;
-  location: Pick<Location, 'pathname' | 'query'>;
+  location: Location;
   multiOrganizations?: boolean;
   myIssues?: boolean;
-  onBranchesChange: () => void;
+  onBranchesChange?: () => void;
   organization?: { key: string };
   router: Pick<Router, 'push' | 'replace'>;
   userOrganizations: T.Organization[];
@@ -144,7 +142,7 @@ export interface State {
 const DEFAULT_QUERY = { resolved: 'false' };
 const MAX_INITAL_FETCH = 1000;
 
-export class App extends React.PureComponent<Props, State> {
+export default class App extends React.PureComponent<Props, State> {
   mounted = false;
 
   constructor(props: Props) {
@@ -539,13 +537,13 @@ export class App extends React.PureComponent<Props, State> {
     const { paging } = this.state;
 
     if (!paging) {
-      return;
+      return Promise.reject();
     }
 
     const p = paging.pageIndex + 1;
 
     this.setState({ checkAll: false, loadingMore: true });
-    this.fetchIssuesPage(p).then(
+    return this.fetchIssuesPage(p).then(
       response => {
         if (this.mounted) {
           this.setState(state => ({
@@ -825,8 +823,9 @@ export class App extends React.PureComponent<Props, State> {
   handleReload = () => {
     this.fetchFirstIssues();
     this.refreshBranchStatus();
-    if (isPullRequest(this.props.branchLike)) {
-      this.props.onBranchesChange();
+    const { branchLike, onBranchesChange } = this.props;
+    if (onBranchesChange && isPullRequest(branchLike)) {
+      onBranchesChange();
     }
   };
 
@@ -1180,7 +1179,3 @@ export class App extends React.PureComponent<Props, State> {
     );
   }
 }
-
-const mapDispatchToProps = { fetchBranchStatus: fetchBranchStatus as any };
-
-export default withRouter(connect(null, mapDispatchToProps)(App));
index a896d854d7713b34a9009f55fe95f7fcdd653d8b..c964c62691183111279ee420504d1d0424439ab7 100644 (file)
 import { uniq } from 'lodash';
 import { connect } from 'react-redux';
 import { Dispatch } from 'redux';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { searchIssues } from '../../../api/issues';
 import { getOrganizations } from '../../../api/organizations';
 import throwGlobalError from '../../../app/utils/throwGlobalError';
+import { withRouter } from '../../../components/hoc/withRouter';
 import { parseIssueFromResponse } from '../../../helpers/issues';
 import { receiveOrganizations } from '../../../store/organizations';
+import { fetchBranchStatus } from '../../../store/rootActions';
 import {
   areThereCustomOrganizations,
   getCurrentUser,
@@ -33,6 +35,8 @@ import {
   Store
 } from '../../../store/rootReducer';
 
+const IssuesAppContainer = lazyLoadComponent(() => import('./App'), 'IssuesAppContainer');
+
 interface StateProps {
   currentUser: T.CurrentUser;
   userOrganizations: T.Organization[];
@@ -79,14 +83,10 @@ const fetchIssues = (query: T.RawQuery, requestOrganizations = true) => (
     .catch(throwGlobalError);
 };
 
-interface DispatchProps {
-  fetchIssues: (query: T.RawQuery, requestOrganizations?: boolean) => Promise<void>;
-}
-
 // have to type cast this, because of async action
-const mapDispatchToProps = { fetchIssues: fetchIssues as any } as DispatchProps;
+const mapDispatchToProps = {
+  fetchBranchStatus: fetchBranchStatus as any,
+  fetchIssues: fetchIssues as any
+};
 
-export default connect(
-  mapStateToProps,
-  mapDispatchToProps
-)(lazyLoad(() => import('./App'), 'IssuesAppContainer'));
+export default withRouter(connect(mapStateToProps, mapDispatchToProps)(IssuesAppContainer));
index 1036a7d0f088df9012ec4312b0b0fd5ff5931925..3edd011543912dbc292beb12462d1904b72c42c6 100644 (file)
@@ -17,7 +17,6 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { uniq } from 'lodash';
 import * as React from 'react';
 import { scrollToElement } from 'sonar-ui-common/helpers/scrolling';
 import SourceViewer from '../../../components/SourceViewer/SourceViewer';
@@ -91,12 +90,10 @@ export default class IssuesSourceViewer extends React.PureComponent<Props> {
         : undefined;
 
     if (locations.length > 0) {
-      const components = uniq(locations.map(l => l.component));
       return (
         <div ref={node => (this.node = node)}>
           <CrossComponentSourceViewer
             branchLike={this.props.branchLike}
-            components={components}
             highlightedLocationMessage={highlightedLocationMessage}
             issue={openIssue}
             issues={this.props.issues}
index ea42ad2518e303e6e57689efa13c065d27ea0e1b..e7fdb63556753682af9da767617aa7c45455a58d 100644 (file)
@@ -38,7 +38,7 @@ import {
   selectPreviousFlow,
   selectPreviousLocation
 } from '../../actions';
-import { App } from '../App';
+import App from '../App';
 
 jest.mock('sonar-ui-common/helpers/handleRequiredAuthentication', () => ({
   default: jest.fn()
@@ -90,7 +90,7 @@ it('should not render for anonymous user', () => {
 
 it('should open standard facets for vulnerabilities and hotspots', () => {
   const wrapper = shallowRender({
-    location: { pathname: '/issues', query: { types: 'VULNERABILITY' } }
+    location: mockLocation({ pathname: '/issues', query: { types: 'VULNERABILITY' } })
   });
   const instance = wrapper.instance();
   const fetchFacet = jest.spyOn(instance, 'fetchFacet');
@@ -420,7 +420,7 @@ function shallowRender(props: Partial<App['props']> = {}) {
         rules: [],
         users: []
       })}
-      location={{ pathname: '/issues', query: {} }}
+      location={mockLocation({ pathname: '/issues', query: {} })}
       onBranchesChange={() => {}}
       organization={{ key: 'foo' }}
       router={mockRouter()}
index 090eac8205a7cfbf7fbe26555170b35f1ff7a3b8..a0bd5ab199c1f25bc83110b9b0b5792b5365dc5c 100644 (file)
@@ -11,11 +11,6 @@ exports[`should render CrossComponentSourceViewer correctly 1`] = `
         "name": "master",
       }
     }
-    components={
-      Array [
-        "main.js",
-      ]
-    }
     issue={
       Object {
         "actions": Array [],
index 420d0cf659cfcceb669e731e06e6f4d5075f4ece..84a4e68c4d61597ea852f3e71110ed6461eb3fce 100644 (file)
@@ -17,9 +17,9 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
-const CrossComponentSourceViewer = lazyLoad(
+const CrossComponentSourceViewer = lazyLoadComponent(
   () => import(/* webpackPrefetch: true */ './CrossComponentSourceViewerWrapper'),
   'CrossComponentSourceViewer'
 );
index 066902097347f84ad70d7c37c098ee47f72dadd0..705dfafcd478452584601062113df07118ddc41f 100644 (file)
  */
 import * as React from 'react';
 import { IndexRoute } from 'react-router';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 export const maintenanceRoutes = (
-  <IndexRoute component={lazyLoad(() => import('./components/MaintenanceAppContainer'))} />
+  <IndexRoute component={lazyLoadComponent(() => import('./components/MaintenanceAppContainer'))} />
 );
 
 export const setupRoutes = (
-  <IndexRoute component={lazyLoad(() => import('./components/SetupAppContainer'))} />
+  <IndexRoute component={lazyLoadComponent(() => import('./components/SetupAppContainer'))} />
 );
index 1ee19543cd69266c72cd8e24377754920d5f9f23..dc80a1870f47551bccd574a9502db2465d876118 100644 (file)
@@ -21,12 +21,15 @@ import tooltipDCE from 'Docs/tooltips/editions/datacenter.md';
 import tooltipDE from 'Docs/tooltips/editions/developer.md';
 import tooltipEE from 'Docs/tooltips/editions/enterprise.md';
 import * as React from 'react';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { translate } from 'sonar-ui-common/helpers/l10n';
 import { getEditionUrl } from '../../../helpers/editions';
 import { Edition, EditionKey } from '../../../types/editions';
 
-const DocMarkdownBlock = lazyLoad(() => import('../../../components/docs/DocMarkdownBlock'));
+const DocMarkdownBlock = lazyLoadComponent(
+  () => import('../../../components/docs/DocMarkdownBlock'),
+  'DocMarkdownBlock'
+);
 
 interface Props {
   currentEdition?: EditionKey;
index cfd28f4bc3564b8199df6a97225b59f1c90be8b1..538a9f2b9efa08425518681d02c82713bc978e5d 100644 (file)
@@ -4,7 +4,7 @@ exports[`should display the edition 1`] = `
 <div
   className="boxed-group boxed-group-inner marketplace-edition"
 >
-  <LazyLoader />
+  <DocMarkdownBlock />
   <div
     className="marketplace-edition-action spacer-top"
   >
index 68418a8f274d5838a0976225575fe6e8e1e93225..729a854fd60b19052722418a5d97461062d4af9f 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./AppContainer')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./AppContainer')) }
   }
 ];
 
index 83ba57896b9d888f567a0f0a5ba2e2179d746c29..c53f19f768d124abaa3573c76da002e2f73d8d15 100644 (file)
@@ -29,11 +29,7 @@ interface Props {
 export default function OrganizationProjects(props: Props) {
   return (
     <>
-      <AllProjectsContainer
-        isFavorite={false}
-        location={props.location}
-        organization={props.organization}
-      />
+      <AllProjectsContainer isFavorite={false} organization={props.organization} />
       <Suggestions suggestions="organization_projects" />
     </>
   );
index 975ddd60eee55323abb51d6a6107334fe96b2131..1efff137c9f6fbb65d2af0866b2dc69c76a3fb4c 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { RedirectFunction, RouterState } from 'react-router';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import codingRulesRoutes from '../coding-rules/routes';
 import qualityGatesRoutes from '../quality-gates/routes';
 import qualityProfilesRoutes from '../quality-profiles/routes';
 import webhooksRoutes from '../webhooks/routes';
 
-const OrganizationContainer = lazyLoad(() => import('./components/OrganizationContainer'));
+const OrganizationContainer = lazyLoadComponent(() => import('./components/OrganizationContainer'));
 
 const routes = [
   {
     path: ':organizationKey',
-    component: lazyLoad(() => import('./components/OrganizationPage')),
+    component: lazyLoadComponent(() => import('./components/OrganizationPage')),
     childRoutes: [
       {
         indexRoute: {
@@ -43,14 +43,22 @@ const routes = [
         path: 'projects',
         component: OrganizationContainer,
         childRoutes: [
-          { indexRoute: { component: lazyLoad(() => import('./components/OrganizationProjects')) } }
+          {
+            indexRoute: {
+              component: lazyLoadComponent(() => import('./components/OrganizationProjects'))
+            }
+          }
         ]
       },
       {
         path: 'issues',
         component: OrganizationContainer,
         childRoutes: [
-          { indexRoute: { component: lazyLoad(() => import('../issues/components/AppContainer')) } }
+          {
+            indexRoute: {
+              component: lazyLoadComponent(() => import('../issues/components/AppContainer'))
+            }
+          }
         ]
       },
       {
@@ -60,7 +68,9 @@ const routes = [
       },
       {
         path: 'members',
-        component: lazyLoad(() => import('../organizationMembers/OrganizationMembersContainer'))
+        component: lazyLoadComponent(() =>
+          import('../organizationMembers/OrganizationMembersContainer')
+        )
       },
       {
         path: 'quality_profiles',
@@ -72,26 +82,32 @@ const routes = [
         childRoutes: qualityGatesRoutes
       },
       {
-        component: lazyLoad(() => import('./components/OrganizationAccessContainer')),
+        component: lazyLoadComponent(() => import('./components/OrganizationAccessContainer')),
         childRoutes: [
-          { path: 'edit', component: lazyLoad(() => import('./components/OrganizationEdit')) },
-          { path: 'groups', component: lazyLoad(() => import('../groups/components/App')) },
+          {
+            path: 'edit',
+            component: lazyLoadComponent(() => import('./components/OrganizationEdit'))
+          },
+          {
+            path: 'groups',
+            component: lazyLoadComponent(() => import('../groups/components/App'))
+          },
           {
             path: 'permissions',
-            component: lazyLoad(() => import('../permissions/global/components/App'))
+            component: lazyLoadComponent(() => import('../permissions/global/components/App'))
           },
           {
             path: 'permission_templates',
-            component: lazyLoad(() => import('../permission-templates/components/App'))
+            component: lazyLoadComponent(() => import('../permission-templates/components/App'))
           },
           {
             path: 'projects_management',
-            component: lazyLoad(() => import('../projectsManagement/AppContainer'))
+            component: lazyLoadComponent(() => import('../projectsManagement/AppContainer'))
           },
           { path: 'webhooks', childRoutes: webhooksRoutes },
           {
             path: 'extension/:pluginKey/:extensionKey',
-            component: lazyLoad(() =>
+            component: lazyLoadComponent(() =>
               import('../../app/components/extensions/OrganizationPageExtension')
             )
           }
index e10115c97808f7ca64a24a1f86fb65209441142e..fbd6ea0c9503619993cdd5f01c78e8d94e1bae70 100644 (file)
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import * as React from 'react';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import Suggestions from '../../../app/components/embed-docs-modal/Suggestions';
 import { Router, withRouter } from '../../../components/hoc/withRouter';
 import { isPullRequest } from '../../../helpers/branch-like';
@@ -26,8 +26,8 @@ import { BranchLike } from '../../../types/branch-like';
 import { ComponentQualifier } from '../../../types/component';
 import BranchOverview from '../branches/BranchOverview';
 
-const EmptyOverview = lazyLoad(() => import('./EmptyOverview'));
-const PullRequestOverview = lazyLoad(() => import('../pullRequests/PullRequestOverview'));
+const EmptyOverview = lazyLoadComponent(() => import('./EmptyOverview'));
+const PullRequestOverview = lazyLoadComponent(() => import('../pullRequests/PullRequestOverview'));
 
 interface Props {
   branchLike?: BranchLike;
index eeec9f5ea7d1f7b959d86c30e5e41549790fc822..18862261bce776d7ed839cf33a3d566fd462ba58 100644 (file)
@@ -41,15 +41,23 @@ import { IssueType, MeasurementType, PR_METRICS } from '../utils';
 import AfterMergeEstimate from './AfterMergeEstimate';
 import LargeQualityGateBadge from './LargeQualityGateBadge';
 
-interface Props {
-  branchLike: PullRequest;
-  component: T.Component;
+interface StateProps {
   conditions?: QualityGateStatusCondition[];
-  fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>;
   ignoredConditions?: boolean;
   status?: T.Status;
 }
 
+interface DispatchProps {
+  fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>;
+}
+
+interface OwnProps {
+  branchLike: PullRequest;
+  component: T.Component;
+}
+
+type Props = StateProps & DispatchProps & OwnProps;
+
 interface State {
   loading: boolean;
   measures: T.MeasureEnhanced[];
@@ -244,4 +252,7 @@ const mapStateToProps = (state: Store, { branchLike, component }: Props) => {
 
 const mapDispatchToProps = { fetchBranchStatus: fetchBranchStatus as any };
 
-export default connect(mapStateToProps, mapDispatchToProps)(PullRequestOverview);
+export default connect<StateProps, DispatchProps, OwnProps>(
+  mapStateToProps,
+  mapDispatchToProps
+)(PullRequestOverview);
index 168c5c58de68acecdf411d816d2affb5933a463a..92b03bc56073c8b9a190bc5a7277cf194d6b98fc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/App')) }
   }
 ];
 
index 168c5c58de68acecdf411d816d2affb5933a463a..92b03bc56073c8b9a190bc5a7277cf194d6b98fc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/App')) }
   }
 ];
 
index cf478a468be527217a569d8557f6a375a898e1e5..da2a3b06f11252f23f17d891dbeafec3be26e98d 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 export const globalPermissionsRoutes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./global/components/App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./global/components/App')) }
   }
 ];
 
 export const projectPermissionsRoutes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./project/components/AppContainer')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./project/components/AppContainer')) }
   }
 ];
index 168c5c58de68acecdf411d816d2affb5933a463a..92b03bc56073c8b9a190bc5a7277cf194d6b98fc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/App')) }
   }
 ];
 
index 575ab1d0e7b167e5cd70de158df4b92c9c45571c..96df47d62da4a9c23bb9b2f6bdd334e0962e8f45 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
     indexRoute: {
-      component: lazyLoad(() => import('./components/ProjectActivityAppContainer'))
+      component: lazyLoadComponent(() => import('./components/ProjectActivityAppContainer'))
     }
   }
 ];
index 2b83ad2df234c076f73cb0a95b9ed106c000cf46..2b08f969444b3b9ea0ab9c0c998892f20353f3bc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/AppContainer')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/AppContainer')) }
   }
 ];
 
index 168c5c58de68acecdf411d816d2affb5933a463a..92b03bc56073c8b9a190bc5a7277cf194d6b98fc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/App')) }
   }
 ];
 
index 8f91ec48084dee998f3b9062eb5df5169fcc4a20..d82abd3b1461caa1b583ed5901e36d1eaf991d3e 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./App')) }
   }
 ];
 
index 8f91ec48084dee998f3b9062eb5df5169fcc4a20..d82abd3b1461caa1b583ed5901e36d1eaf991d3e 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./App')) }
   }
 ];
 
index 7877a05ad3c67aaaefc553e3a355eb4b5b4b0388..09c3f522345dbf9e4d6a2f5a8b9921c8cd13de73 100644 (file)
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { connect } from 'react-redux';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { areThereCustomOrganizations, getCurrentUser, Store } from '../../../store/rootReducer';
 
 const stateToProps = (state: Store) => ({
@@ -26,4 +26,4 @@ const stateToProps = (state: Store) => ({
   organizationsEnabled: areThereCustomOrganizations(state)
 });
 
-export default connect(stateToProps)(lazyLoad(() => import('./AllProjects')));
+export default connect(stateToProps)(lazyLoadComponent(() => import('./AllProjects')));
index 476aa33acda8cb703d90a5c0346a618f4b39d915..fc3f6fb794f4f105a222faa305d315ce1c2dc030 100644 (file)
@@ -108,13 +108,7 @@ export class DefaultPageSelector extends React.PureComponent<Props, State> {
 
   render() {
     if (isSonarCloud() && isLoggedIn(this.props.currentUser)) {
-      return (
-        <AllProjectsContainer
-          isFavorite={true}
-          location={this.props.location}
-          organization={undefined}
-        />
-      );
+      return <AllProjectsContainer isFavorite={true} organization={undefined} />;
     }
 
     const { shouldBeRedirected, shouldForceSorting } = this.state;
@@ -124,13 +118,7 @@ export class DefaultPageSelector extends React.PureComponent<Props, State> {
       shouldBeRedirected !== true &&
       shouldForceSorting === undefined
     ) {
-      return (
-        <AllProjectsContainer
-          isFavorite={false}
-          location={this.props.location}
-          organization={undefined}
-        />
-      );
+      return <AllProjectsContainer isFavorite={false} organization={undefined} />;
     }
 
     return null;
index b0920a4b169d19bb38e60a4bf43af78f8afd72b4..7cd069419a1e2e1762f2a83b88019e90412c3ad8 100644 (file)
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { RedirectFunction, RouterState } from 'react-router';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { save } from 'sonar-ui-common/helpers/storage';
 import { isDefined } from 'sonar-ui-common/helpers/types';
 import DefaultPageSelectorContainer from './components/DefaultPageSelectorContainer';
@@ -37,7 +37,7 @@ const routes = [
   { path: 'favorite', component: FavoriteProjectsContainer },
   {
     path: 'create',
-    component: lazyLoad(() => import('../create/project/CreateProjectPage'))
+    component: lazyLoadComponent(() => import('../create/project/CreateProjectPage'))
   }
 ].filter(isDefined);
 
index 68418a8f274d5838a0976225575fe6e8e1e93225..729a854fd60b19052722418a5d97461062d4af9f 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./AppContainer')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./AppContainer')) }
   }
 ];
 
index f2b31650fbd2cc2bda59568ccbec0414f1f13184..0b0da83d63db4152b4af118b3c28df8e0940d8e3 100644 (file)
@@ -17,9 +17,9 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
-const App = lazyLoad(() => import('./components/App'));
+const App = lazyLoadComponent(() => import('./components/App'));
 
 const routes = [{ indexRoute: { component: App } }, { path: 'show/:id', component: App }];
 
index 471a0a1160a90acaf168270cee76041c9fbac2b8..00eba49aa2c5610cef4a4a476a293d7145329bd4 100644 (file)
  */
 import * as React from 'react';
 import { Button } from 'sonar-ui-common/components/controls/buttons';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner';
 import { translate } from 'sonar-ui-common/helpers/l10n';
 import { Profile } from '../../../api/quality-profiles';
 import { getRuleDetails } from '../../../api/rules';
 
-const ActivationFormModal = lazyLoad(
+const ActivationFormModal = lazyLoadComponent(
   () => import('../../coding-rules/components/ActivationFormModal'),
   'ActivationFormModal'
 );
index 85588a40ce6adfd2eaef584e05771435d0c38f99..7d1b18bb50b15cca3c9638d1aeeae4ce29a77b59 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    component: lazyLoad(() => import('./components/AppContainer')),
-    indexRoute: { component: lazyLoad(() => import('./home/HomeContainer')) },
+    component: lazyLoadComponent(() => import('./components/AppContainer')),
+    indexRoute: { component: lazyLoadComponent(() => import('./home/HomeContainer')) },
     childRoutes: [
       {
-        component: lazyLoad(() => import('./components/ProfileContainer')),
+        component: lazyLoadComponent(() => import('./components/ProfileContainer')),
         childRoutes: [
           {
             path: 'show',
-            component: lazyLoad(() => import('./details/ProfileDetails'))
+            component: lazyLoadComponent(() => import('./details/ProfileDetails'))
           },
           {
             path: 'changelog',
-            component: lazyLoad(() => import('./changelog/ChangelogContainer'))
+            component: lazyLoadComponent(() => import('./changelog/ChangelogContainer'))
           },
           {
             path: 'compare',
-            component: lazyLoad(() => import('./compare/ComparisonContainer'))
+            component: lazyLoadComponent(() => import('./compare/ComparisonContainer'))
           }
         ]
       }
index c1293bf3ee1533dc2e5e44f1d21813218fc32c6b..6b7c1d131450e59c6e5937a42c6a3e0ce6b7207e 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
     path: 'new',
-    component: lazyLoad(() => import('./components/LoginContainer'))
+    component: lazyLoadComponent(() => import('./components/LoginContainer'))
   },
   {
     path: 'logout',
-    component: lazyLoad(() => import('./components/Logout'))
+    component: lazyLoadComponent(() => import('./components/Logout'))
   },
   {
     path: 'unauthorized',
-    component: lazyLoad(() => import('./components/Unauthorized'))
+    component: lazyLoadComponent(() => import('./components/Unauthorized'))
   },
   {
     path: 'email_already_exists',
-    component: lazyLoad(() => import('./components/EmailAlreadyExists'))
+    component: lazyLoadComponent(() => import('./components/EmailAlreadyExists'))
   }
 ];
 
index d36ab7cc4adaf63837fb135efe69a8eb69a9b27e..a7ac736f78f03ab96440952c5c29f163717c6b22 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/AppContainer')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/AppContainer')) }
   },
   {
     path: 'encryption',
-    component: lazyLoad(() => import('./encryption/EncryptionApp'))
+    component: lazyLoadComponent(() => import('./encryption/EncryptionApp'))
   }
 ];
 
index 168c5c58de68acecdf411d816d2affb5933a463a..92b03bc56073c8b9a190bc5a7277cf194d6b98fc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/App')) }
   }
 ];
 
index adb924399192078957ecd025515762b02b10a6e3..4436986b49d66fc000472d2ff71ba0c64a40fd66 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
-import { isSonarCloud } from '../../helpers/system';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
     indexRoute: {
-      component: lazyLoad(() =>
-        isSonarCloud() ? import('./onboarding/OnboardingPage') : import('./ProjectOnboardingPage')
-      )
+      component: lazyLoadComponent(() => import('./ProjectOnboardingPage'))
     }
   }
 ];
index 3e75189e325193b51b506c8d32da10ffb2ee051a..4df2cd1dab3119d27466fc888556e688195ceb38 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./UsersAppContainer')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./UsersAppContainer')) }
   }
 ];
 
index fcebe06dc0feb28540f7f77b90848f29b8e7b936..56f159d6cc6cacca372f83d13df00f19829498b9 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/WebApiApp')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/WebApiApp')) }
   },
   {
     path: '**',
-    component: lazyLoad(() => import('./components/WebApiApp'))
+    component: lazyLoadComponent(() => import('./components/WebApiApp'))
   }
 ];
 
index 168c5c58de68acecdf411d816d2affb5933a463a..92b03bc56073c8b9a190bc5a7277cf194d6b98fc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
 const routes = [
   {
-    indexRoute: { component: lazyLoad(() => import('./components/App')) }
+    indexRoute: { component: lazyLoadComponent(() => import('./components/App')) }
   }
 ];
 
index 366e4003b9604d3e4643c6e03b954c617b98cd78..0f157ddb6ef90aa8a5c1a1f9bf86f27497e63edc 100644 (file)
@@ -17,9 +17,9 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 
-const SourceViewer = lazyLoad(
+const SourceViewer = lazyLoadComponent(
   () => import(/* webpackPrefetch: true */ './SourceViewerBase'),
   'SourceViewer'
 );
index 1872532b9aa222842057774cf73f3d380a0ab09e..e4588216300c062aa194415ef11f5e34786d0bcf 100644 (file)
@@ -67,17 +67,17 @@ export interface Props {
   // but kept to maintaint the location indexes
   highlightedLocations?: (T.FlowLocation | undefined)[];
   highlightedLocationMessage?: { index: number; text: string | undefined };
-  loadComponent: (
+  loadComponent?: (
     component: string,
     branchLike: BranchLike | undefined
   ) => Promise<T.SourceViewerFile>;
-  loadIssues: (
+  loadIssues?: (
     component: string,
     from: number,
     to: number,
     branchLike: BranchLike | undefined
   ) => Promise<T.Issue[]>;
-  loadSources: (
+  loadSources?: (
     component: string,
     from: number,
     to: number,
@@ -129,10 +129,7 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
     displayAllIssues: false,
     displayIssueLocationsCount: true,
     displayIssueLocationsLink: true,
-    displayLocationMarkers: true,
-    loadComponent: defaultLoadComponent,
-    loadIssues: defaultLoadIssues,
-    loadSources: defaultLoadSources
+    displayLocationMarkers: true
   };
 
   constructor(props: Props) {
@@ -208,6 +205,18 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
     this.mounted = false;
   }
 
+  get loadComponent() {
+    return this.props.loadComponent || defaultLoadComponent;
+  }
+
+  get loadIssues() {
+    return this.props.loadIssues || defaultLoadIssues;
+  }
+
+  get propsLoadSources() {
+    return this.props.loadSources || defaultLoadSources;
+  }
+
   computeCoverageStatus(lines: T.SourceLine[]) {
     return lines.map(line => ({ ...line, coverageStatus: getCoverageStatus(line) }));
   }
@@ -228,7 +237,7 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
 
     const to = (this.props.aroundLine || 0) + LINES;
     const loadIssues = (component: T.SourceViewerFile, sources: T.SourceLine[]) => {
-      this.props.loadIssues(this.props.component, 1, to, this.props.branchLike).then(
+      this.loadIssues(this.props.component, 1, to, this.props.branchLike).then(
         issues => {
           if (this.mounted) {
             const finalSources = sources.slice(0, LINES);
@@ -300,9 +309,10 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
       );
     };
 
-    this.props
-      .loadComponent(this.props.component, this.props.branchLike)
-      .then(onResolve, onFailLoadComponent);
+    this.loadComponent(this.props.component, this.props.branchLike).then(
+      onResolve,
+      onFailLoadComponent
+    );
   }
 
   fetchSources() {
@@ -335,27 +345,25 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
     }
     const firstSourceLine = this.state.sources[0];
     const lastSourceLine = this.state.sources[this.state.sources.length - 1];
-    this.props
-      .loadIssues(
-        this.props.component,
-        firstSourceLine && firstSourceLine.line,
-        lastSourceLine && lastSourceLine.line,
-        this.props.branchLike
-      )
-      .then(
-        issues => {
-          if (this.mounted) {
-            this.setState({
-              issues,
-              issuesByLine: issuesByLine(issues),
-              issueLocationsByLine: locationsByLine(issues)
-            });
-          }
-        },
-        () => {
-          // TODO
+    this.loadIssues(
+      this.props.component,
+      firstSourceLine && firstSourceLine.line,
+      lastSourceLine && lastSourceLine.line,
+      this.props.branchLike
+    ).then(
+      issues => {
+        if (this.mounted) {
+          this.setState({
+            issues,
+            issuesByLine: issuesByLine(issues),
+            issueLocationsByLine: locationsByLine(issues)
+          });
         }
-      );
+      },
+      () => {
+        // TODO
+      }
+    );
   }
 
   loadSources = (): Promise<T.SourceLine[]> => {
@@ -381,9 +389,10 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
       // request one additional line to define `hasSourcesAfter`
       to++;
 
-      return this.props
-        .loadSources(this.props.component, from, to, this.props.branchLike)
-        .then(sources => resolve(sources), onFailLoadSources);
+      return this.propsLoadSources(this.props.component, from, to, this.props.branchLike).then(
+        sources => resolve(sources),
+        onFailLoadSources
+      );
     });
   };
 
@@ -394,43 +403,34 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
     const firstSourceLine = this.state.sources[0];
     this.setState({ loadingSourcesBefore: true });
     const from = Math.max(1, firstSourceLine.line - LINES);
-    this.props
-      .loadSources(this.props.component, from, firstSourceLine.line - 1, this.props.branchLike)
-      .then(
-        sources => {
-          this.props
-            .loadIssues(this.props.component, from, firstSourceLine.line - 1, this.props.branchLike)
-            .then(
-              issues => {
-                if (this.mounted) {
-                  this.setState(prevState => {
-                    const nextIssues = uniqBy(
-                      [...issues, ...(prevState.issues || [])],
-                      issue => issue.key
-                    );
-                    return {
-                      issues: nextIssues,
-                      issuesByLine: issuesByLine(nextIssues),
-                      issueLocationsByLine: locationsByLine(nextIssues),
-                      loadingSourcesBefore: false,
-                      sources: [
-                        ...this.computeCoverageStatus(sources),
-                        ...(prevState.sources || [])
-                      ],
-                      symbolsByLine: { ...prevState.symbolsByLine, ...symbolsByLine(sources) }
-                    };
-                  });
-                }
-              },
-              () => {
-                // TODO
-              }
-            );
-        },
-        () => {
-          // TODO
+    Promise.all([
+      this.propsLoadSources(
+        this.props.component,
+        from,
+        firstSourceLine.line - 1,
+        this.props.branchLike
+      ),
+      this.loadIssues(this.props.component, from, firstSourceLine.line - 1, this.props.branchLike)
+    ]).then(
+      ([sources, issues]) => {
+        if (this.mounted) {
+          this.setState(prevState => {
+            const nextIssues = uniqBy([...issues, ...(prevState.issues || [])], issue => issue.key);
+            return {
+              issues: nextIssues,
+              issuesByLine: issuesByLine(nextIssues),
+              issueLocationsByLine: locationsByLine(nextIssues),
+              loadingSourcesBefore: false,
+              sources: [...this.computeCoverageStatus(sources), ...(prevState.sources || [])],
+              symbolsByLine: { ...prevState.symbolsByLine, ...symbolsByLine(sources) }
+            };
+          });
         }
-      );
+      },
+      () => {
+        // TODO
+      }
+    );
   };
 
   loadSourcesAfter = () => {
@@ -442,38 +442,31 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
     const fromLine = lastSourceLine.line + 1;
     // request one additional line to define `hasSourcesAfter`
     const toLine = lastSourceLine.line + LINES + 1;
-    this.props.loadSources(this.props.component, fromLine, toLine, this.props.branchLike).then(
-      sources => {
-        this.props.loadIssues(this.props.component, fromLine, toLine, this.props.branchLike).then(
-          issues => {
-            if (this.mounted) {
-              this.setState(prevState => {
-                const nextIssues = uniqBy(
-                  [...(prevState.issues || []), ...issues],
-                  issue => issue.key
-                );
-                return {
-                  issues: nextIssues,
-                  issuesByLine: issuesByLine(nextIssues),
-                  issueLocationsByLine: locationsByLine(nextIssues),
-                  hasSourcesAfter: sources.length > LINES,
-                  loadingSourcesAfter: false,
-                  sources: [
-                    ...(prevState.sources || []),
-                    ...this.computeCoverageStatus(sources.slice(0, LINES))
-                  ],
-                  symbolsByLine: {
-                    ...prevState.symbolsByLine,
-                    ...symbolsByLine(sources.slice(0, LINES))
-                  }
-                };
-              });
-            }
-          },
-          () => {
-            // TODO
-          }
-        );
+    Promise.all([
+      this.propsLoadSources(this.props.component, fromLine, toLine, this.props.branchLike),
+      this.loadIssues(this.props.component, fromLine, toLine, this.props.branchLike)
+    ]).then(
+      ([sources, issues]) => {
+        if (this.mounted) {
+          this.setState(prevState => {
+            const nextIssues = uniqBy([...(prevState.issues || []), ...issues], issue => issue.key);
+            return {
+              issues: nextIssues,
+              issuesByLine: issuesByLine(nextIssues),
+              issueLocationsByLine: locationsByLine(nextIssues),
+              hasSourcesAfter: sources.length > LINES,
+              loadingSourcesAfter: false,
+              sources: [
+                ...(prevState.sources || []),
+                ...this.computeCoverageStatus(sources.slice(0, LINES))
+              ],
+              symbolsByLine: {
+                ...prevState.symbolsByLine,
+                ...symbolsByLine(sources.slice(0, LINES))
+              }
+            };
+          });
+        }
       },
       () => {
         // TODO
@@ -723,7 +716,10 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
   }
 }
 
-function defaultLoadComponent(component: string, branchLike: BranchLike | undefined) {
+function defaultLoadComponent(
+  component: string,
+  branchLike: BranchLike | undefined
+): Promise<T.SourceViewerFile> {
   return Promise.all([
     getComponentForSourceViewer({ component, ...getBranchLikeQuery(branchLike) }),
     getComponentData({ component, ...getBranchLikeQuery(branchLike) })
index e7ae07b774bf5037c6744f7d417b7a47a65df3cf..6bcce8bb4d3f83c4846f1a673ab44fc9ced399cc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
+import { shallow } from 'enzyme';
 import * as React from 'react';
+import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
+import { getComponentData, getComponentForSourceViewer, getSources } from '../../../api/components';
 import { mockMainBranch } from '../../../helpers/mocks/branch-like';
+import { mockIssue, mockSourceLine, mockSourceViewerFile } from '../../../helpers/testMocks';
+import defaultLoadIssues from '../helpers/loadIssues';
 import SourceViewerBase from '../SourceViewerBase';
 
-it('should render correctly', () => {
-  expect(shallowRender()).toMatchSnapshot();
+jest.mock('../helpers/loadIssues', () => ({
+  default: jest.fn().mockRejectedValue({})
+}));
+
+jest.mock('../../../api/components', () => ({
+  getComponentForSourceViewer: jest.fn().mockRejectedValue(''),
+  getComponentData: jest.fn().mockRejectedValue(''),
+  getSources: jest.fn().mockRejectedValue('')
+}));
+
+beforeEach(() => {
+  jest.resetAllMocks();
+});
+
+it('should render nothing from the start', () => {
+  expect(shallowRender().type()).toBeNull();
+});
+
+it('should render correctly', async () => {
+  (defaultLoadIssues as jest.Mock).mockResolvedValueOnce([mockIssue()]);
+  (getComponentForSourceViewer as jest.Mock).mockResolvedValueOnce(mockSourceViewerFile());
+  (getComponentData as jest.Mock).mockResolvedValueOnce({
+    component: { leakPeriodDate: '2018-06-20T17:12:19+0200' }
+  });
+  (getSources as jest.Mock).mockResolvedValueOnce([]);
+
+  const wrapper = shallowRender();
+  await waitAndUpdate(wrapper);
+
+  expect(wrapper).toMatchSnapshot();
+});
+
+it('should use load props if provided', () => {
+  const loadComponent = jest.fn().mockResolvedValue({});
+  const loadIssues = jest.fn().mockResolvedValue([]);
+  const loadSources = jest.fn().mockResolvedValue([]);
+  const wrapper = shallowRender({
+    loadComponent,
+    loadIssues,
+    loadSources
+  });
+
+  expect(wrapper.instance().loadComponent).toBe(loadComponent);
+});
+
+it('should reload', async () => {
+  (defaultLoadIssues as jest.Mock)
+    .mockResolvedValueOnce([mockIssue()])
+    .mockResolvedValueOnce([mockIssue()]);
+  (getComponentForSourceViewer as jest.Mock).mockResolvedValueOnce(mockSourceViewerFile());
+  (getComponentData as jest.Mock).mockResolvedValueOnce({
+    component: { leakPeriodDate: '2018-06-20T17:12:19+0200' }
+  });
+  (getSources as jest.Mock).mockResolvedValueOnce([mockSourceLine()]);
+
+  const wrapper = shallowRender();
+  await waitAndUpdate(wrapper);
+
+  wrapper.instance().reloadIssues();
+
+  expect(defaultLoadIssues).toBeCalledTimes(2);
+
+  await waitAndUpdate(wrapper);
+
+  expect(wrapper.state().issues).toHaveLength(1);
+});
+
+it('should load sources before', async () => {
+  (defaultLoadIssues as jest.Mock)
+    .mockResolvedValueOnce([mockIssue(false, { key: 'issue1' })])
+    .mockResolvedValueOnce([mockIssue(false, { key: 'issue2' })]);
+  (getComponentForSourceViewer as jest.Mock).mockResolvedValueOnce(mockSourceViewerFile());
+  (getComponentData as jest.Mock).mockResolvedValueOnce({
+    component: { leakPeriodDate: '2018-06-20T17:12:19+0200' }
+  });
+  (getSources as jest.Mock)
+    .mockResolvedValueOnce([mockSourceLine()])
+    .mockResolvedValueOnce([mockSourceLine()]);
+
+  const wrapper = shallowRender();
+  await waitAndUpdate(wrapper);
+
+  wrapper.instance().loadSourcesBefore();
+  expect(wrapper.state().loadingSourcesBefore).toBe(true);
+
+  expect(defaultLoadIssues).toBeCalledTimes(2);
+  expect(getSources).toBeCalledTimes(2);
+
+  await waitAndUpdate(wrapper);
+  expect(wrapper.state().loadingSourcesBefore).toBe(false);
+  expect(wrapper.state().issues).toHaveLength(2);
+});
+
+it('should load sources after', async () => {
+  (defaultLoadIssues as jest.Mock)
+    .mockResolvedValueOnce([mockIssue(false, { key: 'issue1' })])
+    .mockResolvedValueOnce([mockIssue(false, { key: 'issue2' })]);
+  (getComponentForSourceViewer as jest.Mock).mockResolvedValueOnce(mockSourceViewerFile());
+  (getComponentData as jest.Mock).mockResolvedValueOnce({
+    component: { leakPeriodDate: '2018-06-20T17:12:19+0200' }
+  });
+  (getSources as jest.Mock)
+    .mockResolvedValueOnce([mockSourceLine()])
+    .mockResolvedValueOnce([mockSourceLine()]);
+
+  const wrapper = shallowRender();
+  await waitAndUpdate(wrapper);
+
+  wrapper.instance().loadSourcesAfter();
+  expect(wrapper.state().loadingSourcesAfter).toBe(true);
+
+  expect(defaultLoadIssues).toBeCalledTimes(2);
+  expect(getSources).toBeCalledTimes(2);
+
+  await waitAndUpdate(wrapper);
+
+  expect(wrapper.state().loadingSourcesAfter).toBe(false);
+  expect(wrapper.state().issues).toHaveLength(2);
 });
 
-function shallowRender() {
-  return <SourceViewerBase branchLike={mockMainBranch()} component="my-component" />;
+function shallowRender(overrides: Partial<SourceViewerBase['props']> = {}) {
+  return shallow<SourceViewerBase>(
+    <SourceViewerBase branchLike={mockMainBranch()} component="my-component" {...overrides} />
+  );
 }
index 8b0b0958b9f8a269f62fa061d85a9debcff1a9f9..1c54b6275983ef20761aad43f45434823a41d996 100644 (file)
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
 exports[`should render correctly 1`] = `
-<SourceViewerBase
-  branchLike={
+<ContextProvider
+  value={
     Object {
-      "analysisDate": "2018-01-01",
-      "excludedFromPurge": true,
-      "isMain": true,
-      "name": "master",
+      "branchLike": Object {
+        "analysisDate": "2018-01-01",
+        "excludedFromPurge": true,
+        "isMain": true,
+        "name": "master",
+      },
+      "file": Object {
+        "key": "foo",
+        "leakPeriodDate": "2018-06-20T17:12:19+0200",
+        "measures": Object {
+          "coverage": "85.2",
+          "duplicationDensity": "1.0",
+          "issues": "12",
+          "lines": "56",
+        },
+        "path": "foo/bar.ts",
+        "project": "my-project",
+        "projectName": "MyProject",
+        "q": "FIL",
+        "uuid": "foo-bar",
+      },
     }
   }
-  component="my-component"
-  displayAllIssues={false}
-  displayIssueLocationsCount={true}
-  displayIssueLocationsLink={true}
-  displayLocationMarkers={true}
-  loadComponent={[Function]}
-  loadIssues={[Function]}
-  loadSources={[Function]}
-/>
+>
+  <div
+    className="source-viewer"
+  >
+    <ContextConsumer>
+      <Component />
+    </ContextConsumer>
+    <SourceViewerCode
+      branchLike={
+        Object {
+          "analysisDate": "2018-01-01",
+          "excludedFromPurge": true,
+          "isMain": true,
+          "name": "master",
+        }
+      }
+      componentKey="my-component"
+      displayAllIssues={false}
+      displayIssueLocationsCount={true}
+      displayIssueLocationsLink={true}
+      displayLocationMarkers={true}
+      duplicationsByLine={Object {}}
+      hasSourcesAfter={false}
+      hasSourcesBefore={false}
+      highlightedSymbols={Array []}
+      issueLocationsByLine={
+        Object {
+          "25": Array [
+            Object {
+              "from": 0,
+              "line": 25,
+              "to": 999999,
+            },
+          ],
+          "26": Array [
+            Object {
+              "from": 0,
+              "line": 26,
+              "to": 15,
+            },
+          ],
+        }
+      }
+      issues={
+        Array [
+          Object {
+            "actions": Array [],
+            "component": "main.js",
+            "componentLongName": "main.js",
+            "componentQualifier": "FIL",
+            "componentUuid": "foo1234",
+            "creationDate": "2017-03-01T09:36:01+0100",
+            "flows": Array [],
+            "fromHotspot": false,
+            "key": "AVsae-CQS-9G3txfbFN2",
+            "line": 25,
+            "message": "Reduce the number of conditional operators (4) used in the expression",
+            "organization": "myorg",
+            "project": "myproject",
+            "projectKey": "foo",
+            "projectName": "Foo",
+            "projectOrganization": "org",
+            "rule": "javascript:S1067",
+            "ruleName": "foo",
+            "secondaryLocations": Array [],
+            "severity": "MAJOR",
+            "status": "OPEN",
+            "textRange": Object {
+              "endLine": 26,
+              "endOffset": 15,
+              "startLine": 25,
+              "startOffset": 0,
+            },
+            "transitions": Array [],
+            "type": "BUG",
+          },
+        ]
+      }
+      issuesByLine={
+        Object {
+          "26": Array [
+            Object {
+              "actions": Array [],
+              "component": "main.js",
+              "componentLongName": "main.js",
+              "componentQualifier": "FIL",
+              "componentUuid": "foo1234",
+              "creationDate": "2017-03-01T09:36:01+0100",
+              "flows": Array [],
+              "fromHotspot": false,
+              "key": "AVsae-CQS-9G3txfbFN2",
+              "line": 25,
+              "message": "Reduce the number of conditional operators (4) used in the expression",
+              "organization": "myorg",
+              "project": "myproject",
+              "projectKey": "foo",
+              "projectName": "Foo",
+              "projectOrganization": "org",
+              "rule": "javascript:S1067",
+              "ruleName": "foo",
+              "secondaryLocations": Array [],
+              "severity": "MAJOR",
+              "status": "OPEN",
+              "textRange": Object {
+                "endLine": 26,
+                "endOffset": 15,
+                "startLine": 25,
+                "startOffset": 0,
+              },
+              "transitions": Array [],
+              "type": "BUG",
+            },
+          ],
+        }
+      }
+      loadDuplications={[Function]}
+      loadSourcesAfter={[Function]}
+      loadSourcesBefore={[Function]}
+      loadingSourcesAfter={false}
+      loadingSourcesBefore={false}
+      onIssueChange={[Function]}
+      onIssuePopupToggle={[Function]}
+      onIssueSelect={[Function]}
+      onIssueUnselect={[Function]}
+      onIssuesClose={[Function]}
+      onIssuesOpen={[Function]}
+      onLinePopupToggle={[Function]}
+      onSymbolClick={[Function]}
+      openIssuesByLine={Object {}}
+      renderDuplicationPopup={[Function]}
+      sources={Array []}
+      symbolsByLine={Object {}}
+    />
+  </div>
+</ContextProvider>
 `;
index ca84132317bc13434d22aeba86e4894b2a61022d..0a85275bd022648c783553443a57ca87653b3899 100644 (file)
@@ -32,7 +32,7 @@ import Select from 'sonar-ui-common/components/controls/Select';
 import CalendarIcon from 'sonar-ui-common/components/icons/CalendarIcon';
 import ChevronLeftIcon from 'sonar-ui-common/components/icons/ChevronLeftIcon';
 import ChevronRightIcon from 'sonar-ui-common/components/icons/ChevronRightIcon';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import {
   getShortMonthName,
   getShortWeekDayName,
@@ -41,7 +41,7 @@ import {
 import './DayPicker.css';
 import './styles.css';
 
-const DayPicker = lazyLoad(() => import('react-day-picker'));
+const DayPicker = lazyLoadComponent(() => import('react-day-picker'), 'DayPicker');
 
 interface Props {
   className?: string;
index decde97522b10bc8c88b463a06713971f37fb0e1..a1cfb5d215021a1bbb72902876ab88fd756d777d 100644 (file)
  */
 import * as React from 'react';
 import HelpTooltip from 'sonar-ui-common/components/controls/HelpTooltip';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { filterContent } from '../../helpers/markdown';
 
-const DocMarkdownBlock = lazyLoad(() => import('./DocMarkdownBlock'));
+const DocMarkdownBlock = lazyLoadComponent(() => import('./DocMarkdownBlock'), 'DocMarkdownBlock');
 
 interface Props {
   className?: string;
index 2c9968861339f0cbdd68783f328b2cde7a4ebd89..cb2fe21b9d99745e6f59935867c1ee54a4d7527b 100644 (file)
@@ -8,7 +8,7 @@ exports[`should render 2`] = `
     <div
       className="abs-width-300"
     >
-      <LazyLoader
+      <DocMarkdownBlock
         className="cut-margins"
         content="this is *bold* text"
         isTooltip={true}
index 4856d16f9c23648841e734c179fa534951d874e5..45453eb4189a2a1cb4ffcc145a75b234a1105663 100644 (file)
  */
 import { omit, uniqBy } from 'lodash';
 import * as React from 'react';
-import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
+import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
 import { get, save } from 'sonar-ui-common/helpers/storage';
 import { ComponentDescriptor, RuleDescriptor, WorkspaceContext } from './context';
 import './styles.css';
 import WorkspacePortal from './WorkspacePortal';
 
 const WORKSPACE = 'sonarqube-workspace';
-const WorkspaceNav = lazyLoad(() => import('./WorkspaceNav'));
-const WorkspaceRuleViewer = lazyLoad(() => import('./WorkspaceRuleViewer'));
-const WorkspaceComponentViewer = lazyLoad(() => import('./WorkspaceComponentViewer'));
+const WorkspaceNav = lazyLoadComponent(() => import('./WorkspaceNav'), 'WorkspaceNav');
+const WorkspaceRuleViewer = lazyLoadComponent(
+  () => import('./WorkspaceRuleViewer'),
+  'WorkspaceRuleViewer'
+);
+const WorkspaceComponentViewer = lazyLoadComponent(
+  () => import('./WorkspaceComponentViewer'),
+  'WorkspaceComponentViewer'
+);
 
 interface State {
   components: ComponentDescriptor[];