From 2677db7c158f90bbd259eacf0d50941875f48a8b Mon Sep 17 00:00:00 2001 From: Julio Zynger Date: Wed, 30 Mar 2022 17:31:50 +0200 Subject: [PATCH] Add table pagination to GoCD plugin The default value for the GoCD API is [10 pipelines per page](https://api.gocd.org/current/#get-pipeline-history). Here we increase the requested page size to the maximum (100 pipelines per page) and add pagination controls to the build tables. We still don't have _actual request pagination_ implemented, which means we only ever perform a single request - that will come in a future contribution. Signed-off-by: Julio Zynger --- .changeset/swift-fans-shout.md | 5 +++++ plugins/gocd/src/api/gocdApi.client.ts | 4 +++- .../gocd/src/components/GoCdBuildsTable/GoCdBuildsTable.tsx | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .changeset/swift-fans-shout.md diff --git a/.changeset/swift-fans-shout.md b/.changeset/swift-fans-shout.md new file mode 100644 index 0000000000..7a11b70592 --- /dev/null +++ b/.changeset/swift-fans-shout.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-gocd': patch +--- + +Add pagination controls to GoCD build table diff --git a/plugins/gocd/src/api/gocdApi.client.ts b/plugins/gocd/src/api/gocdApi.client.ts index 1f4955a80d..2c45632b33 100644 --- a/plugins/gocd/src/api/gocdApi.client.ts +++ b/plugins/gocd/src/api/gocdApi.client.ts @@ -18,6 +18,8 @@ import { GoCdApiError, PipelineHistory } from './gocdApi.model'; import { DiscoveryApi } from '@backstage/core-plugin-api'; import { ResponseError } from '@backstage/errors'; +const DEFAULT_PAGE_SIZE = 100; + export class GoCdClientApi implements GoCdApi { constructor(private readonly discoveryApi: DiscoveryApi) {} @@ -26,7 +28,7 @@ export class GoCdClientApi implements GoCdApi { ): Promise { const baseUrl = await this.discoveryApi.getBaseUrl('proxy'); const pipelineHistoryResponse = await fetch( - `${baseUrl}/gocd/pipelines/${pipelineName}/history`, + `${baseUrl}/gocd/pipelines/${pipelineName}/history?page_size=${DEFAULT_PAGE_SIZE}`, { headers: { Accept: 'application/vnd.go.cd+json', diff --git a/plugins/gocd/src/components/GoCdBuildsTable/GoCdBuildsTable.tsx b/plugins/gocd/src/components/GoCdBuildsTable/GoCdBuildsTable.tsx index 51ba2b6e8c..58dfbcca39 100644 --- a/plugins/gocd/src/components/GoCdBuildsTable/GoCdBuildsTable.tsx +++ b/plugins/gocd/src/components/GoCdBuildsTable/GoCdBuildsTable.tsx @@ -244,9 +244,11 @@ export const GoCdBuildsTable = (props: GoCdBuildsProps): JSX.Element => { search: true, searchAutoFocus: true, debounceInterval: 800, - paging: false, + paging: true, + padding: 'dense', + pageSizeOptions: [5, 10, 20, 50], showFirstLastPageButtons: false, - pageSize: 10, + pageSize: 20, }} columns={columns} data={