diff --git a/.changeset/two-singers-learn.md b/.changeset/two-singers-learn.md new file mode 100644 index 0000000000..f5c2a78ab0 --- /dev/null +++ b/.changeset/two-singers-learn.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-devtools': patch +--- + +Added alpha support for the New Frontend System (Declarative Integration) diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx index ec333ce38f..59e0194dc0 100644 --- a/packages/app-next/src/App.tsx +++ b/packages/app-next/src/App.tsx @@ -50,7 +50,7 @@ import { } from '@backstage/integration-react'; import { createSignInPageExtension } from '@backstage/frontend-plugin-api'; import { SignInPage } from '@backstage/core-components'; - +import devToolsPlugin from '@backstage/plugin-devtools/alpha'; import linguistPlugin from '@backstage/plugin-linguist/alpha'; /* @@ -127,6 +127,7 @@ const app = createApp({ userSettingsPlugin, homePlugin, appVisualizerPlugin, + devToolsPlugin, linguistPlugin, ...collectedLegacyPlugins, createExtensionOverrides({ diff --git a/plugins/devtools/api-report-alpha.md b/plugins/devtools/api-report-alpha.md new file mode 100644 index 0000000000..59aefd3698 --- /dev/null +++ b/plugins/devtools/api-report-alpha.md @@ -0,0 +1,19 @@ +## API Report File for "@backstage/plugin-devtools" + +> 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'; +import { RouteRef } from '@backstage/frontend-plugin-api'; + +// @alpha (undocumented) +const _default: BackstagePlugin< + { + root: RouteRef; + }, + {} +>; +export default _default; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/devtools/package.json b/plugins/devtools/package.json index 34ce5d7091..ef1f106dc2 100644 --- a/plugins/devtools/package.json +++ b/plugins/devtools/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" @@ -29,9 +42,11 @@ "postpack": "backstage-cli package postpack" }, "dependencies": { + "@backstage/core-compat-api": "workspace:^", "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/errors": "workspace:^", + "@backstage/frontend-plugin-api": "workspace:^", "@backstage/plugin-devtools-common": "workspace:^", "@backstage/plugin-permission-react": "workspace:^", "@material-ui/core": "^4.9.13", diff --git a/plugins/devtools/src/alpha.ts b/plugins/devtools/src/alpha.ts new file mode 100644 index 0000000000..e80f131817 --- /dev/null +++ b/plugins/devtools/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/devtools/src/alpha/index.ts b/plugins/devtools/src/alpha/index.ts new file mode 100644 index 0000000000..2f137f09ee --- /dev/null +++ b/plugins/devtools/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/devtools/src/alpha/plugin.tsx b/plugins/devtools/src/alpha/plugin.tsx new file mode 100644 index 0000000000..746b90a50f --- /dev/null +++ b/plugins/devtools/src/alpha/plugin.tsx @@ -0,0 +1,70 @@ +/* + * 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, + createNavItemExtension, + createPageExtension, + createPlugin, + discoveryApiRef, + identityApiRef, +} from '@backstage/frontend-plugin-api'; + +import { devToolsApiRef, DevToolsClient } from '../api'; +import { + compatWrapper, + convertLegacyRouteRef, +} from '@backstage/core-compat-api'; +import BuildIcon from '@material-ui/icons/Build'; +import { rootRouteRef } from '../routes'; + +/** @alpha */ +export const devToolsApi = createApiExtension({ + factory: createApiFactory({ + api: devToolsApiRef, + deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef }, + factory: ({ discoveryApi, identityApi }) => + new DevToolsClient({ discoveryApi, identityApi }), + }), +}); + +/** @alpha */ +export const devToolsPage = createPageExtension({ + defaultPath: '/devtools', + routeRef: convertLegacyRouteRef(rootRouteRef), + loader: () => + import('../components/DevToolsPage').then(m => + compatWrapper(), + ), +}); + +/** @alpha */ +export const devToolsNavItem = createNavItemExtension({ + title: 'DevTools', + routeRef: convertLegacyRouteRef(rootRouteRef), + icon: BuildIcon, +}); + +/** @alpha */ +export default createPlugin({ + id: 'devtools', + routes: { + root: convertLegacyRouteRef(rootRouteRef), + }, + extensions: [devToolsApi, devToolsPage, devToolsNavItem], +}); diff --git a/yarn.lock b/yarn.lock index 230f6d3e8d..d648f33383 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6298,10 +6298,12 @@ __metadata: resolution: "@backstage/plugin-devtools@workspace:plugins/devtools" dependencies: "@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-devtools-common": "workspace:^" "@backstage/plugin-permission-react": "workspace:^" "@material-ui/core": ^4.9.13