From 24554326887a8d5404927fa55f5ee7bcf49fb69a Mon Sep 17 00:00:00 2001 From: guillaume-peoch-sonarsource Date: Wed, 7 Jun 2023 15:03:08 +0200 Subject: [PATCH] SONAR-18971 QualityProfile page doesn't load more than 100 projects --- .../js/apps/quality-profiles/details/ProfileProjects.tsx | 8 +++++--- .../details/__tests__/ProfileProjects-test.tsx | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.tsx index 3d1c70ff730..59e19683ef8 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.tsx @@ -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 { } 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 { 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); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx index 2694164ac55..c38aaeedff1 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx @@ -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 () => { -- 2.39.5