Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(UI): add user location to user profile page #12016

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion datahub-web-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
"uuid": "^8.3.2",
"virtualizedtableforantd4": "^1.2.1",
"web-vitals": "^0.2.4",
"yamljs": "^0.3.0"
"yamljs": "^0.3.0",
"country-data-list": "^1.3.4"
},
"scripts": {
"analyze": "source-map-explorer 'dist/assets/*.js'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ export const Name = styled.div`
margin: 13px 0 7px 0;
`;

export const UserDetails = styled.div`
font-size: 14px;
line-height: 35px;
font-weight: 400;
line-height: 28px;
text-align: center;
`

export const TitleRole = styled.div`
font-size: 14px;
line-height: 22px;
Expand All @@ -74,6 +82,8 @@ export const TitleRole = styled.div`
export const Team = styled.div`
font-size: 12px;
line-height: 20px;
font-weight: 400;
padding-bottom: 10px;
color: #8c8c8c;
`;

Expand Down Expand Up @@ -111,6 +121,23 @@ export const AboutSection = styled.div`
color: #262626;
`;

export const LocationSection = styled.div`
text-align: left;
font-weight: bold;
font-size: 14px;
line-height: 26px;
color: #262626;
`;

export const LocationSectionText = styled.div`
text-align: left;
font-weight: normal;
font-size: 14px;
line-height: 26px;
margin-bottom: -10px;
color: #262626;
`;

export const AboutSectionText = styled.div`
font-size: 12px;
font-weight: 100;
Expand Down
33 changes: 32 additions & 1 deletion datahub-web-react/src/app/entity/user/UserInfoSideBar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import GlobeIcon from '../../../images/Globe.svg';
import { countries } from 'country-data-list';
import { Divider, message, Space, Button, Typography, Tag } from 'antd';
import React, { useEffect, useState } from 'react';
import { EditOutlined, MailOutlined, PhoneOutlined, SlackOutlined } from '@ant-design/icons';
Expand All @@ -17,6 +19,9 @@ import {
Name,
TitleRole,
Team,
LocationSection,
LocationSectionText,
UserDetails
} from '../shared/SidebarStyledComponents';
import EntityGroups from '../shared/EntityGroups';
import { mapRoleIcon } from '../../identity/user/UserUtils';
Expand All @@ -38,6 +43,8 @@ type SideBarData = {
groupsDetails: Array<EntityRelationship>;
urn: string | undefined;
dataHubRoles: Array<EntityRelationship>;
countryCode: string | undefined;
username: string | undefined;
};

type Props = {
Expand All @@ -51,7 +58,7 @@ const AVATAR_STYLE = { marginTop: '14px' };
* UserInfoSideBar- Sidebar section for users profiles.
*/
export default function UserInfoSideBar({ sideBarData, refetch }: Props) {
const { name, aboutText, avatarName, email, groupsDetails, phone, photoUrl, role, slack, team, dataHubRoles, urn } =
const { name, aboutText, avatarName, email, groupsDetails, phone, photoUrl, role, slack, team, dataHubRoles, urn, countryCode, username } =
sideBarData;

const [updateCorpUserPropertiesMutation] = useUpdateCorpUserPropertiesMutation();
Expand Down Expand Up @@ -114,12 +121,23 @@ export default function UserInfoSideBar({ sideBarData, refetch }: Props) {
};
const dataHubRoleName = dataHubRoles && dataHubRoles.length > 0 && (dataHubRoles[0]?.entity as DataHubRole).name;

let countryName;
const findCountryName = (countryCode) => {
try {
countryName = countries[countryCode].name;
} catch (error) {
countryName = '';
}
return countryName;
};

return (
<>
<SideBar>
<SideBarSubSection className={isProfileOwner ? '' : 'fullView'}>
<CustomAvatar size={160} photoUrl={photoUrl} name={avatarName} style={AVATAR_STYLE} />
<Name>{name || <EmptyValue />}</Name>
<UserDetails>{username || <EmptyValue />}</UserDetails>
{role && <TitleRole>{role}</TitleRole>}
{team && <Team>{team}</Team>}
{dataHubRoleName && <Tag icon={mapRoleIcon(dataHubRoleName)}>{dataHubRoleName}</Tag>}
Expand All @@ -143,6 +161,19 @@ export default function UserInfoSideBar({ sideBarData, refetch }: Props) {
</Space>
</SocialDetails>
<Divider className="divider-aboutSection" />
{ countryCode ? (
<LocationSection>
Location
<br />
<LocationSectionText>
<img src={GlobeIcon} alt="Manage Users" style={{ display: 'inline' }} /> &nbsp;
samanthafigueredo5 marked this conversation as resolved.
Show resolved Hide resolved
{findCountryName(countryCode)}
</LocationSectionText>
<Divider className="divider-aboutSection" />
</LocationSection>
): (
null
)}
<AboutSection>
About
<AboutSectionText>
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/user/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ export default function UserProfile() {
undefined,
role: data?.corpUser?.editableProperties?.title || data?.corpUser?.info?.title || undefined,
team: data?.corpUser?.editableProperties?.teams?.join(',') || data?.corpUser?.info?.departmentName || undefined,
samanthafigueredo5 marked this conversation as resolved.
Show resolved Hide resolved
countryCode: data?.corpUser?.info?.countryCode|| undefined,
email: data?.corpUser?.editableProperties?.email || data?.corpUser?.info?.email || undefined,
slack: data?.corpUser?.editableProperties?.slack || undefined,
phone: data?.corpUser?.editableProperties?.phone || undefined,
aboutText: data?.corpUser?.editableProperties?.aboutMe || undefined,
groupsDetails: userGroups,
dataHubRoles: userRoles,
urn,
username: data?.corpUser?.username
};

if (data?.corpUser?.exists === false) {
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/graphql/user.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ query getUser($urn: String!, $groupsCount: Int!) {
fullName
email
departmentName
countryCode
}
editableProperties {
slack
Expand Down
10 changes: 10 additions & 0 deletions datahub-web-react/src/images/Globe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions datahub-web-react/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5926,6 +5926,13 @@ cosmiconfig@^8.1.0, cosmiconfig@^8.1.3:
parse-json "^5.2.0"
path-type "^4.0.0"

country-data-list@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/country-data-list/-/country-data-list-1.3.4.tgz#0c88a5b8b5c6cba2e0881ee378b7a24b5216aae4"
integrity sha512-BKwqyeXbmhhzOEf1gcH1Ui1X/ni8YmXTllhCTNW23ja/u7EY1lKS0hrK68kngw5ni6WooXLARXmnHxGnKDWQpQ==
dependencies:
currency-symbol-map "~5"

create-context-state@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/create-context-state/-/create-context-state-2.0.0.tgz#b58d33c553ef6c66958899d06fad4edf1b99ca24"
Expand Down Expand Up @@ -6015,6 +6022,11 @@ csstype@^3.0.2, csstype@^3.0.6, csstype@^3.0.7, csstype@^3.1.0, csstype@^3.1.1:
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.1.tgz#841b532c45c758ee546a11d5bd7b7b473c8c30b9"
integrity sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==

currency-symbol-map@~5:
version "5.1.0"
resolved "https://registry.yarnpkg.com/currency-symbol-map/-/currency-symbol-map-5.1.0.tgz#59531fbe977ba95e8d358e90e3c9e9053efb75ad"
integrity sha512-LO/lzYRw134LMDVnLyAf1dHE5tyO6axEFkR3TXjQIOmMkAM9YL6QsiUwuXzZAmFnuDJcs4hayOgyIYtViXFrLw==

csstype@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81"
Expand Down
Loading