From 38726cd9a79a8d922b6e44ed666eff4985490838 Mon Sep 17 00:00:00 2001 From: Jeff Cook Date: Wed, 7 Apr 2021 23:22:30 +0000 Subject: [PATCH] Teach SonarQube `isPluginApplicableToEntity`. Signed-off-by: Jeff Cook --- plugins/sonarqube/src/components/index.ts | 1 + plugins/sonarqube/src/components/useProjectKey.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/plugins/sonarqube/src/components/index.ts b/plugins/sonarqube/src/components/index.ts index 8f0786bb8e..8ff9a77485 100644 --- a/plugins/sonarqube/src/components/index.ts +++ b/plugins/sonarqube/src/components/index.ts @@ -15,3 +15,4 @@ */ export * from './SonarQubeCard'; +export { isSonarQubeAvailable as isPluginApplicableToEntity } from './useProjectKey'; diff --git a/plugins/sonarqube/src/components/useProjectKey.ts b/plugins/sonarqube/src/components/useProjectKey.ts index dcff79d972..c0f488b00c 100644 --- a/plugins/sonarqube/src/components/useProjectKey.ts +++ b/plugins/sonarqube/src/components/useProjectKey.ts @@ -18,6 +18,9 @@ import { Entity } from '@backstage/catalog-model'; export const SONARQUBE_PROJECT_KEY_ANNOTATION = 'sonarqube.org/project-key'; +export const isSonarQubeAvailable = (entity: Entity) => + Boolean(entity.metadata.annotations?.[SONARQUBE_PROJECT_KEY_ANNOTATION]); + export const useProjectKey = (entity: Entity) => { return entity?.metadata.annotations?.[SONARQUBE_PROJECT_KEY_ANNOTATION] ?? ''; };