From 86e94970230d88893371caca90562dfe4b2d4a2c Mon Sep 17 00:00:00 2001 From: mo Date: Mon, 2 May 2022 12:16:42 -0500 Subject: [PATCH] cleaning up frontend Signed-off-by: mo --- .../src/api/AzureDevOpsApi.ts | 1 - .../azure-devops/src/api/AzureDevOpsApi.ts | 1 - .../azure-devops/src/api/AzureDevOpsClient.ts | 10 +----- .../EntityPageAzureGitTags.tsx | 2 +- .../components/GitTagTable/GitTagTable.tsx | 36 ++++++------------- plugins/azure-devops/src/hooks/useGitTags.ts | 25 +++---------- 6 files changed, 16 insertions(+), 59 deletions(-) diff --git a/plugins/azure-devops-backend/src/api/AzureDevOpsApi.ts b/plugins/azure-devops-backend/src/api/AzureDevOpsApi.ts index d4551fc0d2..d77de5d528 100644 --- a/plugins/azure-devops-backend/src/api/AzureDevOpsApi.ts +++ b/plugins/azure-devops-backend/src/api/AzureDevOpsApi.ts @@ -27,7 +27,6 @@ import { Policy, PullRequest, PullRequestOptions, - PullRequestStatus, RepoBuild, Team, TeamMember, diff --git a/plugins/azure-devops/src/api/AzureDevOpsApi.ts b/plugins/azure-devops/src/api/AzureDevOpsApi.ts index 49cb7f9644..ccedc401f1 100644 --- a/plugins/azure-devops/src/api/AzureDevOpsApi.ts +++ b/plugins/azure-devops/src/api/AzureDevOpsApi.ts @@ -42,7 +42,6 @@ export interface AzureDevOpsApi { getGitTags( projectName: string, repoName: string, - options?: PullRequestOptions, ): Promise<{ items: GitTag[] }>; getPullRequests( diff --git a/plugins/azure-devops/src/api/AzureDevOpsClient.ts b/plugins/azure-devops/src/api/AzureDevOpsClient.ts index a0fe8d8791..61c8479d71 100644 --- a/plugins/azure-devops/src/api/AzureDevOpsClient.ts +++ b/plugins/azure-devops/src/api/AzureDevOpsClient.ts @@ -62,18 +62,10 @@ export class AzureDevOpsClient implements AzureDevOpsApi { public async getGitTags( projectName: string, repoName: string, - options?: PullRequestOptions, ): Promise<{ items: GitTag[] }> { - const queryString = new URLSearchParams(); - if (options?.top) { - queryString.append('top', options.top.toString()); - } - if (options?.status) { - queryString.append('status', options.status.toString()); - } const urlSegment = `git-tags/${encodeURIComponent( projectName, - )}/${encodeURIComponent(repoName)}?${queryString}`; + )}/${encodeURIComponent(repoName)}`; const items = await this.get(urlSegment); return { items }; diff --git a/plugins/azure-devops/src/components/EntityPageAzureGitTags/EntityPageAzureGitTags.tsx b/plugins/azure-devops/src/components/EntityPageAzureGitTags/EntityPageAzureGitTags.tsx index 8f997e079e..139549966e 100644 --- a/plugins/azure-devops/src/components/EntityPageAzureGitTags/EntityPageAzureGitTags.tsx +++ b/plugins/azure-devops/src/components/EntityPageAzureGitTags/EntityPageAzureGitTags.tsx @@ -22,5 +22,5 @@ export const EntityPageAzureGitTags = ({ }: { defaultLimit?: number; }) => { - return ; + return ; }; diff --git a/plugins/azure-devops/src/components/GitTagTable/GitTagTable.tsx b/plugins/azure-devops/src/components/GitTagTable/GitTagTable.tsx index 3d37f1af31..4b8f63e187 100644 --- a/plugins/azure-devops/src/components/GitTagTable/GitTagTable.tsx +++ b/plugins/azure-devops/src/components/GitTagTable/GitTagTable.tsx @@ -14,22 +14,17 @@ * limitations under the License. */ -import { Box, Chip } from '@material-ui/core'; +import { Box } from '@material-ui/core'; import { Link, ResponseErrorPanel, Table, TableColumn, } from '@backstage/core-components'; -import { - PullRequest, - PullRequestStatus, -} from '@backstage/plugin-azure-devops-common'; -import React, { useState } from 'react'; +import { GitTag } from '@backstage/plugin-azure-devops-common'; +import React from 'react'; import { AzurePullRequestsIcon } from '../AzurePullRequestsIcon'; -import { DateTime } from 'luxon'; -import { PullRequestStatusButtonGroup } from '../PullRequestStatusButtonGroup'; import { useEntity } from '@backstage/plugin-catalog-react'; import { useGitTags } from '../../hooks/useGitTags'; @@ -39,6 +34,11 @@ const columns: TableColumn[] = [ field: 'name', highlight: false, width: 'auto', + render: (row: Partial) => ( + + {row.name} + + ), }, { title: 'Commit', @@ -52,20 +52,10 @@ const columns: TableColumn[] = [ }, ]; -type PullRequestTableProps = { - defaultLimit?: number; -}; - -export const GitTagTable = ({ defaultLimit }: PullRequestTableProps) => { - const [pullRequestStatusState, setPullRequestStatusState] = - useState(PullRequestStatus.Active); +export const GitTagTable = () => { const { entity } = useEntity(); - const { items, loading, error } = useGitTags( - entity, - defaultLimit, - pullRequestStatusState, - ); + const { items, loading, error } = useGitTags(entity); if (error) { return ( @@ -90,12 +80,6 @@ export const GitTagTable = ({ defaultLimit }: PullRequestTableProps) => { Azure Repos - Git Tags ({items ? items.length : 0}) - - - } data={items ?? []} diff --git a/plugins/azure-devops/src/hooks/useGitTags.ts b/plugins/azure-devops/src/hooks/useGitTags.ts index 2a513f1492..b940a7105d 100644 --- a/plugins/azure-devops/src/hooks/useGitTags.ts +++ b/plugins/azure-devops/src/hooks/useGitTags.ts @@ -14,42 +14,25 @@ * limitations under the License. */ -import { - GitTag, - PullRequestOptions, - PullRequestStatus, -} from '@backstage/plugin-azure-devops-common'; +import { GitTag } from '@backstage/plugin-azure-devops-common'; -import { AZURE_DEVOPS_DEFAULT_TOP } from '../constants'; import { Entity } from '@backstage/catalog-model'; import { azureDevOpsApiRef } from '../api'; import { useApi } from '@backstage/core-plugin-api'; import useAsync from 'react-use/lib/useAsync'; import { useProjectRepoFromEntity } from './useProjectRepoFromEntity'; -export function useGitTags( - // TODO: Keep iterating down this rabbit hole on the client once the service has caught up - entity: Entity, - defaultLimit?: number, - requestedStatus?: PullRequestStatus, -): { +export function useGitTags(entity: Entity): { items?: GitTag[]; loading: boolean; error?: Error; } { - const top = defaultLimit ?? AZURE_DEVOPS_DEFAULT_TOP; - const status = requestedStatus ?? PullRequestStatus.Active; - const options: PullRequestOptions = { - top, - status, - }; - const api = useApi(azureDevOpsApiRef); const { project, repo } = useProjectRepoFromEntity(entity); const { value, loading, error } = useAsync(() => { - return api.getGitTags(project, repo, options); - }, [api, project, repo, top, status]); + return api.getGitTags(project, repo); + }, [api, project, repo]); return { items: value?.items,