From: Pascal Mugnier Date: Mon, 28 May 2018 09:55:56 +0000 (+0200) Subject: SONAR-10711 Add pagination object to api/qualityprofile/projects webservice X-Git-Tag: 7.5~1116 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8aba91e2773be64fd0279446499c899170ee2ab9;p=sonarqube.git SONAR-10711 Add pagination object to api/qualityprofile/projects webservice --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java index fb118ff5bff..0ddac92ca87 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java @@ -69,6 +69,7 @@ public class ProjectsAction implements QProfileWsAction { .setResponseExample(getClass().getResource("projects-example.json")); action.setChangelog( + new Change("7.2", "'more' response field is deprecated"), new Change("6.5", "'id' response field is deprecated"), new Change("6.0", "'uuid' response field is deprecated and replaced by 'id'"), new Change("6.0", "'key' response field has been added to return the project key")); @@ -160,6 +161,12 @@ public class ProjectsAction implements QProfileWsAction { .endObject(); } json.endArray(); + json.name("paging").beginObject() + .prop("pageIndex", paging.pageIndex()) + .prop("pageSize", paging.pageSize()) + .prop("total", paging.total()) + .endObject(); + // more is deprecated since 7.2 json.prop("more", paging.hasNextPage()); json.endObject(); json.close(); diff --git a/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/projects-example.json b/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/projects-example.json index 8da87945f84..d1993655b57 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/projects-example.json +++ b/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/projects-example.json @@ -1,4 +1,9 @@ { + "paging": { + "pageIndex": 1, + "pageSize": 100, + "total": 4 + }, "results": [ { "id": "5eab015a-1f76-4ba4-bd89-bf547132d673", @@ -24,6 +29,5 @@ "name": "SonarQube Android Plugin", "selected": false } - ], - "more": false + ] } 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 b73f69f04fc..29a1c9617da 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 @@ -55,7 +55,7 @@ export default class ProfileProjects extends React.PureComponent { componentDidUpdate(prevProps: Props) { if (prevProps.profile !== this.props.profile) { - this.loadProjects(); + this.setState({ projects: null, page: 1 }, this.loadProjects); } }