diff --git a/.changeset/old-needles-brake.md b/.changeset/old-needles-brake.md new file mode 100644 index 0000000000..eea2bf6539 --- /dev/null +++ b/.changeset/old-needles-brake.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-github-issues': patch +'@backstage/plugin-github-pull-requests-board': patch +--- + +Properly filter on relations instead of the spec, when finding by owner diff --git a/plugins/github-issues/src/hooks/useEntityGitHubRepositories.ts b/plugins/github-issues/src/hooks/useEntityGitHubRepositories.ts index 242de514ca..d7b60575ad 100644 --- a/plugins/github-issues/src/hooks/useEntityGitHubRepositories.ts +++ b/plugins/github-issues/src/hooks/useEntityGitHubRepositories.ts @@ -13,13 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Entity } from '@backstage/catalog-model'; + +import { Entity, stringifyEntityRef } from '@backstage/catalog-model'; import { useApi } from '@backstage/core-plugin-api'; -import { - catalogApiRef, - humanizeEntityRef, - useEntity, -} from '@backstage/plugin-catalog-react'; +import { catalogApiRef, useEntity } from '@backstage/plugin-catalog-react'; import { useCallback, useEffect, useState } from 'react'; const GITHUB_PROJECT_SLUG_ANNOTATION = 'github.com/project-slug'; @@ -48,7 +45,7 @@ export function useEntityGitHubRepositories() { const entitiesList = await catalogApi.getEntities({ filter: { kind: ['Component', 'API'], - 'spec.owner': humanizeEntityRef(entity, { defaultKind: 'group' }), + 'relations.ownedBy': stringifyEntityRef(entity), }, }); diff --git a/plugins/github-pull-requests-board/src/hooks/useUserRepositories.tsx b/plugins/github-pull-requests-board/src/hooks/useUserRepositories.tsx index b905811aea..ed0d3580f0 100644 --- a/plugins/github-pull-requests-board/src/hooks/useUserRepositories.tsx +++ b/plugins/github-pull-requests-board/src/hooks/useUserRepositories.tsx @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import { stringifyEntityRef } from '@backstage/catalog-model'; import { useApi } from '@backstage/core-plugin-api'; -import { - catalogApiRef, - humanizeEntityRef, - useEntity, -} from '@backstage/plugin-catalog-react'; +import { catalogApiRef, useEntity } from '@backstage/plugin-catalog-react'; import { useCallback, useEffect, useState } from 'react'; import { getProjectNameFromEntity } from '../utils/functions'; @@ -29,9 +27,7 @@ export function useUserRepositories() { const getRepositoriesNames = useCallback(async () => { const entitiesList = await catalogApi.getEntities({ - filter: { - 'spec.owner': humanizeEntityRef(teamEntity, { defaultKind: 'group' }), - }, + filter: { 'relations.ownedBy': stringifyEntityRef(teamEntity) }, }); const entitiesNames: string[] = entitiesList.items.map(componentEntity =>