diff --git a/.changeset/five-bananas-retire.md b/.changeset/five-bananas-retire.md new file mode 100644 index 0000000000..88b1d3d6dd --- /dev/null +++ b/.changeset/five-bananas-retire.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-org': patch +--- + +Adds the Resource kind to the `useGetEntities` fallback so that Resources are included by default when no specific kinds are provided in the group ownership card. diff --git a/packages/app-next/app-config.yaml b/packages/app-next/app-config.yaml index 1121cfc0d5..97e8446fa4 100644 --- a/packages/app-next/app-config.yaml +++ b/packages/app-next/app-config.yaml @@ -30,6 +30,9 @@ app: config: showAggregateMembersToggle: true initialRelationAggregation: aggregated + - entity-card:org/ownership: + config: + ownedKinds: ['Component', 'API', 'System'] # - apis.plugin.graphiql.browse.gitlab: true # - graphiql-endpoint:graphiql/gitlab: true diff --git a/plugins/org/report-alpha.api.md b/plugins/org/report-alpha.api.md index 93e81f0851..cfd2290502 100644 --- a/plugins/org/report-alpha.api.md +++ b/plugins/org/report-alpha.api.md @@ -110,12 +110,14 @@ const _default: OverridableFrontendPlugin< config: { initialRelationAggregation: 'direct' | 'aggregated' | undefined; showAggregateMembersToggle: boolean | undefined; + ownedKinds: string[] | undefined; filter: EntityPredicate | undefined; type: 'content' | 'summary' | 'info' | undefined; }; configInput: { showAggregateMembersToggle?: boolean | undefined; initialRelationAggregation?: 'direct' | 'aggregated' | undefined; + ownedKinds?: string[] | undefined; filter?: EntityPredicate | undefined; type?: 'content' | 'summary' | 'info' | undefined; }; diff --git a/plugins/org/src/alpha.tsx b/plugins/org/src/alpha.tsx index 57924a0269..4e11463781 100644 --- a/plugins/org/src/alpha.tsx +++ b/plugins/org/src/alpha.tsx @@ -65,6 +65,7 @@ const EntityOwnershipCard = EntityCardBlueprint.makeWithOverrides({ initialRelationAggregation: z => z.enum(['direct', 'aggregated']).optional(), showAggregateMembersToggle: z => z.boolean().optional(), + ownedKinds: z => z.array(z.string()).optional(), }, }, factory(originalFactory, { config }) { @@ -79,6 +80,9 @@ const EntityOwnershipCard = EntityCardBlueprint.makeWithOverrides({ ? undefined : !config.showAggregateMembersToggle } + entityFilterKind={ + config.ownedKinds ?? ['Component', 'API', 'System', 'Resource'] + } /> )), }); diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx index 6ea0f0cbc9..5bb058e1b2 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx @@ -36,11 +36,21 @@ const items = [ { type: 'ownedBy', targetRef: 'group:default/my-team', - target: { - name: 'my-team', - namespace: 'default', - kind: 'group', - }, + }, + ], + }, + { + kind: 'Resource', + metadata: { + name: 'my-resource', + }, + spec: { + type: 'database', + }, + relations: [ + { + type: 'ownedBy', + targetRef: 'group:default/my-team', }, ], }, @@ -56,11 +66,6 @@ const items = [ { type: 'ownedBy', targetRef: 'group:default/my-team', - target: { - name: 'my-team', - namespace: 'default', - kind: 'group', - }, }, ], }, @@ -77,11 +82,6 @@ const items = [ { type: 'ownedBy', targetRef: 'group:default/my-team', - target: { - name: 'my-team', - namespace: 'default', - kind: 'group', - }, }, ], }, @@ -160,7 +160,7 @@ describe('OwnershipCard', () => { expect(mockedGetEntities).toHaveBeenCalledWith({ filter: [ { - kind: ['Component', 'API', 'System'], + kind: ['Component', 'API', 'System', 'Resource'], 'relations.ownedBy': ['group:default/my-team'], }, ], diff --git a/plugins/org/src/components/Cards/OwnershipCard/useGetEntities.ts b/plugins/org/src/components/Cards/OwnershipCard/useGetEntities.ts index a5a5363192..56c1e8cebd 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/useGetEntities.ts +++ b/plugins/org/src/components/Cards/OwnershipCard/useGetEntities.ts @@ -198,7 +198,7 @@ export function useGetEntities( error?: Error; } { const catalogApi = useApi(catalogApiRef); - const kinds = entityFilterKind ?? ['Component', 'API', 'System']; + const kinds = entityFilterKind ?? ['Component', 'API', 'System', 'Resource']; const { loading,