From b2d04967ba8a20722d62947c7106636c2a5b9a73 Mon Sep 17 00:00:00 2001 From: mo Date: Fri, 29 Apr 2022 07:50:03 -0500 Subject: [PATCH] client getGitTags, still calls /pull-requests/ Signed-off-by: mo --- .../azure-devops/src/api/AzureDevOpsApi.ts | 1 - .../azure-devops/src/api/AzureDevOpsClient.ts | 21 ++++++++++++++++++- plugins/azure-devops/src/hooks/useGitTags.ts | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/plugins/azure-devops/src/api/AzureDevOpsApi.ts b/plugins/azure-devops/src/api/AzureDevOpsApi.ts index e4f4e32b6b..63e6dc3125 100644 --- a/plugins/azure-devops/src/api/AzureDevOpsApi.ts +++ b/plugins/azure-devops/src/api/AzureDevOpsApi.ts @@ -39,7 +39,6 @@ export interface AzureDevOpsApi { ): Promise<{ items: RepoBuild[] }>; getGitTags( - // TODO: Keep iterating down this rabbit hole on the client once the service has caught up projectName: string, repoName: string, options?: PullRequestOptions, diff --git a/plugins/azure-devops/src/api/AzureDevOpsClient.ts b/plugins/azure-devops/src/api/AzureDevOpsClient.ts index 87a6c7e404..e25ea1e457 100644 --- a/plugins/azure-devops/src/api/AzureDevOpsClient.ts +++ b/plugins/azure-devops/src/api/AzureDevOpsClient.ts @@ -29,7 +29,6 @@ import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api'; import { AzureDevOpsApi } from './AzureDevOpsApi'; import { ResponseError } from '@backstage/errors'; -// TODO: See red squiggly below export class AzureDevOpsClient implements AzureDevOpsApi { private readonly discoveryApi: DiscoveryApi; private readonly identityApi: IdentityApi; @@ -59,6 +58,26 @@ export class AzureDevOpsClient implements AzureDevOpsApi { return { items }; } + public async getGitTags( + projectName: string, + repoName: string, + options?: PullRequestOptions, + ): Promise<{ items: PullRequest[] }> { + const queryString = new URLSearchParams(); + if (options?.top) { + queryString.append('top', options.top.toString()); + } + if (options?.status) { + queryString.append('status', options.status.toString()); + } + const urlSegment = `pull-requests/${encodeURIComponent( + projectName, + )}/${encodeURIComponent(repoName)}?${queryString}`; + + const items = await this.get(urlSegment); + return { items }; + } + public async getPullRequests( projectName: string, repoName: string, diff --git a/plugins/azure-devops/src/hooks/useGitTags.ts b/plugins/azure-devops/src/hooks/useGitTags.ts index 88930109a9..a20d73d940 100644 --- a/plugins/azure-devops/src/hooks/useGitTags.ts +++ b/plugins/azure-devops/src/hooks/useGitTags.ts @@ -48,7 +48,7 @@ export function useGitTags( const { project, repo } = useProjectRepoFromEntity(entity); const { value, loading, error } = useAsync(() => { - return api.getPullRequests(project, repo, options); + return api.getGitTags(project, repo, options); }, [api, project, repo, top, status]); return {