update pr to remove profile changes
Signed-off-by: Joe Patterson <jrwpatterson@gmail.com>
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -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/',
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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<string, string> & {
|
||||
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<string, string> & {
|
||||
displayName?: string;
|
||||
email?: string;
|
||||
picture?: string;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type Validators = {
|
||||
isValidApiVersion(value: unknown): boolean;
|
||||
|
||||
@@ -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<string, string> & {
|
||||
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[];
|
||||
|
||||
@@ -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<string, string> & {
|
||||
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[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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: [],
|
||||
|
||||
@@ -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 }) => (
|
||||
<Box display="flex" alignItems="center">
|
||||
@@ -192,7 +192,6 @@ export const GroupProfileCard = (props: { variant?: InfoCardVariants }) => {
|
||||
/>
|
||||
</ListItem>
|
||||
<LinksGroup links={links} />
|
||||
<ProfileInfoGroup profile={profile} />
|
||||
</List>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@@ -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<string, string>;
|
||||
}) => {
|
||||
const profileKeys = useMemo(
|
||||
() =>
|
||||
profile !== undefined
|
||||
? Object.keys(profile).filter(key => !staticProfileKeys.includes(key))
|
||||
: [],
|
||||
[profile],
|
||||
);
|
||||
|
||||
if (profile === undefined || profileKeys.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Divider />
|
||||
{profileKeys.map(key => {
|
||||
const value = profile[key];
|
||||
|
||||
return (
|
||||
<ListItem key={key}>
|
||||
<ListItemText style={{ width: '25%', flexGrow: 0 }}>
|
||||
{key}
|
||||
</ListItemText>
|
||||
|
||||
<ListItemText>{value}</ListItemText>
|
||||
</ListItem>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -14,4 +14,3 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
export * from './LinksGroup';
|
||||
export * from './ProfileInfoGroup';
|
||||
|
||||
@@ -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'],
|
||||
},
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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 }) => {
|
||||
</ListItem>
|
||||
|
||||
<LinksGroup links={links} />
|
||||
<ProfileInfoGroup profile={profile} />
|
||||
</List>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user