diff --git a/.changeset/modern-pandas-agree.md b/.changeset/modern-pandas-agree.md new file mode 100644 index 0000000000..9c3f95aef2 --- /dev/null +++ b/.changeset/modern-pandas-agree.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-github': patch +--- + +Adds an edit URL to the GitHub Teams Group entities. diff --git a/plugins/catalog-backend-module-github/src/lib/github.test.ts b/plugins/catalog-backend-module-github/src/lib/github.test.ts index fb4caa42c0..40dec0a297 100644 --- a/plugins/catalog-backend-module-github/src/lib/github.test.ts +++ b/plugins/catalog-backend-module-github/src/lib/github.test.ts @@ -86,6 +86,7 @@ describe('github', () => { name: 'Team', description: 'The one and only team', avatarUrl: 'http://example.com/team.jpeg', + editTeamUrl: 'http://example.com/orgs/blah/teams/team/edit', parentTeam: { slug: 'parent', combinedSlug: '', @@ -109,6 +110,11 @@ describe('github', () => { metadata: expect.objectContaining({ name: 'team', description: 'The one and only team', + annotations: { + 'github.com/team-slug': 'blah/team', + 'backstage.io/edit-url': + 'http://example.com/orgs/blah/teams/team/edit', + }, }), spec: { type: 'team', diff --git a/plugins/catalog-backend-module-github/src/lib/github.ts b/plugins/catalog-backend-module-github/src/lib/github.ts index b3dae26091..888df380f8 100644 --- a/plugins/catalog-backend-module-github/src/lib/github.ts +++ b/plugins/catalog-backend-module-github/src/lib/github.ts @@ -52,6 +52,7 @@ export type Team = { name?: string; description?: string; avatarUrl?: string; + editTeamUrl?: string; parentTeam?: Team; members: Connection; }; @@ -165,6 +166,7 @@ export async function getOrganizationTeams( name description avatarUrl + editTeamUrl parentTeam { slug } members(first: 100, membership: IMMEDIATE) { pageInfo { hasNextPage } @@ -179,14 +181,20 @@ export async function getOrganizationTeams( const groupMemberUsers = new Map(); const mapper = async (team: Team) => { + const annotations: { [annotationName: string]: string } = { + 'github.com/team-slug': team.combinedSlug, + }; + + if (team.editTeamUrl) { + annotations['backstage.io/edit-url'] = team.editTeamUrl; + } + const entity: GroupEntity = { apiVersion: 'backstage.io/v1alpha1', kind: 'Group', metadata: { name: team.slug, - annotations: { - 'github.com/team-slug': team.combinedSlug, - }, + annotations, }, spec: { type: 'team',