From e2083dfb55e6b5b211ae16b40fa9d10332c6d181 Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Wed, 27 Dec 2023 12:11:26 -0600 Subject: [PATCH] Added alpha support for the New Frontend System Signed-off-by: Andre Wanlin --- .changeset/beige-apples-press.md | 5 ++ packages/app-next/app-config.yaml | 7 +- plugins/azure-devops/api-report-alpha.md | 13 +++ plugins/azure-devops/package.json | 21 ++++- plugins/azure-devops/src/alpha.ts | 18 ++++ plugins/azure-devops/src/alpha/index.ts | 17 ++++ plugins/azure-devops/src/alpha/plugin.tsx | 104 ++++++++++++++++++++++ yarn.lock | 2 + 8 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 .changeset/beige-apples-press.md create mode 100644 plugins/azure-devops/api-report-alpha.md create mode 100644 plugins/azure-devops/src/alpha.ts create mode 100644 plugins/azure-devops/src/alpha/index.ts create mode 100644 plugins/azure-devops/src/alpha/plugin.tsx diff --git a/.changeset/beige-apples-press.md b/.changeset/beige-apples-press.md new file mode 100644 index 0000000000..56c46db830 --- /dev/null +++ b/.changeset/beige-apples-press.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-azure-devops': patch +--- + +Added alpha support for the New Frontend System (Declarative Integration) diff --git a/packages/app-next/app-config.yaml b/packages/app-next/app-config.yaml index 9cc3507fa4..2ffc8967e3 100644 --- a/packages/app-next/app-config.yaml +++ b/packages/app-next/app-config.yaml @@ -17,8 +17,13 @@ app: config: filter: kind:component has:links - entity-card:linguist/languages + - entity-card:azure-devops/readme # Entity page content - entity-content:techdocs + - entity-content:azure-devops/pipelines + - entity-content:azure-devops/pull-requests + - entity-content:azure-devops/git-tags + # scmAuthExtension: >- # createScmAuthExtension({ @@ -32,7 +37,7 @@ app: # }) # externalRouteRefs: - # bind(catalogPlugin.externalRoutes, { + # bind(catalogPlugin.externalRoutes, # createComponent: scaffolderPlugin.routes.root, # viewTechDoc: techdocsPlugin.routes.docRoot, # createFromTemplate: scaffolderPlugin.routes.selectedTemplate, diff --git a/plugins/azure-devops/api-report-alpha.md b/plugins/azure-devops/api-report-alpha.md new file mode 100644 index 0000000000..8040c0235f --- /dev/null +++ b/plugins/azure-devops/api-report-alpha.md @@ -0,0 +1,13 @@ +## API Report File for "@backstage/plugin-azure-devops" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackstagePlugin } from '@backstage/frontend-plugin-api'; + +// @alpha (undocumented) +const _default: BackstagePlugin<{}, {}>; +export default _default; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/azure-devops/package.json b/plugins/azure-devops/package.json index d0b5932b31..e367cfb89f 100644 --- a/plugins/azure-devops/package.json +++ b/plugins/azure-devops/package.json @@ -5,9 +5,22 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "alpha": [ + "src/alpha.ts" + ], + "package.json": [ + "package.json" + ] + } }, "backstage": { "role": "frontend-plugin" @@ -30,9 +43,11 @@ }, "dependencies": { "@backstage/catalog-model": "workspace:^", + "@backstage/core-compat-api": "workspace:^", "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/errors": "workspace:^", + "@backstage/frontend-plugin-api": "workspace:^", "@backstage/plugin-azure-devops-common": "workspace:^", "@backstage/plugin-catalog-react": "workspace:^", "@material-ui/core": "^4.12.2", diff --git a/plugins/azure-devops/src/alpha.ts b/plugins/azure-devops/src/alpha.ts new file mode 100644 index 0000000000..e80f131817 --- /dev/null +++ b/plugins/azure-devops/src/alpha.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2023 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 * from './alpha/index'; +export { default } from './alpha/index'; diff --git a/plugins/azure-devops/src/alpha/index.ts b/plugins/azure-devops/src/alpha/index.ts new file mode 100644 index 0000000000..2f137f09ee --- /dev/null +++ b/plugins/azure-devops/src/alpha/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { default } from './plugin'; diff --git a/plugins/azure-devops/src/alpha/plugin.tsx b/plugins/azure-devops/src/alpha/plugin.tsx new file mode 100644 index 0000000000..f30b5cf219 --- /dev/null +++ b/plugins/azure-devops/src/alpha/plugin.tsx @@ -0,0 +1,104 @@ +/* + * Copyright 2023 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 React from 'react'; +import { + createApiExtension, + createApiFactory, + createPageExtension, + createPlugin, + discoveryApiRef, + identityApiRef, +} from '@backstage/frontend-plugin-api'; +import { azureDevOpsApiRef, AzureDevOpsClient } from '../api'; +import { + compatWrapper, + convertLegacyRouteRef, +} from '@backstage/core-compat-api'; +import { + createEntityCardExtension, + createEntityContentExtension, +} from '@backstage/plugin-catalog-react/alpha'; +import { azurePullRequestDashboardRouteRef } from '../routes'; + +export const azureDevOpsApi = createApiExtension({ + factory: createApiFactory({ + api: azureDevOpsApiRef, + deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef }, + factory: ({ discoveryApi, identityApi }) => + new AzureDevOpsClient({ discoveryApi, identityApi }), + }), +}); + +const azureDevOpsPullRequestPage = createPageExtension({ + defaultPath: '/azure-pull-requests', + routeRef: convertLegacyRouteRef(azurePullRequestDashboardRouteRef), + loader: () => + import('../components/PullRequestsPage').then(m => + compatWrapper(), + ), +}); + +const entityAzurePipelinesContent = createEntityContentExtension({ + name: 'pipelines', + defaultPath: '/pipelines', + defaultTitle: 'Pipelines', + loader: () => + import('../components/EntityPageAzurePipelines').then(m => + compatWrapper(), + ), +}); + +const entityAzureGitTagsContent = createEntityContentExtension({ + name: 'git-tags', + defaultPath: '/git-tags', + defaultTitle: 'Git Tags', + loader: () => + import('../components/EntityPageAzureGitTags').then(m => + compatWrapper(), + ), +}); + +const entityAzurePullRequestsContent = createEntityContentExtension({ + name: 'pull-requests', + defaultPath: '/pull-requests', + defaultTitle: 'Pull Requests', + loader: () => + import('../components/EntityPageAzurePullRequests').then(m => + compatWrapper(), + ), +}); + +export const entityAzureReadmeCard = createEntityCardExtension({ + name: 'readme', + loader: async () => + import('../components/ReadmeCard').then(m => + compatWrapper(), + ), +}); + +/** @alpha */ +export default createPlugin({ + id: 'azure-devops', + extensions: [ + azureDevOpsApi, + entityAzureReadmeCard, + entityAzurePipelinesContent, + entityAzureGitTagsContent, + entityAzurePullRequestsContent, + azureDevOpsPullRequestPage, + ], +}); diff --git a/yarn.lock b/yarn.lock index 42811acc21..9649405700 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4909,10 +4909,12 @@ __metadata: dependencies: "@backstage/catalog-model": "workspace:^" "@backstage/cli": "workspace:^" + "@backstage/core-compat-api": "workspace:^" "@backstage/core-components": "workspace:^" "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^" "@backstage/errors": "workspace:^" + "@backstage/frontend-plugin-api": "workspace:^" "@backstage/plugin-azure-devops-common": "workspace:^" "@backstage/plugin-catalog-react": "workspace:^" "@backstage/test-utils": "workspace:^"