From 4f42918c4f026d3ed59a9bb85f300603f020c23d Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Wed, 27 Dec 2023 11:07:04 -0600 Subject: [PATCH] Added alpha support for the New Frontend System Signed-off-by: Andre Wanlin --- .changeset/tricky-pans-explain.md | 5 +++ packages/app-next/app-config.yaml | 2 +- packages/app-next/src/App.tsx | 3 ++ plugins/linguist/api-report-alpha.md | 13 +++++++ plugins/linguist/package.json | 21 +++++++++-- plugins/linguist/src/alpha.ts | 18 +++++++++ plugins/linguist/src/alpha/index.ts | 17 +++++++++ plugins/linguist/src/alpha/plugin.tsx | 53 +++++++++++++++++++++++++++ yarn.lock | 2 + 9 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 .changeset/tricky-pans-explain.md create mode 100644 plugins/linguist/api-report-alpha.md create mode 100644 plugins/linguist/src/alpha.ts create mode 100644 plugins/linguist/src/alpha/index.ts create mode 100644 plugins/linguist/src/alpha/plugin.tsx diff --git a/.changeset/tricky-pans-explain.md b/.changeset/tricky-pans-explain.md new file mode 100644 index 0000000000..64b2bda1fe --- /dev/null +++ b/.changeset/tricky-pans-explain.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-linguist': 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 3eaab2fa1a..77f4284455 100644 --- a/packages/app-next/app-config.yaml +++ b/packages/app-next/app-config.yaml @@ -15,7 +15,7 @@ app: - entity-card:catalog/links: config: filter: kind:component has:links - + - entity-card:linguist/languages # Entity page content - entity-content:techdocs diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx index 112532cee2..747576533a 100644 --- a/packages/app-next/src/App.tsx +++ b/packages/app-next/src/App.tsx @@ -51,6 +51,8 @@ import { import { createSignInPageExtension } from '@backstage/frontend-plugin-api'; import { SignInPage } from '@backstage/core-components'; +import linguistPlugin from '@backstage/plugin-linguist/alpha'; + /* # Notes @@ -125,6 +127,7 @@ const app = createApp({ userSettingsPlugin, homePlugin, appVisualizerPlugin, + linguistPlugin, ...collectedLegacyPlugins, createExtensionOverrides({ extensions: [ diff --git a/plugins/linguist/api-report-alpha.md b/plugins/linguist/api-report-alpha.md new file mode 100644 index 0000000000..418439d331 --- /dev/null +++ b/plugins/linguist/api-report-alpha.md @@ -0,0 +1,13 @@ +## API Report File for "@backstage/plugin-linguist" + +> 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/linguist/package.json b/plugins/linguist/package.json index 50ff0f8aaf..4b2eddf9dd 100644 --- a/plugins/linguist/package.json +++ b/plugins/linguist/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-catalog-react": "workspace:^", "@backstage/plugin-linguist-common": "workspace:^", "@material-ui/core": "^4.9.13", diff --git a/plugins/linguist/src/alpha.ts b/plugins/linguist/src/alpha.ts new file mode 100644 index 0000000000..e80f131817 --- /dev/null +++ b/plugins/linguist/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/linguist/src/alpha/index.ts b/plugins/linguist/src/alpha/index.ts new file mode 100644 index 0000000000..2f137f09ee --- /dev/null +++ b/plugins/linguist/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/linguist/src/alpha/plugin.tsx b/plugins/linguist/src/alpha/plugin.tsx new file mode 100644 index 0000000000..36d635740f --- /dev/null +++ b/plugins/linguist/src/alpha/plugin.tsx @@ -0,0 +1,53 @@ +/* + * 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, + createPlugin, + discoveryApiRef, + identityApiRef, +} from '@backstage/frontend-plugin-api'; + +import { LinguistClient, linguistApiRef } from '../api'; +import { compatWrapper } from '@backstage/core-compat-api'; +import { createEntityCardExtension } from '@backstage/plugin-catalog-react/alpha'; + +/** @alpha */ +export const entityLinguistCard = createEntityCardExtension({ + name: 'languages', + loader: async () => + import('../components/LinguistCard').then(m => + compatWrapper(), + ), +}); + +/** @alpha */ +export const linguistApi = createApiExtension({ + factory: createApiFactory({ + api: linguistApiRef, + deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef }, + factory: ({ discoveryApi, identityApi }) => + new LinguistClient({ discoveryApi, identityApi }), + }), +}); + +/** @alpha */ +export default createPlugin({ + id: 'linguist', + extensions: [linguistApi, entityLinguistCard], +}); diff --git a/yarn.lock b/yarn.lock index 0b1b81f289..e11c5c132a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7487,10 +7487,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-catalog-react": "workspace:^" "@backstage/plugin-linguist-common": "workspace:^" "@material-ui/core": ^4.9.13