diff --git a/workspaces/orchestrator/.changeset/gentle-foxes-march.md b/workspaces/orchestrator/.changeset/gentle-foxes-march.md new file mode 100644 index 00000000000..cbd8fa4a571 --- /dev/null +++ b/workspaces/orchestrator/.changeset/gentle-foxes-march.md @@ -0,0 +1,5 @@ +--- +'@red-hat-developer-hub/backstage-plugin-orchestrator': patch +--- + +Fix unintended Workflows tab on User profile pages by converting the entity tab condition from a React hook-based component to a plain predicate function and using the built-in hasAnnotation checker in dynamic plugin config diff --git a/workspaces/orchestrator/plugins/orchestrator/app-config.yaml b/workspaces/orchestrator/plugins/orchestrator/app-config.yaml index 2889731ae79..c20139d1cf1 100644 --- a/workspaces/orchestrator/plugins/orchestrator/app-config.yaml +++ b/workspaces/orchestrator/plugins/orchestrator/app-config.yaml @@ -30,4 +30,4 @@ dynamicPlugins: gridColumn: '1 / -1' if: anyOf: - - IsOrchestratorCatalogTabAvailable + - hasAnnotation: orchestrator.io/workflows diff --git a/workspaces/orchestrator/plugins/orchestrator/report.api.md b/workspaces/orchestrator/plugins/orchestrator/report.api.md index 84d14b4321e..75950cd407c 100644 --- a/workspaces/orchestrator/plugins/orchestrator/report.api.md +++ b/workspaces/orchestrator/plugins/orchestrator/report.api.md @@ -4,14 +4,15 @@ ```ts import { BackstagePlugin } from '@backstage/core-plugin-api'; +import { Entity } from '@backstage/catalog-model'; import { JSX as JSX_2 } from 'react/jsx-runtime'; import { RouteRef } from '@backstage/core-plugin-api'; import { SvgIconProps } from '@mui/material/SvgIcon'; import { TranslationRef } from '@backstage/frontend-plugin-api'; import { TranslationResource } from '@backstage/frontend-plugin-api'; -// @public (undocumented) -export const IsOrchestratorCatalogTabAvailable: () => boolean; +// @public +export const IsOrchestratorCatalogTabAvailable: (entity: Entity) => boolean; // Warning: (ae-missing-release-tag) "OrchestratorCatalogTab" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -229,8 +230,7 @@ export const orchestratorTranslations: TranslationResource<'plugin.orchestrator' // Warnings were encountered during analysis: // -// src/components/catalogComponents/CatalogTab.d.ts:5:22 - (ae-undocumented) Missing documentation for "IsOrchestratorCatalogTabAvailable". -// src/components/catalogComponents/CatalogTab.d.ts:6:22 - (ae-undocumented) Missing documentation for "OrchestratorCatalogTab". +// src/components/catalogComponents/CatalogTab.d.ts:12:22 - (ae-undocumented) Missing documentation for "OrchestratorCatalogTab". // (No @packageDocumentation comment for this package) ``` diff --git a/workspaces/orchestrator/plugins/orchestrator/src/components/catalogComponents/CatalogTab.tsx b/workspaces/orchestrator/plugins/orchestrator/src/components/catalogComponents/CatalogTab.tsx index dca038c9aef..32b740511c3 100644 --- a/workspaces/orchestrator/plugins/orchestrator/src/components/catalogComponents/CatalogTab.tsx +++ b/workspaces/orchestrator/plugins/orchestrator/src/components/catalogComponents/CatalogTab.tsx @@ -13,18 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { Entity } from '@backstage/catalog-model'; import { useEntity } from '@backstage/plugin-catalog-react'; import { WorkflowsTabContent } from '../OrchestratorPage/WorkflowsTabContent'; /** * @public - * @returns True if the entity has the orchestrator.io/workflows annotation + * Predicate that returns true when the entity carries the + * `orchestrator.io/workflows` annotation. + * + * Compatible with both the legacy `EntityLayout.Route` `if` prop + * and the RHDH dynamic-plugin `if.anyOf` condition system, which + * call it as a plain function with the entity as the first argument. */ -export const IsOrchestratorCatalogTabAvailable = () => { - const { entity } = useEntity(); - return Boolean(entity.metadata.annotations?.['orchestrator.io/workflows']); -}; +export const IsOrchestratorCatalogTabAvailable = (entity: Entity): boolean => + Boolean(entity.metadata.annotations?.['orchestrator.io/workflows']); export const OrchestratorCatalogTab = () => { const { entity } = useEntity();