]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-18971 QualityProfile page doesn't load more than 100 projects
authorguillaume-peoch-sonarsource <guillaume.peoch@sonarsource.com>
Wed, 7 Jun 2023 13:03:08 +0000 (15:03 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 12 Jun 2023 20:02:49 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx

index 3d1c70ff730b59eb646d5fad60e05ad4b3d139c7..59e19683ef8ed9647123fc7168386f2cec127796 100644 (file)
@@ -20,9 +20,9 @@
 import * as React from 'react';
 import { getProfileProjects } from '../../../api/quality-profiles';
 import Link from '../../../components/common/Link';
-import { Button } from '../../../components/controls/buttons';
 import ListFooter from '../../../components/controls/ListFooter';
 import Tooltip from '../../../components/controls/Tooltip';
+import { Button } from '../../../components/controls/buttons';
 import QualifierIcon from '../../../components/icons/QualifierIcon';
 import { translate } from '../../../helpers/l10n';
 import { getProjectUrl } from '../../../helpers/urls';
@@ -82,13 +82,14 @@ export default class ProfileProjects extends React.PureComponent<Props, State> {
     }
 
     this.setState({ loading: true });
-    const data = { key: this.props.profile.key, page: this.state.page };
+    const data = { key: this.props.profile.key, p: 1 };
     getProfileProjects(data).then(({ paging, results }) => {
       if (this.mounted) {
         this.setState({
           projects: results,
           total: paging.total,
           loading: false,
+          page: 1,
         });
       }
     }, this.stopLoading);
@@ -96,13 +97,14 @@ export default class ProfileProjects extends React.PureComponent<Props, State> {
 
   loadMore = () => {
     this.setState({ loadingMore: true });
-    const data = { key: this.props.profile.key, page: this.state.page + 1 };
+    const data = { key: this.props.profile.key, p: this.state.page + 1 };
     getProfileProjects(data).then(({ paging, results }) => {
       if (this.mounted) {
         this.setState((state) => ({
           projects: [...state.projects, ...results],
           total: paging.total,
           loadingMore: false,
+          page: state.page + 1,
         }));
       }
     }, this.stopLoading);
index 2694164ac5520042d519748ece9b7f4b2b5e4cd7..c38aaeedff1e00f5c9fe17ddd1544c3b03d1c77b 100644 (file)
@@ -19,6 +19,7 @@
  */
 import { shallow } from 'enzyme';
 import * as React from 'react';
+import { getProfileProjects } from '../../../../api/quality-profiles';
 import { mockQualityProfile } from '../../../../helpers/testMocks';
 import { waitAndUpdate } from '../../../../helpers/testUtils';
 import ChangeProjectsForm from '../ChangeProjectsForm';
@@ -61,6 +62,8 @@ it('should render correctly', async () => {
   });
   wrapper.setState({ projects: [] });
   expect(wrapper).toMatchSnapshot('no active rules, no associated projects');
+  wrapper.instance().loadMore();
+  expect(getProfileProjects).toHaveBeenLastCalledWith({ p: 2, key: 'key' });
 });
 
 it('should open and close the form', async () => {