-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add user information side sheet and project refactor (#434)
# Description Adds Iser information side sheet and refactor of code according to structure defined in Contributions md file. > Please include a summary of the change and which issue is fixed. List any external dependencies that are required for this change. - [x] PR title and description are to the point and understandable - [x] I have performed a self-review of my own code' Please select version type the purposed change: - [ ] major - [x] minor - [ ] patch - [ ] none <!--- Creates an empty changeset --> External Relations - [ ] database migration ## Changeset Adding user info side-sheet with contact details, riles and my allocations. <!--- Write your changeset here --> --------- Co-authored-by: Noggling <[email protected]>
- Loading branch information
Showing
126 changed files
with
2,320 additions
and
312 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"fusion-project-portal": minor | ||
--- | ||
|
||
|
||
Added `@portal/components` project for ui components utilising components and functionality form `@portal/ui` and `@portal/core`. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"fusion-project-portal": minor | ||
--- | ||
|
||
Added `@portal/ui` project for ui components used in the portal. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"fusion-project-portal": patch | ||
--- | ||
|
||
|
||
Added `@portal/utils` project for utile funtions and moved old utils to new project. `@equinor/portal-utils` has now been deleted. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"fusion-project-portal": minor | ||
--- | ||
|
||
|
||
Added `@portal/core` project for core functionality. Added the new functionality, and is now ready for migration. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
--- | ||
"fusion-project-portal": minor | ||
--- | ||
Adding user info side-sheet with contact details, riles and my allocations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"fusion-project-portal": minor | ||
--- | ||
|
||
Added `@portal/types` porject for globale portal types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# portal-ui | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test portal-ui` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@portal/components", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "vitest --silent --run", | ||
"test:coverage": "vitest run --coverage" | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
client/packages/components/src/components/my-account/MyAccount.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { useCurrentUser } from '@portal/core'; | ||
import { getAccountTypeColor } from '@portal/ui'; | ||
|
||
import { SideSheet } from '@equinor/fusion-react-side-sheet'; | ||
|
||
import { ProfileCardHeader } from './components/ProfileCardHeader'; | ||
|
||
import { ProfileContactDetails } from './components/ProfileContactDetails'; | ||
import { Button, Icon } from '@equinor/eds-core-react'; | ||
import { ProfileManagerCard } from './components/ProfileManager'; | ||
import { briefcase, settings, verified_user } from '@equinor/eds-icons'; | ||
import styled from 'styled-components'; | ||
import { tokens } from '@equinor/eds-tokens'; | ||
import { useMemo, useState } from 'react'; | ||
import { MyRolesTab } from '../my-roles-tab/MyRolesTab'; | ||
import { MyAllocationTab } from '../my-allocations-tab/MyAllocationTab'; | ||
import { PortalSettingsTab } from '../portal-settings-tab/PortalSettingsTab'; | ||
import { PortalActionProps } from '@equinor/portal-core'; | ||
import { PresenceIndicator } from '../presence-indicator'; | ||
|
||
const Style = { | ||
Wrapper: styled.div` | ||
padding: 1rem 0rem; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
`, | ||
Button: styled(Button)` | ||
width: 100%; | ||
display: flex; | ||
padding: 1rem; | ||
height: auto; | ||
`, | ||
}; | ||
|
||
type Tabs = { | ||
Profile: JSX.Element; | ||
MyRoles: JSX.Element; | ||
MyAllocations: JSX.Element; | ||
PortalSettings: JSX.Element; | ||
}; | ||
|
||
export function MyAccount({ action, onClose, open }: PortalActionProps) { | ||
const { data: user, isLoading } = useCurrentUser(); | ||
|
||
const [activeTab, setActiveTab] = useState<keyof Tabs>('Profile'); | ||
|
||
const tabs: Tabs = useMemo(() => { | ||
return { | ||
Profile: ( | ||
<> | ||
<PresenceIndicator /> | ||
<hr /> | ||
<ProfileContactDetails user={user} isLoading={isLoading} /> | ||
<hr /> | ||
<ProfileManagerCard user={user} /> | ||
<hr /> | ||
<Style.Wrapper> | ||
<Style.Button variant="ghost" onClick={() => setActiveTab('MyAllocations')}> | ||
<Icon data={briefcase} scale={40} color={tokens.colors.text.static_icons__tertiary.hex} /> | ||
My Allocations | ||
</Style.Button> | ||
<Style.Button variant="ghost" onClick={() => setActiveTab('MyRoles')}> | ||
<Icon | ||
data={verified_user} | ||
scale={40} | ||
color={tokens.colors.text.static_icons__tertiary.hex} | ||
/> | ||
My Roles | ||
</Style.Button> | ||
</Style.Wrapper> | ||
<hr /> | ||
<Style.Wrapper> | ||
<Style.Button variant="ghost" onClick={() => setActiveTab('PortalSettings')}> | ||
<Icon data={settings} scale={40} color={tokens.colors.text.static_icons__tertiary.hex} /> | ||
Portal Setting | ||
</Style.Button> | ||
</Style.Wrapper> | ||
</> | ||
), | ||
MyRoles: <MyRolesTab onClick={() => setActiveTab('Profile')} user={user} />, | ||
MyAllocations: <MyAllocationTab onClick={() => setActiveTab('Profile')} positions={user?.positions} />, | ||
PortalSettings: <PortalSettingsTab onClick={() => setActiveTab('Profile')} user={user} />, | ||
}; | ||
}, [user, setActiveTab]); | ||
|
||
return ( | ||
<SideSheet isOpen={open} onClose={onClose} isDismissable={true} minWidth={action.minWidth}> | ||
<SideSheet.Indicator color={getAccountTypeColor(user?.accountType)} /> | ||
<SideSheet.Title title={action.name} /> | ||
<SideSheet.SubTitle subTitle={user?.accountType || ''} /> | ||
<SideSheet.Content> | ||
{/* <InfoMessage>This functionality is not yet implemented.</InfoMessage> */} | ||
<ProfileCardHeader user={user} /> | ||
<hr /> | ||
{tabs[activeTab]} | ||
</SideSheet.Content> | ||
</SideSheet> | ||
); | ||
} |
46 changes: 46 additions & 0 deletions
46
client/packages/components/src/components/my-account/components/ProfileCardHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import styled from 'styled-components'; | ||
import { Typography } from '@equinor/eds-core-react'; | ||
import { getDepartment, getJobTitle, useUserPhoto } from '@portal/core'; | ||
import { PersonDetails } from '@portal/types'; | ||
import { Avatar, Skeleton, getAccountTypeColor } from '@portal/ui'; | ||
|
||
const Style = { | ||
InfoWrapper: styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 1rem; | ||
padding: 1rem; | ||
`, | ||
}; | ||
|
||
export const ProfileCardHeader = ({ user }: { user?: PersonDetails }) => { | ||
const { data: url } = useUserPhoto(user?.azureUniqueId); | ||
if (!user) { | ||
return ( | ||
<Style.InfoWrapper> | ||
<Skeleton variant="circle" size="medium" /> | ||
|
||
<div> | ||
<Skeleton width="200px" /> | ||
<div style={{ paddingTop: '0.5rem', gap: '0.2rem', display: 'flex', flexDirection: 'column' }}> | ||
<Skeleton width={60} /> | ||
<Skeleton width={60} /> | ||
</div> | ||
</div> | ||
</Style.InfoWrapper> | ||
); | ||
} | ||
|
||
return ( | ||
<Style.InfoWrapper> | ||
<Avatar url={url} borderColor={getAccountTypeColor(user.accountType)} width={60} height={60} /> | ||
<div> | ||
<Typography variant="h6">{user?.name}</Typography> | ||
<div> | ||
<Typography>{getJobTitle(user)}</Typography> | ||
<Typography>{getDepartment(user)}</Typography> | ||
</div> | ||
</div> | ||
</Style.InfoWrapper> | ||
); | ||
}; |
67 changes: 67 additions & 0 deletions
67
client/packages/components/src/components/my-account/components/ProfileContactDetails.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import styled from 'styled-components'; | ||
import { Icon, Typography } from '@equinor/eds-core-react'; | ||
|
||
import { ProfileListItem } from './ProfileListItem'; | ||
import { TeamsIcon, DelveIcon, Skeleton } from '@portal/ui'; | ||
|
||
import { PersonDetails } from '@portal/types'; | ||
|
||
const Style = { | ||
InfoWrapper: styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
padding: 1rem, 0rem; | ||
`, | ||
}; | ||
|
||
export const ProfileContactDetails = ({ user, isLoading }: { user?: PersonDetails; isLoading: boolean }) => { | ||
return ( | ||
<Style.InfoWrapper> | ||
<Typography>Contact Details</Typography> | ||
{user?.mail ? ( | ||
<ProfileListItem | ||
icon={<Icon name="email" style={{ fontSize: '16px' }} />} | ||
href={`mailto:${user.mail}`} | ||
toCopy={user.mail} | ||
text={user.mail} | ||
title="Email address" | ||
/> | ||
) : ( | ||
isLoading && <Skeleton width={60} style={{ margin: '1rem 0' }} /> | ||
)} | ||
{user?.mobilePhone ? ( | ||
<ProfileListItem | ||
icon={<Icon name="iphone" style={{ fontSize: '16px' }} />} | ||
href={`callto:${user.mobilePhone}`} | ||
toCopy={user.mobilePhone} | ||
text={user.mobilePhone} | ||
title="Phone number" | ||
/> | ||
) : ( | ||
isLoading && <Skeleton width={60} style={{ margin: '1rem 0' }} /> | ||
)} | ||
{user?.mail ? ( | ||
<ProfileListItem | ||
icon={<TeamsIcon />} | ||
href={`msteams:/l/chat/0/0?users=${user.mail}`} | ||
toCopy={`msteams:/l/chat/0/0?users=${user.mail}`} | ||
text="Start a chat in Teams" | ||
title={`${user.name} Teams`} | ||
/> | ||
) : ( | ||
isLoading && <Skeleton width={60} style={{ margin: '1rem 0' }} /> | ||
)} | ||
{user?.azureUniqueId ? ( | ||
<ProfileListItem | ||
icon={<DelveIcon />} | ||
href={`https://eur.delve.office.com/?u=${user.azureUniqueId}&v=work`} | ||
toCopy={`https://eur.delve.office.com/?u=${user.azureUniqueId}&v=work`} | ||
text="Go to Delve account" | ||
title={`${user.name} Delve account`} | ||
/> | ||
) : ( | ||
isLoading && <Skeleton width={60} style={{ margin: '1rem 0' }} /> | ||
)} | ||
</Style.InfoWrapper> | ||
); | ||
}; |
Oops, something went wrong.