From 6392fbe3c00d733ad1329f8ccf0bb5a6f9929a26 Mon Sep 17 00:00:00 2001 From: mo Date: Thu, 28 Apr 2022 07:53:08 -0500 Subject: [PATCH] hacking from pullrequests Signed-off-by: mo --- .../app/src/components/catalog/EntityPage.tsx | 13 ++ .../EntityPageAzureGitTags.tsx | 26 ++++ .../EntityPageAzureGitTags/index.ts | 17 +++ .../components/GitTagTable/GitTagTable.tsx | 139 ++++++++++++++++++ .../src/components/GitTagTable/index.ts | 17 +++ plugins/azure-devops/src/index.ts | 1 + plugins/azure-devops/src/plugin.ts | 12 ++ plugins/azure-devops/src/routes.ts | 4 + 8 files changed, 229 insertions(+) create mode 100644 plugins/azure-devops/src/components/EntityPageAzureGitTags/EntityPageAzureGitTags.tsx create mode 100644 plugins/azure-devops/src/components/EntityPageAzureGitTags/index.ts create mode 100644 plugins/azure-devops/src/components/GitTagTable/GitTagTable.tsx create mode 100644 plugins/azure-devops/src/components/GitTagTable/index.ts diff --git a/packages/app/src/components/catalog/EntityPage.tsx b/packages/app/src/components/catalog/EntityPage.tsx index 26068c6c8f..2b1ba6e492 100644 --- a/packages/app/src/components/catalog/EntityPage.tsx +++ b/packages/app/src/components/catalog/EntityPage.tsx @@ -36,6 +36,7 @@ import { } from '@backstage/plugin-api-docs'; import { EntityAzurePipelinesContent, + EntityAzureGitTagsContent, EntityAzurePullRequestsContent, isAzureDevOpsAvailable, isAzurePipelinesAvailable, @@ -281,6 +282,14 @@ const errorsContent = ( ); +const gitTagsContent = ( + + + + + +); + const pullRequestsContent = ( @@ -478,6 +487,10 @@ const websiteEntityPage = ( + + {gitTagsContent} + + {pullRequestsContent} diff --git a/plugins/azure-devops/src/components/EntityPageAzureGitTags/EntityPageAzureGitTags.tsx b/plugins/azure-devops/src/components/EntityPageAzureGitTags/EntityPageAzureGitTags.tsx new file mode 100644 index 0000000000..8f997e079e --- /dev/null +++ b/plugins/azure-devops/src/components/EntityPageAzureGitTags/EntityPageAzureGitTags.tsx @@ -0,0 +1,26 @@ +/* + * Copyright 2021 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { GitTagTable } from '../GitTagTable/GitTagTable'; +import React from 'react'; + +export const EntityPageAzureGitTags = ({ + defaultLimit, +}: { + defaultLimit?: number; +}) => { + return ; +}; diff --git a/plugins/azure-devops/src/components/EntityPageAzureGitTags/index.ts b/plugins/azure-devops/src/components/EntityPageAzureGitTags/index.ts new file mode 100644 index 0000000000..b88fb6c467 --- /dev/null +++ b/plugins/azure-devops/src/components/EntityPageAzureGitTags/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2021 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { EntityPageAzureGitTags } from './EntityPageAzureGitTags'; diff --git a/plugins/azure-devops/src/components/GitTagTable/GitTagTable.tsx b/plugins/azure-devops/src/components/GitTagTable/GitTagTable.tsx new file mode 100644 index 0000000000..b281cd0759 --- /dev/null +++ b/plugins/azure-devops/src/components/GitTagTable/GitTagTable.tsx @@ -0,0 +1,139 @@ +/* + * Copyright 2021 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Box, Chip } 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 { AzurePullRequestsIcon } from '../AzurePullRequestsIcon'; +import { DateTime } from 'luxon'; +import { PullRequestStatusButtonGroup } from '../PullRequestStatusButtonGroup'; +import { useEntity } from '@backstage/plugin-catalog-react'; +import { usePullRequests } from '../../hooks/usePullRequests'; + +const columns: TableColumn[] = [ + { + title: 'ID', + field: 'pullRequestId', + highlight: false, + width: 'auto', + }, + { + title: 'Title', + field: 'title', + width: 'auto', + render: (row: Partial) => ( + + {row.title} + {row.isDraft && ( + + + + )} + + ), + }, + { + title: 'Source', + field: 'sourceRefName', + width: 'auto', + }, + { + title: 'Target', + field: 'targetRefName', + width: 'auto', + }, + { + title: 'Created By', + field: 'createdBy', + width: 'auto', + }, + { + title: 'Created', + field: 'creationDate', + width: 'auto', + render: (row: Partial) => + (row.creationDate + ? DateTime.fromISO(row.creationDate) + : DateTime.now() + ).toRelative(), + }, +]; + +type PullRequestTableProps = { + defaultLimit?: number; +}; + +export const GitTagTable = ({ defaultLimit }: PullRequestTableProps) => { + const [pullRequestStatusState, setPullRequestStatusState] = + useState(PullRequestStatus.Active); + const { entity } = useEntity(); + + const { items, loading, error } = usePullRequests( + entity, + defaultLimit, + pullRequestStatusState, + ); + + if (error) { + return ( +
+ +
+ ); + } + + return ( + + + + Azure Repos - Pull Requests ({items ? items.length : 0}) + + + + + } + data={items ?? []} + /> + ); +}; diff --git a/plugins/azure-devops/src/components/GitTagTable/index.ts b/plugins/azure-devops/src/components/GitTagTable/index.ts new file mode 100644 index 0000000000..32933241e6 --- /dev/null +++ b/plugins/azure-devops/src/components/GitTagTable/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2021 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { GitTagTable } from './GitTagTable'; diff --git a/plugins/azure-devops/src/index.ts b/plugins/azure-devops/src/index.ts index aa052975de..48177ee830 100644 --- a/plugins/azure-devops/src/index.ts +++ b/plugins/azure-devops/src/index.ts @@ -17,6 +17,7 @@ export { azureDevOpsPlugin, EntityAzurePipelinesContent, + EntityAzureGitTagsContent, EntityAzurePullRequestsContent, isAzureDevOpsAvailable, isAzurePipelinesAvailable, diff --git a/plugins/azure-devops/src/plugin.ts b/plugins/azure-devops/src/plugin.ts index c2ecb7457a..ccd183eee9 100644 --- a/plugins/azure-devops/src/plugin.ts +++ b/plugins/azure-devops/src/plugin.ts @@ -22,6 +22,7 @@ import { import { azurePipelinesEntityContentRouteRef, azurePullRequestDashboardRouteRef, + azureGitTagsEntityContentRouteRef, azurePullRequestsEntityContentRouteRef, } from './routes'; import { @@ -78,6 +79,17 @@ export const EntityAzurePipelinesContent = azureDevOpsPlugin.provide( }), ); +export const EntityAzureGitTagsContent = azureDevOpsPlugin.provide( + createRoutableExtension({ + name: 'EntityAzureGitTagsContent', + component: () => + import('./components/EntityPageAzureGitTags').then( + m => m.EntityPageAzureGitTags, + ), + mountPoint: azureGitTagsEntityContentRouteRef, + }), +); + export const EntityAzurePullRequestsContent = azureDevOpsPlugin.provide( createRoutableExtension({ name: 'EntityAzurePullRequestsContent', diff --git a/plugins/azure-devops/src/routes.ts b/plugins/azure-devops/src/routes.ts index 0d20c12beb..4ed35bbe12 100644 --- a/plugins/azure-devops/src/routes.ts +++ b/plugins/azure-devops/src/routes.ts @@ -24,6 +24,10 @@ export const azurePipelinesEntityContentRouteRef = createRouteRef({ id: 'azure-pipelines-entity-content', }); +export const azureGitTagsEntityContentRouteRef = createRouteRef({ + id: 'azure-git-tags-entity-content', +}); + export const azurePullRequestsEntityContentRouteRef = createRouteRef({ id: 'azure-pull-requests-entity-content', });