Skip to content

Commit 2e8ebcf

Browse files
gabe-lyonsshirshanka
authored andcommitted
feat(React): powering user page via graphql
1 parent 7f2ca12 commit 2e8ebcf

File tree

3 files changed

+29
-36
lines changed

3 files changed

+29
-36
lines changed

datahub-web-react/src/components/entity/user/UserHeader.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import React from 'react';
44
import { Space, Badge, Typography, Avatar } from 'antd';
55

66
type Props = {
7-
profileSrc?: string;
8-
name: string;
9-
title: string;
10-
skills: string[];
11-
teams: string[];
12-
email: string;
7+
profileSrc?: string | null;
8+
name?: string | null;
9+
title?: string | null;
10+
skills?: string[] | null;
11+
teams?: string[] | null;
12+
email?: string | null;
1313
};
1414

1515
const Row = styled.div`
@@ -48,15 +48,15 @@ export default function UserHeader({ profileSrc, name, title, skills, teams, ema
4848
<Skills>
4949
<Typography.Title level={5}>Ask me about</Typography.Title>
5050
<Space>
51-
{skills.map((skill) => (
51+
{skills?.map((skill) => (
5252
<Badge style={{ backgroundColor: '#108ee9' }} count={skill} key={skill} />
5353
))}
5454
</Space>
5555
</Skills>
5656
<div>
5757
<Typography.Title level={5}>Teams</Typography.Title>
5858
<Space>
59-
{teams.map((team) => (
59+
{teams?.map((team) => (
6060
<Badge style={{ backgroundColor: '#87d068' }} count={team} key={team} />
6161
))}
6262
</Space>
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Divider } from 'antd';
1+
import { Divider, Alert } from 'antd';
22
import React from 'react';
33
import styled from 'styled-components';
44

5-
import { EntityType, PlatformNativeType } from '../../../types.generated';
65
import UserHeader from './UserHeader';
76
import UserDetails from './UserDetails';
87
import useUserParams from './routingUtils/useUserParams';
8+
import { useGetUserQuery } from '../../../graphql/user.generated';
99

1010
const PageContainer = styled.div`
1111
background-color: white;
@@ -17,38 +17,28 @@ const PageContainer = styled.div`
1717
*/
1818
export default function UserProfile() {
1919
const { urn, subview, item } = useUserParams();
20+
const { loading, error, data } = useGetUserQuery({ variables: { urn } });
21+
22+
if (loading) {
23+
return <Alert type="info" message="Loading" />;
24+
}
25+
26+
if (error || (!loading && !error && !data)) {
27+
return <Alert type="error" message={error?.message || 'Entity failed to load'} />;
28+
}
2029

2130
return (
2231
<PageContainer>
2332
<UserHeader
24-
name="Jane Doe"
25-
title="Software Engineer"
26-
skills={['Pandas', 'Multivariate Calculus', 'Juggling']}
27-
teams={['Product', 'Data Science']}
28-
33+
profileSrc={data?.corpUser?.editableInfo?.pictureLink}
34+
name={data?.corpUser?.info?.displayName}
35+
title={data?.corpUser?.info?.title}
36+
email={data?.corpUser?.info?.email}
37+
skills={data?.corpUser?.editableInfo?.skills}
38+
teams={data?.corpUser?.editableInfo?.teams}
2939
/>
3040
<Divider />
31-
<UserDetails
32-
urn={urn}
33-
subview={subview}
34-
item={item}
35-
ownerships={{
36-
[EntityType.Dataset]: [
37-
{
38-
name: 'HiveDataset',
39-
origin: 'PROD',
40-
description: 'this is a dataset',
41-
platformNativeType: PlatformNativeType.Table,
42-
},
43-
{
44-
name: 'KafkaDataset',
45-
origin: 'PROD',
46-
description: 'this is also a dataset',
47-
platformNativeType: PlatformNativeType.Table,
48-
},
49-
],
50-
}}
51-
/>
41+
<UserDetails urn={urn} subview={subview} item={item} ownerships={{}} />
5242
</PageContainer>
5343
);
5444
}

datahub-web-react/src/graphql/user.graphql

+3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ query getUser($urn: String!) {
99
firstName
1010
lastName
1111
fullName
12+
email
1213
}
1314
editableInfo {
1415
pictureLink
16+
teams
17+
skills
1518
}
1619
}
1720
}

0 commit comments

Comments
 (0)