From 8b7351f3dff72cdab67157d7626b116d11e7f533 Mon Sep 17 00:00:00 2001 From: secustor Date: Tue, 9 Sep 2025 14:48:48 +0200 Subject: [PATCH] feat(plugins/org): add overwrites to membership and ownership cards Signed-off-by: secustor --- .changeset/giant-weeks-jump.md | 5 +++ packages/app-next/app-config.yaml | 5 +++ plugins/org/report-alpha.api.md | 40 +++++++++++++++++--- plugins/org/src/alpha.tsx | 61 ++++++++++++++++++++++++------- 4 files changed, 91 insertions(+), 20 deletions(-) create mode 100644 .changeset/giant-weeks-jump.md diff --git a/.changeset/giant-weeks-jump.md b/.changeset/giant-weeks-jump.md new file mode 100644 index 0000000000..1b11bd1490 --- /dev/null +++ b/.changeset/giant-weeks-jump.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-org': patch +--- + +Add `initialRelationAggregation` and `showAggregateMembersToggle` options to `EntityMembersListCard` as well to `EntityOwnershipCard` diff --git a/packages/app-next/app-config.yaml b/packages/app-next/app-config.yaml index f83e4d4ba0..59fecf7e64 100644 --- a/packages/app-next/app-config.yaml +++ b/packages/app-next/app-config.yaml @@ -22,6 +22,11 @@ app: ownerEntityRefs: [cubic-belugas] extensions: + - entity-card:org/members-list: + config: + showAggregateMembersToggle: true + initialRelationAggregation: aggregated + # - 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 3cebe00d33..3f8fdca05d 100644 --- a/plugins/org/report-alpha.api.md +++ b/plugins/org/report-alpha.api.md @@ -63,13 +63,17 @@ const _default: OverridableFrontendPlugin< }; }>; 'entity-card:org/members-list': ExtensionDefinition<{ - kind: 'entity-card'; - name: 'members-list'; config: { + initialRelationAggregation: 'direct' | 'aggregated' | undefined; + showAggregateMembersToggle: boolean | undefined; + } & { filter: EntityPredicate | undefined; type: 'content' | 'summary' | 'info' | undefined; }; configInput: { + showAggregateMembersToggle?: boolean | undefined; + initialRelationAggregation?: 'direct' | 'aggregated' | undefined; + } & { filter?: EntityPredicate | undefined; type?: 'content' | 'summary' | 'info' | undefined; }; @@ -96,7 +100,17 @@ const _default: OverridableFrontendPlugin< optional: true; } >; - inputs: {}; + inputs: { + [x: string]: ExtensionInput< + ExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + }; + kind: 'entity-card'; + name: 'members-list'; params: { loader: () => Promise; filter?: string | EntityPredicate | ((entity: Entity) => boolean); @@ -104,13 +118,17 @@ const _default: OverridableFrontendPlugin< }; }>; 'entity-card:org/ownership': ExtensionDefinition<{ - kind: 'entity-card'; - name: 'ownership'; config: { + initialRelationAggregation: 'direct' | 'aggregated' | undefined; + showAggregateMembersToggle: boolean | undefined; + } & { filter: EntityPredicate | undefined; type: 'content' | 'summary' | 'info' | undefined; }; configInput: { + showAggregateMembersToggle?: boolean | undefined; + initialRelationAggregation?: 'direct' | 'aggregated' | undefined; + } & { filter?: EntityPredicate | undefined; type?: 'content' | 'summary' | 'info' | undefined; }; @@ -137,7 +155,17 @@ const _default: OverridableFrontendPlugin< optional: true; } >; - inputs: {}; + inputs: { + [x: string]: ExtensionInput< + ExtensionDataRef, + { + optional: boolean; + singleton: boolean; + } + >; + }; + kind: 'entity-card'; + name: 'ownership'; params: { loader: () => Promise; filter?: string | EntityPredicate | ((entity: Entity) => boolean); diff --git a/plugins/org/src/alpha.tsx b/plugins/org/src/alpha.tsx index 92ae7d8801..ddb8094688 100644 --- a/plugins/org/src/alpha.tsx +++ b/plugins/org/src/alpha.tsx @@ -36,26 +36,59 @@ const EntityGroupProfileCard = EntityCardBlueprint.make({ }); /** @alpha */ -const EntityMembersListCard = EntityCardBlueprint.make({ +const EntityMembersListCard = EntityCardBlueprint.makeWithOverrides({ name: 'members-list', - params: { - filter: { kind: 'group' }, - loader: async () => - import('./components/Cards/Group/MembersList/MembersListCard').then(m => - compatWrapper(), - ), + config: { + schema: { + initialRelationAggregation: z => + z.enum(['direct', 'aggregated']).optional(), + showAggregateMembersToggle: z => z.boolean().optional(), + }, + }, + factory(originalFactory, { config }) { + return originalFactory({ + filter: { kind: 'group' }, + loader: async () => + import('./components/Cards/Group/MembersList/MembersListCard').then(m => + compatWrapper( + , + ), + ), + }); }, }); /** @alpha */ -const EntityOwnershipCard = EntityCardBlueprint.make({ +const EntityOwnershipCard = EntityCardBlueprint.makeWithOverrides({ name: 'ownership', - params: { - filter: { kind: { $in: ['group', 'user'] } }, - loader: async () => - import('./components/Cards/OwnershipCard/OwnershipCard').then(m => - compatWrapper(), - ), + config: { + schema: { + initialRelationAggregation: z => + z.enum(['direct', 'aggregated']).optional(), + showAggregateMembersToggle: z => z.boolean().optional(), + }, + }, + factory(originalFactory, { config }) { + return originalFactory({ + filter: { kind: { $in: ['group', 'user'] } }, + loader: async () => + import('./components/Cards/OwnershipCard/OwnershipCard').then(m => + compatWrapper( + , + ), + ), + }); }, });