diff --git a/.changeset/chatty-ghosts-lay.md b/.changeset/chatty-ghosts-lay.md new file mode 100644 index 0000000000..7d8ef3edbd --- /dev/null +++ b/.changeset/chatty-ghosts-lay.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-sonarqube': patch +--- + +Export isSonarQubeAvailable. diff --git a/plugins/sonarqube/src/components/index.ts b/plugins/sonarqube/src/components/index.ts index 8f0786bb8e..56b9d05885 100644 --- a/plugins/sonarqube/src/components/index.ts +++ b/plugins/sonarqube/src/components/index.ts @@ -15,3 +15,4 @@ */ export * from './SonarQubeCard'; +export { isSonarQubeAvailable } 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] ?? ''; };