Import picture and display name by the GitHubOrgReaderProcessor

This commit is contained in:
Oliver Sand
2020-12-08 16:59:20 +01:00
parent c5297baeb0
commit 8dd0a906da
3 changed files with 35 additions and 3 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/plugin-catalog-backend': patch
---
Support `profile` of groups including `displayName` and `picture` in
`GithubOrgReaderProcessor`. Fixes the import of `description` for groups.
@@ -78,6 +78,9 @@ describe('github', () => {
{
slug: 'team',
combinedSlug: 'blah/team',
name: 'Team',
description: 'The one and only team',
avatarUrl: 'http://example.com/team.jpeg',
parentTeam: {
slug: 'parent',
combinedSlug: '',
@@ -96,9 +99,16 @@ describe('github', () => {
const output = {
groups: [
expect.objectContaining({
metadata: expect.objectContaining({ name: 'team' }),
metadata: expect.objectContaining({
name: 'team',
description: 'The one and only team',
}),
spec: {
type: 'team',
profile: {
displayName: 'Team',
picture: 'http://example.com/team.jpeg',
},
parent: 'parent',
children: [],
},
@@ -45,7 +45,9 @@ export type User = {
export type Team = {
slug: string;
combinedSlug: string;
name?: string;
description?: string;
avatarUrl?: string;
parentTeam?: Team;
members: Connection<User>;
};
@@ -137,6 +139,9 @@ export async function getOrganizationTeams(
nodes {
slug
combinedSlug
name
description
avatarUrl
parentTeam { slug }
members(first: 100, membership: IMMEDIATE) {
pageInfo { hasNextPage }
@@ -162,12 +167,23 @@ export async function getOrganizationTeams(
},
spec: {
type: 'team',
profile: {},
children: [],
},
};
if (team.description) entity.metadata.description = team.description;
if (team.parentTeam) entity.spec.parent = team.parentTeam.slug;
if (team.description) {
entity.metadata.description = team.description;
}
if (team.name) {
entity.spec.profile!.displayName = team.name;
}
if (team.avatarUrl) {
entity.spec.profile!.picture = team.avatarUrl;
}
if (team.parentTeam) {
entity.spec.parent = team.parentTeam.slug;
}
const memberNames: string[] = [];
groupMemberUsers.set(team.slug, memberNames);