From 8f23856aa9d7fdd5636f7b2ca564baae1cd3846c Mon Sep 17 00:00:00 2001 From: Jenah Blitz Date: Thu, 26 Jan 2023 14:12:53 -0500 Subject: [PATCH 1/5] Export isAirbrakeAvailable function for use in EntityPage Signed-off-by: Jenah Blitz --- .../src/components/isAirbrakeAvailable.ts | 21 +++++++++++++++++++ plugins/airbrake/src/index.ts | 1 + 2 files changed, 22 insertions(+) create mode 100644 plugins/airbrake/src/components/isAirbrakeAvailable.ts diff --git a/plugins/airbrake/src/components/isAirbrakeAvailable.ts b/plugins/airbrake/src/components/isAirbrakeAvailable.ts new file mode 100644 index 0000000000..93c04061c2 --- /dev/null +++ b/plugins/airbrake/src/components/isAirbrakeAvailable.ts @@ -0,0 +1,21 @@ +/* + * Copyright 2020 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 { Entity } from '@backstage/catalog-model'; +import { AIRBRAKE_PROJECT_ID_ANNOTATION } from './useProjectId'; + +export const isAirbrakeAvailable = (entity: Entity) => + Boolean(entity.metadata.annotations?.[AIRBRAKE_PROJECT_ID_ANNOTATION]); diff --git a/plugins/airbrake/src/index.ts b/plugins/airbrake/src/index.ts index 2b2406776b..717d544dc9 100644 --- a/plugins/airbrake/src/index.ts +++ b/plugins/airbrake/src/index.ts @@ -22,3 +22,4 @@ export { airbrakePlugin } from './plugin'; export { EntityAirbrakeContent } from './extensions'; +export { isAirbrakeAvailable } from './components/isAirbrakeAvailable'; From 5d9ee0ef307f5612a2e546d9d5e766a4053581bd Mon Sep 17 00:00:00 2001 From: Jenah Blitz Date: Thu, 26 Jan 2023 14:39:00 -0500 Subject: [PATCH 2/5] Update plugin readme Signed-off-by: Jenah Blitz --- plugins/airbrake/README.md | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/plugins/airbrake/README.md b/plugins/airbrake/README.md index bc30ca7896..f37ab08b75 100644 --- a/plugins/airbrake/README.md +++ b/plugins/airbrake/README.md @@ -18,14 +18,21 @@ The Airbrake plugin provides connectivity between Backstage and Airbrake (https: yarn add --cwd packages/backend @backstage/plugin-airbrake-backend ``` -3. Add the `EntityAirbrakeContent` to `packages/app/src/components/catalog/EntityPage.tsx` for all the entity pages you want Airbrake to be in: +3. Add the `EntityAirbrakeContent` and `isAirbrakeAvailable` to `packages/app/src/components/catalog/EntityPage.tsx` for all the entity pages you want Airbrake to be in: ```typescript jsx - import { EntityAirbrakeContent } from '@backstage/plugin-airbrake'; + import { + EntityAirbrakeContent, + isAirbrakeAvailable, + } from '@backstage/plugin-airbrake'; const serviceEntityPage = ( - + @@ -33,7 +40,11 @@ The Airbrake plugin provides connectivity between Backstage and Airbrake (https: const websiteEntityPage = ( - + @@ -41,7 +52,11 @@ The Airbrake plugin provides connectivity between Backstage and Airbrake (https: const defaultEntityPage = ( - + From 41377156d00129eb4256d8440c7562bcc5118166 Mon Sep 17 00:00:00 2001 From: Jenah Blitz Date: Thu, 26 Jan 2023 15:24:00 -0500 Subject: [PATCH 3/5] Add changeset Signed-off-by: Jenah Blitz --- .changeset/tall-years-relate.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tall-years-relate.md diff --git a/.changeset/tall-years-relate.md b/.changeset/tall-years-relate.md new file mode 100644 index 0000000000..10198992ea --- /dev/null +++ b/.changeset/tall-years-relate.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-airbrake': patch +--- + +Adds a boolean helper function to airbrake plugin for use on the EntityPage to show/hide airbrake tab depending on whether the entity's catalog-info.yml has an airbrake id set in the metadata From c5965be60c9e33b7f531f95c74bf711d6dd22409 Mon Sep 17 00:00:00 2001 From: Jenah Blitz Date: Thu, 26 Jan 2023 15:59:20 -0500 Subject: [PATCH 4/5] Add @public with description of it's functionality Signed-off-by: Jenah Blitz --- plugins/airbrake/src/components/isAirbrakeAvailable.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/airbrake/src/components/isAirbrakeAvailable.ts b/plugins/airbrake/src/components/isAirbrakeAvailable.ts index 93c04061c2..01d59668ce 100644 --- a/plugins/airbrake/src/components/isAirbrakeAvailable.ts +++ b/plugins/airbrake/src/components/isAirbrakeAvailable.ts @@ -17,5 +17,9 @@ import { Entity } from '@backstage/catalog-model'; import { AIRBRAKE_PROJECT_ID_ANNOTATION } from './useProjectId'; +/** + * Utility function to determine if the given entity has an Airbrake ID set in the repos catalog-info.yml . + * @public + */ export const isAirbrakeAvailable = (entity: Entity) => Boolean(entity.metadata.annotations?.[AIRBRAKE_PROJECT_ID_ANNOTATION]); From 10ce9d162c5f6c8d2cdedcfc0631e460bcb974ec Mon Sep 17 00:00:00 2001 From: Jenah Blitz Date: Thu, 26 Jan 2023 15:59:30 -0500 Subject: [PATCH 5/5] generate api-report Signed-off-by: Jenah Blitz --- plugins/airbrake/api-report.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/airbrake/api-report.md b/plugins/airbrake/api-report.md index e48fbf9cde..773e2a029a 100644 --- a/plugins/airbrake/api-report.md +++ b/plugins/airbrake/api-report.md @@ -6,6 +6,7 @@ /// import { BackstagePlugin } from '@backstage/core-plugin-api'; +import { Entity } from '@backstage/catalog-model'; import { RouteRef } from '@backstage/core-plugin-api'; // @public @@ -19,4 +20,7 @@ export const airbrakePlugin: BackstagePlugin< // @public export const EntityAirbrakeContent: () => JSX.Element; + +// @public +export const isAirbrakeAvailable: (entity: Entity) => boolean; ```