Adds a new extension point repository.overview.listOptions that can be used to set the page size, whether to list archived repositories or not and potentially other options for the repository overview. If no extension is bound, the default values will be used.

Committed-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
Rene Pfeuffer
2022-12-15 11:16:01 +01:00
committed by SCM-Manager
parent 34bfe49d3e
commit 6ba792e5bc
7 changed files with 97 additions and 13 deletions

View File

@@ -125,6 +125,34 @@ describe("Test repository hooks", () => {
});
});
it("should hide archived repositories", async () => {
const queryClient = createInfiniteCachingClient();
setIndexLink(queryClient, "repositories", "/repos");
fetchMock.get("/api/v2/repos", repositoryCollection, {
query: {
showArchived: "false"
}
});
await expectCollection(queryClient, {
showArchived: false
});
});
it("should set the page size", async () => {
const queryClient = createInfiniteCachingClient();
setIndexLink(queryClient, "repositories", "/repos");
fetchMock.get("/api/v2/repos", repositoryCollection, {
query: {
pageSize: "25"
}
});
await expectCollection(queryClient, {
pageSize: 25
});
});
it("should append search query", async () => {
const queryClient = createInfiniteCachingClient();
setIndexLink(queryClient, "repositories", "/repos");

View File

@@ -47,6 +47,8 @@ export type UseRepositoriesRequest = {
search?: string;
page?: number | string;
disabled?: boolean;
pageSize?: number;
showArchived?: boolean;
};
export const useRepositories = (request?: UseRepositoriesRequest): ApiResult<RepositoryCollection> => {
@@ -59,6 +61,12 @@ export const useRepositories = (request?: UseRepositoriesRequest): ApiResult<Rep
if (request?.search) {
queryParams.q = request.search;
}
if (request?.pageSize) {
queryParams.pageSize = request.pageSize.toString();
}
if (request?.showArchived !== undefined) {
queryParams.showArchived = request.showArchived.toString();
}
if (request?.page) {
queryParams.page = request.page.toString();
}