From 0b115001515c3abc4764b3b4b707889caa5f5131 Mon Sep 17 00:00:00 2001 From: Joe Patterson Date: Wed, 19 Oct 2022 15:09:49 +1000 Subject: [PATCH] update pr to remove profile changes Signed-off-by: Joe Patterson --- .changeset/popular-ants-mix.md | 5 ++ .changeset/tender-jeans-clean.md | 12 ---- .../software-catalog/external-integrations.md | 13 ++--- packages/catalog-model/api-report.md | 26 ++++----- .../src/kinds/GroupEntityV1alpha1.ts | 17 ++---- .../src/kinds/UserEntityV1alpha1.ts | 17 ++---- packages/catalog-model/src/kinds/index.ts | 2 - .../GroupProfile/GroupProfileCard.stories.tsx | 2 - .../Group/GroupProfile/GroupProfileCard.tsx | 3 +- .../Cards/Meta/ProfileInfoGroup.tsx | 56 ------------------- .../org/src/components/Cards/Meta/index.ts | 1 - .../UserProfileCard.stories.tsx | 3 - .../UserProfileCard/UserProfileCard.test.tsx | 7 --- .../User/UserProfileCard/UserProfileCard.tsx | 3 +- 14 files changed, 32 insertions(+), 135 deletions(-) create mode 100644 .changeset/popular-ants-mix.md delete mode 100644 .changeset/tender-jeans-clean.md delete mode 100644 plugins/org/src/components/Cards/Meta/ProfileInfoGroup.tsx diff --git a/.changeset/popular-ants-mix.md b/.changeset/popular-ants-mix.md new file mode 100644 index 0000000000..f0e6b17f8d --- /dev/null +++ b/.changeset/popular-ants-mix.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-org': minor +--- + +Updates the User and Group Profile cards to add the links from the UserEntity or the GroupEntity diff --git a/.changeset/tender-jeans-clean.md b/.changeset/tender-jeans-clean.md deleted file mode 100644 index 2729fa393a..0000000000 --- a/.changeset/tender-jeans-clean.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -'@backstage/catalog-model': minor -'@backstage/plugin-org': minor ---- - -Updates the profile of Group and User to allow any extra string key pair value. - -Then updates the user profile and group profile cards to display any links and extra profile details. - -This allows extra customization without going down the full customization route. - -So for example if you wanted to add address, phone number, job title, slack link to users or departments this allows you to within the current spec diff --git a/docs/features/software-catalog/external-integrations.md b/docs/features/software-catalog/external-integrations.md index 65f019efa3..65f97fb8da 100644 --- a/docs/features/software-catalog/external-integrations.md +++ b/docs/features/software-catalog/external-integrations.md @@ -356,18 +356,15 @@ export class UserEntityProvider implements EntityProvider { }, links, // name of the entity - name: kebabCase(user.displayName as string), + name: kebabCase(user.displayName), // name for display purposes could be anything including email - title: user.displayName as string, + title: user.displayName, }, spec: { profile: { - displayName: user.displayName as string, + displayName: user.displayName, email: user.email, - picture: user.photoUrl ?? 'fake', - // we can add any string/string here and it will be displayed on a user profile card, eg Job Title, Address, or any other information you want displayed - 'Job Title': user.jobTitle as string, - 'Address': user.address, + picture: user.photoUrl, }, memberOf: [], }, @@ -380,7 +377,7 @@ export class UserEntityProvider implements EntityProvider { type: 'full', entities: userResources.map((entity) => ({ entity, - locationKey: 'hr-user:https://www.hrurl.com', + locationKey: 'hr-user-https://www.hrurl.com/', })), }) } diff --git a/packages/catalog-model/api-report.md b/packages/catalog-model/api-report.md index da4c335051..b7456bb2f8 100644 --- a/packages/catalog-model/api-report.md +++ b/packages/catalog-model/api-report.md @@ -257,7 +257,11 @@ interface GroupEntityV1alpha1 extends Entity { // (undocumented) spec: { type: string; - profile?: GroupProfile; + profile?: { + displayName?: string; + email?: string; + picture?: string; + }; parent?: string; children: string[]; members?: string[]; @@ -269,13 +273,6 @@ export { GroupEntityV1alpha1 }; // @public export const groupEntityV1alpha1Validator: KindValidator; -// @public -export type GroupProfile = Record & { - displayName?: string; - email?: string; - picture?: string; -}; - // @public (undocumented) export function isApiEntity(entity: Entity): entity is ApiEntityV1alpha1; @@ -494,7 +491,11 @@ interface UserEntityV1alpha1 extends Entity { kind: 'User'; // (undocumented) spec: { - profile?: UserProfile; + profile?: { + displayName?: string; + email?: string; + picture?: string; + }; memberOf?: string[]; }; } @@ -504,13 +505,6 @@ export { UserEntityV1alpha1 }; // @public export const userEntityV1alpha1Validator: KindValidator; -// @public -export type UserProfile = Record & { - displayName?: string; - email?: string; - picture?: string; -}; - // @public export type Validators = { isValidApiVersion(value: unknown): boolean; diff --git a/packages/catalog-model/src/kinds/GroupEntityV1alpha1.ts b/packages/catalog-model/src/kinds/GroupEntityV1alpha1.ts index 50304e5220..8d88817dbe 100644 --- a/packages/catalog-model/src/kinds/GroupEntityV1alpha1.ts +++ b/packages/catalog-model/src/kinds/GroupEntityV1alpha1.ts @@ -18,17 +18,6 @@ import type { Entity } from '../entity/Entity'; import schema from '../schema/kinds/Group.v1alpha1.schema.json'; import { ajvCompiledJsonSchemaValidator } from './util'; -/** - * Backstage Group Profile. - * - * @public - */ -export type GroupProfile = Record & { - displayName?: string; - email?: string; - picture?: string; -}; - /** * Backstage catalog Group kind Entity. * @@ -39,7 +28,11 @@ export interface GroupEntityV1alpha1 extends Entity { kind: 'Group'; spec: { type: string; - profile?: GroupProfile; + profile?: { + displayName?: string; + email?: string; + picture?: string; + }; parent?: string; children: string[]; members?: string[]; diff --git a/packages/catalog-model/src/kinds/UserEntityV1alpha1.ts b/packages/catalog-model/src/kinds/UserEntityV1alpha1.ts index 9e034ad6b3..55c9b176ea 100644 --- a/packages/catalog-model/src/kinds/UserEntityV1alpha1.ts +++ b/packages/catalog-model/src/kinds/UserEntityV1alpha1.ts @@ -18,17 +18,6 @@ import type { Entity } from '../entity/Entity'; import schema from '../schema/kinds/User.v1alpha1.schema.json'; import { ajvCompiledJsonSchemaValidator } from './util'; -/** - * Backstage User Profile. - * - * @public - */ -export type UserProfile = Record & { - displayName?: string; - email?: string; - picture?: string; -}; - /** * Backstage catalog User kind Entity. * @@ -38,7 +27,11 @@ export interface UserEntityV1alpha1 extends Entity { apiVersion: 'backstage.io/v1alpha1' | 'backstage.io/v1beta1'; kind: 'User'; spec: { - profile?: UserProfile; + profile?: { + displayName?: string; + email?: string; + picture?: string; + }; memberOf?: string[]; }; } diff --git a/packages/catalog-model/src/kinds/index.ts b/packages/catalog-model/src/kinds/index.ts index dd9d0545c6..7211c25a8d 100644 --- a/packages/catalog-model/src/kinds/index.ts +++ b/packages/catalog-model/src/kinds/index.ts @@ -33,7 +33,6 @@ export { groupEntityV1alpha1Validator } from './GroupEntityV1alpha1'; export type { GroupEntityV1alpha1 as GroupEntity, GroupEntityV1alpha1, - GroupProfile, } from './GroupEntityV1alpha1'; export { locationEntityV1alpha1Validator } from './LocationEntityV1alpha1'; export type { @@ -56,5 +55,4 @@ export { userEntityV1alpha1Validator } from './UserEntityV1alpha1'; export type { UserEntityV1alpha1 as UserEntity, UserEntityV1alpha1, - UserProfile, } from './UserEntityV1alpha1'; diff --git a/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.stories.tsx b/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.stories.tsx index 264c4081d7..cfb3d847a4 100644 --- a/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.stories.tsx +++ b/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.stories.tsx @@ -112,8 +112,6 @@ const extraDetailsEntity: GroupEntity = { email: 'team-a@example.com', picture: 'https://avatars.dicebear.com/api/identicon/team-a@example.com.svg?background=%23fff&margin=25', - Telephone: '123456789', - Location: 'London', }, type: 'group', children: [], diff --git a/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx b/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx index e6cd183e8f..3a6b7c238d 100644 --- a/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx +++ b/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx @@ -52,7 +52,7 @@ import { Link, } from '@backstage/core-components'; import { alertApiRef, useApi } from '@backstage/core-plugin-api'; -import { LinksGroup, ProfileInfoGroup } from '../../Meta'; +import { LinksGroup } from '../../Meta'; const CardTitle = (props: { title: string }) => ( @@ -192,7 +192,6 @@ export const GroupProfileCard = (props: { variant?: InfoCardVariants }) => { /> - diff --git a/plugins/org/src/components/Cards/Meta/ProfileInfoGroup.tsx b/plugins/org/src/components/Cards/Meta/ProfileInfoGroup.tsx deleted file mode 100644 index 177983d4a5..0000000000 --- a/plugins/org/src/components/Cards/Meta/ProfileInfoGroup.tsx +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2022 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { ListItem, ListItemText, Divider } from '@material-ui/core'; -import React, { useMemo } from 'react'; - -const staticProfileKeys = ['displayName', 'email', 'picture']; - -export const ProfileInfoGroup = ({ - profile, -}: { - profile?: Record; -}) => { - const profileKeys = useMemo( - () => - profile !== undefined - ? Object.keys(profile).filter(key => !staticProfileKeys.includes(key)) - : [], - [profile], - ); - - if (profile === undefined || profileKeys.length === 0) { - return null; - } - - return ( - <> - - {profileKeys.map(key => { - const value = profile[key]; - - return ( - - - {key} - - - {value} - - ); - })} - - ); -}; diff --git a/plugins/org/src/components/Cards/Meta/index.ts b/plugins/org/src/components/Cards/Meta/index.ts index 5f4e5b4690..076af49bf9 100644 --- a/plugins/org/src/components/Cards/Meta/index.ts +++ b/plugins/org/src/components/Cards/Meta/index.ts @@ -14,4 +14,3 @@ * limitations under the License. */ export * from './LinksGroup'; -export * from './ProfileInfoGroup'; diff --git a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx index 7abfbee389..a27be7857b 100644 --- a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx +++ b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx @@ -127,9 +127,6 @@ const extraDetailsEntity: UserEntity = { email: 'guest@example.com', picture: 'https://avatars.dicebear.com/api/avataaars/guest@example.com.svg?background=%23fff', - 'Job Title': 'Software Engineer', - Department: 'Engineering', - Location: 'San Francisco, CA', }, memberOf: ['team-a'], }, diff --git a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.test.tsx b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.test.tsx index 7eabdf2903..fb0df3d25f 100644 --- a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.test.tsx +++ b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.test.tsx @@ -183,9 +183,6 @@ describe('Edit Button', () => { profile: { displayName: 'Calum Leavy', email: 'calum-leavy@example.com', - 'Job Title': 'Software Engineer', - Department: 'Engineering', - Location: 'San Francisco, CA', }, memberOf: ['ExampleGroup'], }, @@ -209,10 +206,6 @@ describe('Edit Button', () => { }, ), ); - expect(rendered.getByText('Software Engineer')).toBeInTheDocument(); - expect(rendered.getByText('Department')).toBeInTheDocument(); - expect(rendered.getByText('San Francisco, CA')).toBeInTheDocument(); - expect(rendered.getByText('Location')).toBeInTheDocument(); expect(rendered.getByText('Slack')).toBeInTheDocument(); expect(rendered.getByText('Google')).toBeInTheDocument(); }); diff --git a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx index 8a56dc58c2..a35c1c057b 100644 --- a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx +++ b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx @@ -46,7 +46,7 @@ import { InfoCardVariants, Link, } from '@backstage/core-components'; -import { LinksGroup, ProfileInfoGroup } from '../../Meta'; +import { LinksGroup } from '../../Meta'; const CardTitle = (props: { title?: string }) => props.title ? ( @@ -131,7 +131,6 @@ export const UserProfileCard = (props: { variant?: InfoCardVariants }) => { -