aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-web/src/main/js/api/alm-integrations.ts20
-rw-r--r--server/sonar-web/src/main/js/api/mocks/AlmIntegrationsServiceMock.ts25
2 files changed, 35 insertions, 10 deletions
diff --git a/server/sonar-web/src/main/js/api/alm-integrations.ts b/server/sonar-web/src/main/js/api/alm-integrations.ts
index 8958403d766..50d8e241f78 100644
--- a/server/sonar-web/src/main/js/api/alm-integrations.ts
+++ b/server/sonar-web/src/main/js/api/alm-integrations.ts
@@ -103,20 +103,31 @@ export function importAzureRepository(data: {
export function getBitbucketServerProjects(
almSetting: string,
-): Promise<{ projects: BitbucketProject[] }> {
- return getJSON('/api/alm_integrations/list_bitbucketserver_projects', { almSetting });
+ start?: number,
+ pageSize?: number,
+): Promise<{ isLastPage: boolean; nextPageStart: number; projects: BitbucketProject[] }> {
+ return getJSON('/api/alm_integrations/list_bitbucketserver_projects', {
+ almSetting,
+ pageSize,
+ start,
+ });
}
export function getBitbucketServerRepositories(
almSetting: string,
projectName: string,
+ start?: number,
+ pageSize?: number,
): Promise<{
isLastPage: boolean;
+ nextPageStart: number;
repositories: BitbucketRepository[];
}> {
return getJSON('/api/alm_integrations/search_bitbucketserver_repos', {
almSetting,
+ pageSize,
projectName,
+ start,
});
}
@@ -144,13 +155,18 @@ export function importBitbucketServerProject(data: {
export function searchForBitbucketServerRepositories(
almSetting: string,
repositoryName: string,
+ start?: number,
+ pageSize?: number,
): Promise<{
isLastPage: boolean;
+ nextPageStart: number;
repositories: BitbucketRepository[];
}> {
return getJSON('/api/alm_integrations/search_bitbucketserver_repos', {
almSetting,
+ pageSize,
repositoryName,
+ start,
});
}
diff --git a/server/sonar-web/src/main/js/api/mocks/AlmIntegrationsServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/AlmIntegrationsServiceMock.ts
index 540e0ebfbf6..752d8d3cb22 100644
--- a/server/sonar-web/src/main/js/api/mocks/AlmIntegrationsServiceMock.ts
+++ b/server/sonar-web/src/main/js/api/mocks/AlmIntegrationsServiceMock.ts
@@ -77,7 +77,8 @@ export default class AlmIntegrationsServiceMock {
githubRepositories: GithubRepository[];
pagination: Paging;
bitbucketCloudRepositories: BitbucketCloudRepository[];
- bitbucketIsLastPage: boolean;
+ bitbucketProjectsIsLastPage: boolean;
+ bitbucketReposIsLastPage: boolean;
bitbucketRepositories: BitbucketRepository[];
bitbucketProjects: BitbucketProject[];
defaultAlmInstancePATMap: { [key: string]: boolean } = {
@@ -189,7 +190,8 @@ export default class AlmIntegrationsServiceMock {
this.githubRepositories = cloneDeep(this.defaultGithubRepositories);
this.bitbucketRepositories = cloneDeep(this.defaultBitbucketRepositories);
this.bitbucketProjects = cloneDeep(this.defaultBitbucketProjects);
- this.bitbucketIsLastPage = true;
+ this.bitbucketProjectsIsLastPage = true;
+ this.bitbucketReposIsLastPage = true;
jest
.mocked(checkPersonalAccessTokenIsValid)
.mockImplementation(this.checkPersonalAccessTokenIsValid);
@@ -267,7 +269,7 @@ export default class AlmIntegrationsServiceMock {
searchForBitbucketCloudRepositories = () => {
return Promise.resolve({
- isLastPage: this.bitbucketIsLastPage,
+ isLastPage: this.bitbucketReposIsLastPage,
repositories: this.bitbucketCloudRepositories,
});
};
@@ -311,7 +313,7 @@ export default class AlmIntegrationsServiceMock {
});
this.bitbucketCloudRepositories = generatedRepositories;
- this.bitbucketIsLastPage = quantity >= total;
+ this.bitbucketReposIsLastPage = quantity >= total;
}
createRandomGithubRepositoriessWithLoadMore(quantity: number, total: number) {
@@ -362,12 +364,17 @@ export default class AlmIntegrationsServiceMock {
};
getBitbucketServerProjects = () => {
- return Promise.resolve({ projects: this.bitbucketProjects });
+ return Promise.resolve({
+ isLastPage: this.bitbucketProjectsIsLastPage,
+ nextPageStart: this.bitbucketProjects.length - Number(this.bitbucketProjectsIsLastPage),
+ projects: this.bitbucketProjects,
+ });
};
getBitbucketServerRepositories = () => {
return Promise.resolve({
- isLastPage: this.bitbucketIsLastPage,
+ isLastPage: this.bitbucketReposIsLastPage,
+ nextPageStart: this.bitbucketRepositories.length - Number(this.bitbucketReposIsLastPage),
repositories: this.bitbucketRepositories,
});
};
@@ -389,7 +396,8 @@ export default class AlmIntegrationsServiceMock {
searchForBitbucketServerRepositories = () => {
return Promise.resolve({
- isLastPage: this.bitbucketIsLastPage,
+ isLastPage: this.bitbucketReposIsLastPage,
+ nextPageStart: this.bitbucketRepositories.length - Number(this.bitbucketReposIsLastPage),
repositories: this.bitbucketRepositories,
});
};
@@ -402,6 +410,7 @@ export default class AlmIntegrationsServiceMock {
this.bitbucketCloudRepositories = cloneDeep(this.defaultBitbucketCloudRepositories);
this.bitbucketRepositories = cloneDeep(this.defaultBitbucketRepositories);
this.bitbucketProjects = cloneDeep(this.defaultBitbucketProjects);
- this.bitbucketIsLastPage = true;
+ this.bitbucketProjectsIsLastPage = true;
+ this.bitbucketReposIsLastPage = true;
};
}