From e09d3e83997c2446412738338131318d6e897078 Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Thu, 13 Feb 2025 11:53:18 -0600 Subject: [PATCH 1/2] catalog-unprocessed-entities - Added alpha support for the New Frontend System Signed-off-by: Andre Wanlin --- .changeset/tough-crabs-hope.md | 5 + .../catalog-unprocessed-entities/README.md | 20 ++++ .../catalog-unprocessed-entities/package.json | 7 ++ .../report-alpha.api.md | 93 +++++++++++++++++++ .../catalog-unprocessed-entities/src/alpha.ts | 18 ++++ .../src/alpha/index.ts | 17 ++++ .../src/alpha/plugin.tsx | 86 +++++++++++++++++ yarn.lock | 2 + 8 files changed, 248 insertions(+) create mode 100644 .changeset/tough-crabs-hope.md create mode 100644 plugins/catalog-unprocessed-entities/report-alpha.api.md create mode 100644 plugins/catalog-unprocessed-entities/src/alpha.ts create mode 100644 plugins/catalog-unprocessed-entities/src/alpha/index.ts create mode 100644 plugins/catalog-unprocessed-entities/src/alpha/plugin.tsx diff --git a/.changeset/tough-crabs-hope.md b/.changeset/tough-crabs-hope.md new file mode 100644 index 0000000000..50b36b45f4 --- /dev/null +++ b/.changeset/tough-crabs-hope.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-unprocessed-entities': patch +--- + +Added alpha support for the New Frontend System diff --git a/plugins/catalog-unprocessed-entities/README.md b/plugins/catalog-unprocessed-entities/README.md index c2e5109d5c..ebadbb7054 100644 --- a/plugins/catalog-unprocessed-entities/README.md +++ b/plugins/catalog-unprocessed-entities/README.md @@ -44,6 +44,26 @@ import { CatalogUnprocessedEntitiesPage } from '@backstage/plugin-catalog-unproc />; ``` +### Integrating with the New Frontend System + +Follow this section if you are using Backstage's [new frontend system](https://backstage.io/docs/frontend-system/). + +Import `catalogUnprocessedEntitiesPlugin` in your `App.tsx` and add it to your app's `features` array: + +```typescript +import catalogUnprocessedEntitiesPlugin from '@backstage/plugin-catalog-unprocessed-entities'; + +// ... + +export const app = createApp({ + features: [ + // ... + catalogUnprocessedEntitiesPlugin, + // ... + ], +}); +``` + ## Customization If you want to use the provided endpoints in a different way, you can use the ApiRef doing the following: diff --git a/plugins/catalog-unprocessed-entities/package.json b/plugins/catalog-unprocessed-entities/package.json index 7bdf6da524..ed02f611ac 100644 --- a/plugins/catalog-unprocessed-entities/package.json +++ b/plugins/catalog-unprocessed-entities/package.json @@ -22,6 +22,11 @@ }, "license": "Apache-2.0", "sideEffects": false, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" + }, "main": "src/index.ts", "types": "src/index.ts", "files": [ @@ -38,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:^", "@material-ui/core": "^4.9.13", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "^4.0.0-alpha.60", diff --git a/plugins/catalog-unprocessed-entities/report-alpha.api.md b/plugins/catalog-unprocessed-entities/report-alpha.api.md new file mode 100644 index 0000000000..6758179ffb --- /dev/null +++ b/plugins/catalog-unprocessed-entities/report-alpha.api.md @@ -0,0 +1,93 @@ +## API Report File for "@backstage/plugin-catalog-unprocessed-entities" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { AnyApiFactory } from '@backstage/frontend-plugin-api'; +import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { FrontendPlugin } from '@backstage/frontend-plugin-api'; +import { IconComponent } from '@backstage/core-plugin-api'; +import { default as React_2 } from 'react'; +import { RouteRef } from '@backstage/frontend-plugin-api'; + +// @alpha (undocumented) +const _default: FrontendPlugin< + { + root: RouteRef; + }, + {}, + { + 'page:catalog-unprocessed-entities': ExtensionDefinition<{ + kind: 'page'; + name: undefined; + config: { + path: string | undefined; + }; + configInput: { + path?: string | undefined; + }; + output: + | ConfigurableExtensionDataRef< + React_2.JSX.Element, + 'core.reactElement', + {} + > + | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef< + RouteRef, + 'core.routing.ref', + { + optional: true; + } + >; + inputs: {}; + params: { + defaultPath: string; + loader: () => Promise; + routeRef?: RouteRef | undefined; + }; + }>; + 'nav-item:catalog-unprocessed-entities': ExtensionDefinition<{ + kind: 'nav-item'; + name: undefined; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }, + 'core.nav-item.target', + {} + >; + inputs: {}; + params: { + title: string; + icon: IconComponent; + routeRef: RouteRef; + }; + }>; + 'api:catalog-unprocessed-entities': ExtensionDefinition<{ + kind: 'api'; + name: undefined; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + params: { + factory: AnyApiFactory; + }; + }>; + } +>; +export default _default; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-unprocessed-entities/src/alpha.ts b/plugins/catalog-unprocessed-entities/src/alpha.ts new file mode 100644 index 0000000000..e80f131817 --- /dev/null +++ b/plugins/catalog-unprocessed-entities/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/catalog-unprocessed-entities/src/alpha/index.ts b/plugins/catalog-unprocessed-entities/src/alpha/index.ts new file mode 100644 index 0000000000..2f137f09ee --- /dev/null +++ b/plugins/catalog-unprocessed-entities/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/catalog-unprocessed-entities/src/alpha/plugin.tsx b/plugins/catalog-unprocessed-entities/src/alpha/plugin.tsx new file mode 100644 index 0000000000..85c021510c --- /dev/null +++ b/plugins/catalog-unprocessed-entities/src/alpha/plugin.tsx @@ -0,0 +1,86 @@ +/* + * 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 { + createApiFactory, + createFrontendPlugin, + discoveryApiRef, + fetchApiRef, + ApiBlueprint, + PageBlueprint, + NavItemBlueprint, +} from '@backstage/frontend-plugin-api'; + +import { + catalogUnprocessedEntitiesApiRef, + CatalogUnprocessedEntitiesClient, +} from '../api'; +import { + compatWrapper, + convertLegacyRouteRef, +} from '@backstage/core-compat-api'; +import QueueIcon from '@material-ui/icons/Queue'; +import { rootRouteRef } from '../routes'; + +/** @alpha */ +export const catalogUnprocessedEntitiesApi = ApiBlueprint.make({ + params: { + factory: createApiFactory({ + api: catalogUnprocessedEntitiesApiRef, + deps: { + discoveryApi: discoveryApiRef, + fetchApi: fetchApiRef, + }, + factory: ({ discoveryApi, fetchApi }) => + new CatalogUnprocessedEntitiesClient(discoveryApi, fetchApi), + }), + }, +}); + +/** @alpha */ +export const catalogUnprocessedEntitiesPage = PageBlueprint.make({ + params: { + defaultPath: '/catalog-unprocessed-entities', + routeRef: convertLegacyRouteRef(rootRouteRef), + loader: () => + import('../components/UnprocessedEntities').then(m => + compatWrapper(), + ), + }, +}); + +/** @alpha */ +export const catalogUnprocessedEntitiesNavItem = NavItemBlueprint.make({ + params: { + title: 'Unprocessed Entities', + routeRef: convertLegacyRouteRef(rootRouteRef), + icon: QueueIcon, + }, +}); + +/** @alpha */ +export default createFrontendPlugin({ + id: 'catalog-unprocessed-entities', + routes: { + root: convertLegacyRouteRef(rootRouteRef), + }, + extensions: [ + catalogUnprocessedEntitiesApi, + catalogUnprocessedEntitiesPage, + catalogUnprocessedEntitiesNavItem, + ], +}); diff --git a/yarn.lock b/yarn.lock index 1f3039fcd4..ad2aa54234 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6405,10 +6405,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:^" "@material-ui/core": ^4.9.13 "@material-ui/icons": ^4.9.1 "@material-ui/lab": ^4.0.0-alpha.60 From d02041adc4b2bae5686298bc71252a3e0eb77bb3 Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Thu, 13 Feb 2025 12:18:08 -0600 Subject: [PATCH 2/2] Package fix Signed-off-by: Andre Wanlin --- plugins/catalog-unprocessed-entities/package.json | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/catalog-unprocessed-entities/package.json b/plugins/catalog-unprocessed-entities/package.json index ed02f611ac..5c22053871 100644 --- a/plugins/catalog-unprocessed-entities/package.json +++ b/plugins/catalog-unprocessed-entities/package.json @@ -10,9 +10,7 @@ ] }, "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts" + "access": "public" }, "homepage": "https://backstage.io", "repository": { @@ -29,6 +27,16 @@ }, "main": "src/index.ts", "types": "src/index.ts", + "typesVersions": { + "*": { + "alpha": [ + "src/alpha.ts" + ], + "package.json": [ + "package.json" + ] + } + }, "files": [ "dist" ],