From 29afabd440c3d498ac7ba49f635d94f9976d712c Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 23 Dec 2020 18:32:59 +0100 Subject: [PATCH] sentry: port to new composability API Co-authored-by: blam --- plugins/sentry/package.json | 1 + plugins/sentry/src/extensions.tsx | 56 +++++++++++++++++++++++++++++++ plugins/sentry/src/index.ts | 1 + plugins/sentry/src/plugin.ts | 3 ++ 4 files changed, 61 insertions(+) create mode 100644 plugins/sentry/src/extensions.tsx diff --git a/plugins/sentry/package.json b/plugins/sentry/package.json index 630e735bb7..4284c90688 100644 --- a/plugins/sentry/package.json +++ b/plugins/sentry/package.json @@ -33,6 +33,7 @@ "dependencies": { "@backstage/catalog-model": "^0.6.0", "@backstage/core": "^0.4.2", + "@backstage/plugin-catalog": "^0.2.8", "@backstage/theme": "^0.2.2", "@material-ui/core": "^4.11.0", "@material-ui/icons": "^4.9.1", diff --git a/plugins/sentry/src/extensions.tsx b/plugins/sentry/src/extensions.tsx new file mode 100644 index 0000000000..a66080f2b6 --- /dev/null +++ b/plugins/sentry/src/extensions.tsx @@ -0,0 +1,56 @@ +/* + * Copyright 2020 Spotify AB + * + * 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 { + createComponentExtension, + createRoutableExtension, +} from '@backstage/core'; +import { useEntity } from '@backstage/plugin-catalog'; +import { plugin, rootRouteRef } from './plugin'; + +export const EntitySentryContent = plugin.provide( + createRoutableExtension({ + mountPoint: rootRouteRef, + component: () => + import('./components/SentryIssuesWidget').then( + ({ SentryIssuesWidget }) => { + const SentryPage = () => { + const { entity } = useEntity(); + return ; + }; + return SentryPage; + }, + ), + }), +); + +export const EntitySentryCard = plugin.provide( + createComponentExtension({ + component: { + lazy: () => + import('./components/SentryIssuesWidget').then( + ({ SentryIssuesWidget }) => { + const SentryCard = () => { + const { entity } = useEntity(); + return ; + }; + return SentryCard; + }, + ), + }, + }), +); diff --git a/plugins/sentry/src/index.ts b/plugins/sentry/src/index.ts index 2b9e2186ec..de53d7456a 100644 --- a/plugins/sentry/src/index.ts +++ b/plugins/sentry/src/index.ts @@ -17,4 +17,5 @@ export * from './api'; export * from './components'; export { plugin } from './plugin'; +export { EntitySentryCard, EntitySentryContent } from './extensions'; export { Router } from './components/Router'; diff --git a/plugins/sentry/src/plugin.ts b/plugins/sentry/src/plugin.ts index 6a4fe4e5a4..49ecfdb5f2 100644 --- a/plugins/sentry/src/plugin.ts +++ b/plugins/sentry/src/plugin.ts @@ -41,4 +41,7 @@ export const plugin = createPlugin({ ), }), ], + routes: { + root: rootRouteRef, + }, });