newrelic: migrate to new composability API

This commit is contained in:
Patrik Oldsberg
2021-02-02 23:57:50 +01:00
parent 64b9efac2e
commit c5ab91ce3c
5 changed files with 27 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-newrelic': patch
---
Migrate to new composability API, exporting the plugin instance as `newRelicPlugin`, and the root page as `NewRelicPage`.
+2 -2
View File
@@ -15,6 +15,6 @@
*/
import { createDevApp } from '@backstage/dev-utils';
import { plugin } from '../src/plugin';
import { newRelicPlugin } from '../src/plugin';
createDevApp().registerPlugin(plugin).render();
createDevApp().registerPlugin(newRelicPlugin).render();
+5 -1
View File
@@ -14,4 +14,8 @@
* limitations under the License.
*/
export { plugin } from './plugin';
export {
newRelicPlugin,
newRelicPlugin as plugin,
NewRelicPage,
} from './plugin';
+2 -2
View File
@@ -14,10 +14,10 @@
* limitations under the License.
*/
import { plugin } from './plugin';
import { newRelicPlugin } from './plugin';
describe('newrelic', () => {
it('should export plugin', () => {
expect(plugin).toBeDefined();
expect(newRelicPlugin).toBeDefined();
});
});
+13 -1
View File
@@ -19,6 +19,7 @@ import {
createPlugin,
createRouteRef,
discoveryApiRef,
createRoutableExtension,
} from '@backstage/core';
import { NewRelicClient, newRelicApiRef } from './api';
import NewRelicComponent from './components/NewRelicComponent';
@@ -28,7 +29,7 @@ export const rootRouteRef = createRouteRef({
title: 'newrelic',
});
export const plugin = createPlugin({
export const newRelicPlugin = createPlugin({
id: 'newrelic',
apis: [
createApiFactory({
@@ -40,4 +41,15 @@ export const plugin = createPlugin({
register({ router }) {
router.addRoute(rootRouteRef, NewRelicComponent);
},
routes: {
root: rootRouteRef,
},
});
export const NewRelicPage = newRelicPlugin.provide(
createRoutableExtension({
component: () =>
import('./components/NewRelicComponent').then(m => m.default),
mountPoint: rootRouteRef,
}),
);