*/
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;
* 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;
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';
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'
);
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;
*/
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 {
}
/>
</Alert>
- <LazyLoader
+ <AnalysisWarningsModal
onClose={[Function]}
warnings={
Array [
*/
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 {
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'
);
}
}
-export default withRouter(GlobalNavPlus);
+export default withRouter<Props>(GlobalNavPlus);
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';
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'>;
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';
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';
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} />
<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"
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} />
<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>
);
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} />
<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}>
</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} />
</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>
* 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;
* 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'))
}
]
}
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'
);
* 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')) }
}
];
* 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')) }
}
];
* 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 {
replace({ pathname: nextState.location.pathname, query: normalizedQuery });
}
},
- component: lazyLoad(() => import('./components/App'))
+ component: lazyLoadComponent(() => import('./components/App'))
}
}
];
* 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',
* 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')) }
}
];
* 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')) }
}
];
* 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 } }];
* 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')) }
}
];
+++ /dev/null
-/*
- * 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);
+++ /dev/null
-/*
- * 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} />
- );
-}
+++ /dev/null
-// 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 {},
- }
- }
-/>
-`;
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';
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,
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';
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[];
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) {
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 => ({
handleReload = () => {
this.fetchFirstIssues();
this.refreshBranchStatus();
- if (isPullRequest(this.props.branchLike)) {
- this.props.onBranchesChange();
+ const { branchLike, onBranchesChange } = this.props;
+ if (onBranchesChange && isPullRequest(branchLike)) {
+ onBranchesChange();
}
};
);
}
}
-
-const mapDispatchToProps = { fetchBranchStatus: fetchBranchStatus as any };
-
-export default withRouter(connect(null, mapDispatchToProps)(App));
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,
Store
} from '../../../store/rootReducer';
+const IssuesAppContainer = lazyLoadComponent(() => import('./App'), 'IssuesAppContainer');
+
interface StateProps {
currentUser: T.CurrentUser;
userOrganizations: T.Organization[];
.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));
* 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';
: 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}
selectPreviousFlow,
selectPreviousLocation
} from '../../actions';
-import { App } from '../App';
+import App from '../App';
jest.mock('sonar-ui-common/helpers/handleRequiredAuthentication', () => ({
default: jest.fn()
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');
rules: [],
users: []
})}
- location={{ pathname: '/issues', query: {} }}
+ location={mockLocation({ pathname: '/issues', query: {} })}
onBranchesChange={() => {}}
organization={{ key: 'foo' }}
router={mockRouter()}
"name": "master",
}
}
- components={
- Array [
- "main.js",
- ]
- }
issue={
Object {
"actions": Array [],
* 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'
);
*/
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'))} />
);
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;
<div
className="boxed-group boxed-group-inner marketplace-edition"
>
- <LazyLoader />
+ <DocMarkdownBlock />
<div
className="marketplace-edition-action spacer-top"
>
* 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')) }
}
];
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" />
</>
);
* 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: {
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'))
+ }
+ }
]
},
{
},
{
path: 'members',
- component: lazyLoad(() => import('../organizationMembers/OrganizationMembersContainer'))
+ component: lazyLoadComponent(() =>
+ import('../organizationMembers/OrganizationMembersContainer')
+ )
},
{
path: 'quality_profiles',
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')
)
}
* 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';
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;
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[];
const mapDispatchToProps = { fetchBranchStatus: fetchBranchStatus as any };
-export default connect(mapStateToProps, mapDispatchToProps)(PullRequestOverview);
+export default connect<StateProps, DispatchProps, OwnProps>(
+ mapStateToProps,
+ mapDispatchToProps
+)(PullRequestOverview);
* 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')) }
}
];
* 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')) }
}
];
* 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')) }
}
];
* 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')) }
}
];
* 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'))
}
}
];
* 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')) }
}
];
* 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')) }
}
];
* 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')) }
}
];
* 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')) }
}
];
* 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) => ({
organizationsEnabled: areThereCustomOrganizations(state)
});
-export default connect(stateToProps)(lazyLoad(() => import('./AllProjects')));
+export default connect(stateToProps)(lazyLoadComponent(() => import('./AllProjects')));
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;
shouldBeRedirected !== true &&
shouldForceSorting === undefined
) {
- return (
- <AllProjectsContainer
- isFavorite={false}
- location={this.props.location}
- organization={undefined}
- />
- );
+ return <AllProjectsContainer isFavorite={false} organization={undefined} />;
}
return null;
* 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';
{ path: 'favorite', component: FavoriteProjectsContainer },
{
path: 'create',
- component: lazyLoad(() => import('../create/project/CreateProjectPage'))
+ component: lazyLoadComponent(() => import('../create/project/CreateProjectPage'))
}
].filter(isDefined);
* 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')) }
}
];
* 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 }];
*/
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'
);
* 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'))
}
]
}
* 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'))
}
];
* 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'))
}
];
* 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')) }
}
];
* 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'))
}
}
];
* 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')) }
}
];
* 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'))
}
];
* 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')) }
}
];
* 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'
);
// 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,
displayAllIssues: false,
displayIssueLocationsCount: true,
displayIssueLocationsLink: true,
- displayLocationMarkers: true,
- loadComponent: defaultLoadComponent,
- loadIssues: defaultLoadIssues,
- loadSources: defaultLoadSources
+ displayLocationMarkers: true
};
constructor(props: Props) {
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) }));
}
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);
);
};
- this.props
- .loadComponent(this.props.component, this.props.branchLike)
- .then(onResolve, onFailLoadComponent);
+ this.loadComponent(this.props.component, this.props.branchLike).then(
+ onResolve,
+ onFailLoadComponent
+ );
}
fetchSources() {
}
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[]> => {
// 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
+ );
});
};
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 = () => {
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
}
}
-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) })
* 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} />
+ );
}
// 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>
`;
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,
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;
*/
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;
<div
className="abs-width-300"
>
- <LazyLoader
+ <DocMarkdownBlock
className="cut-margins"
content="this is *bold* text"
isTooltip={true}
*/
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[];