aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Mugnier <pascal.mugnier@sonarsource.com>2018-05-28 11:55:56 +0200
committerSonarTech <sonartech@sonarsource.com>2018-05-29 20:20:47 +0200
commit8aba91e2773be64fd0279446499c899170ee2ab9 (patch)
tree5e66a8d8748e3c82fef997edc4bc3adde0a93f8e
parentf138d383ba38185ce6d8c2f9f8fb83c20d10d7ef (diff)
downloadsonarqube-8aba91e2773be64fd0279446499c899170ee2ab9.tar.gz
sonarqube-8aba91e2773be64fd0279446499c899170ee2ab9.zip
SONAR-10711 Add pagination object to api/qualityprofile/projects webservice
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java7
-rw-r--r--server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/projects-example.json8
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.tsx2
3 files changed, 14 insertions, 3 deletions
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<Props, State> {
componentDidUpdate(prevProps: Props) {
if (prevProps.profile !== this.props.profile) {
- this.loadProjects();
+ this.setState({ projects: null, page: 1 }, this.loadProjects);
}
}