From 38726cd9a79a8d922b6e44ed666eff4985490838 Mon Sep 17 00:00:00 2001 From: Jeff Cook Date: Wed, 7 Apr 2021 23:22:30 +0000 Subject: [PATCH 1/4] 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] ?? ''; }; From db802fafbde016614982fbb38a82c9d54ca70bfb Mon Sep 17 00:00:00 2001 From: Jeff Cook Date: Wed, 7 Apr 2021 23:35:10 +0000 Subject: [PATCH 2/4] Include changeset for exporting `isPluginAvailableToEntity` in sonarqube Signed-off-by: Jeff Cook --- .changeset/chatty-ghosts-lay.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/chatty-ghosts-lay.md diff --git a/.changeset/chatty-ghosts-lay.md b/.changeset/chatty-ghosts-lay.md new file mode 100644 index 0000000000..472975e826 --- /dev/null +++ b/.changeset/chatty-ghosts-lay.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-sonarqube': patch +--- + +Export isPluginAvailableToEntity From 413b98ff7d3d1b2642715ed06f97982fd9f28d96 Mon Sep 17 00:00:00 2001 From: Jeff Cook Date: Wed, 7 Apr 2021 23:46:02 +0000 Subject: [PATCH 3/4] Fix changelog description. Signed-off-by: Jeff Cook --- .changeset/chatty-ghosts-lay.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/chatty-ghosts-lay.md b/.changeset/chatty-ghosts-lay.md index 472975e826..26a83f89f9 100644 --- a/.changeset/chatty-ghosts-lay.md +++ b/.changeset/chatty-ghosts-lay.md @@ -2,4 +2,4 @@ '@backstage/plugin-sonarqube': patch --- -Export isPluginAvailableToEntity +Export isPluginApplicableToEntity From ec75495ee3d62e211b55f19a80ef71464fd51288 Mon Sep 17 00:00:00 2001 From: Jeff Cook Date: Thu, 8 Apr 2021 13:27:49 +0000 Subject: [PATCH 4/4] No need to export under the alias isPluginApplicableToEntity. ... That's an old pattern, per https://github.com/backstage/backstage/pull/5245#discussion_r609367059. Signed-off-by: Jeff Cook --- .changeset/chatty-ghosts-lay.md | 2 +- plugins/sonarqube/src/components/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/chatty-ghosts-lay.md b/.changeset/chatty-ghosts-lay.md index 26a83f89f9..7d8ef3edbd 100644 --- a/.changeset/chatty-ghosts-lay.md +++ b/.changeset/chatty-ghosts-lay.md @@ -2,4 +2,4 @@ '@backstage/plugin-sonarqube': patch --- -Export isPluginApplicableToEntity +Export isSonarQubeAvailable. diff --git a/plugins/sonarqube/src/components/index.ts b/plugins/sonarqube/src/components/index.ts index 8ff9a77485..56b9d05885 100644 --- a/plugins/sonarqube/src/components/index.ts +++ b/plugins/sonarqube/src/components/index.ts @@ -15,4 +15,4 @@ */ export * from './SonarQubeCard'; -export { isSonarQubeAvailable as isPluginApplicableToEntity } from './useProjectKey'; +export { isSonarQubeAvailable } from './useProjectKey';