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: add user information side sheet and project refactor #434

Merged
merged 31 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eceb4eb
feat: push changelog
Noggling Oct 10, 2023
16f5ec8
fix: destination-repository-name: "equinor/fusion-project-portal-in…
Noggling Oct 10, 2023
903f06f
chore: user name
Noggling Oct 10, 2023
fe41fc0
chore: try this
Noggling Oct 10, 2023
8621eb0
chore: username
Noggling Oct 10, 2023
fbe19c4
chore: API_TOKEN_GITHUB
Noggling Oct 10, 2023
c93d13d
chore: user Noggling
Noggling Oct 10, 2023
a22dc4f
chore: chbh
Noggling Oct 10, 2023
73228a7
chore: change to push on main and ad bot ar github user
Noggling Oct 19, 2023
2e0bd92
feat: add portal UI project for pure ui components
Noggling Nov 5, 2023
8b5f17e
feat: add portal types project for global types
Noggling Nov 5, 2023
803a9da
chore: remove old avatar, now moved to portal UI
Noggling Nov 5, 2023
72a67a8
feat: portal core. added portal core package.
Noggling Nov 5, 2023
a3e05f8
fear: add components project
Noggling Nov 5, 2023
42122f5
feat: add user information side sheet and top-bar avatar
Noggling Nov 5, 2023
81e4850
feat: added portal utils and move old utils
Noggling Nov 6, 2023
680ccf4
chore: move my account to portal components
Noggling Nov 6, 2023
3c2a17d
chore: fix import for types
Noggling Nov 6, 2023
53fd3e4
Create pretty-onions-teach.md
Noggling Nov 6, 2023
c12754a
Create cyan-snakes-flow.md
Noggling Nov 6, 2023
3446d24
Create dry-beans-cheat.md
Noggling Nov 6, 2023
cd49a04
Create nasty-jokes-wonder.md
Noggling Nov 6, 2023
76627ba
Create beige-rats-admire.md
Noggling Nov 6, 2023
e0a9b4c
chore: create pr-434-1588251794.md
Noggling Nov 6, 2023
34efe46
chore: moved components and added portal url util
Noggling Nov 6, 2023
62b517f
chore: test updates
Noggling Nov 6, 2023
772587a
chore: add @testing-library/jest-dom
Noggling Nov 6, 2023
1c32201
fix: test
Noggling Nov 6, 2023
4845634
doc: lint fix
Noggling Nov 6, 2023
30646d5
chore: fix pr comments
Noggling Nov 6, 2023
48222e5
chore: add unit test and rename file
Noggling Nov 6, 2023
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
7 changes: 7 additions & 0 deletions .changeset/beige-rats-admire.md
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`.

5 changes: 5 additions & 0 deletions .changeset/cyan-snakes-flow.md
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.
7 changes: 7 additions & 0 deletions .changeset/dry-beans-cheat.md
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.

7 changes: 7 additions & 0 deletions .changeset/nasty-jokes-wonder.md
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.

5 changes: 5 additions & 0 deletions .changeset/pr-434-1588251794.md
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.
5 changes: 5 additions & 0 deletions .changeset/pretty-onions-teach.md
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.
6 changes: 4 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"private": true,
"devDependencies": {
"@hirez_io/observer-spy": "^2.2.0",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.0.0",
"@testing-library/react-hooks": "^8.0.1^",
"@types/dompurify": "^3.0.2",
Expand Down Expand Up @@ -71,9 +71,11 @@
"@equinor/fusion-framework-react": "^5.3.2",
"@equinor/fusion-framework-react-app": "^4.1.9",
"@equinor/fusion-framework-react-components-bookmark": "0.2.10",
"@equinor/fusion-framework-react-components-people-provider": "^1.1.2",
"@equinor/fusion-framework-react-module-signalr": "^2.0.10",
"@equinor/fusion-observable": "^8.1.2",
"@equinor/fusion-react-context-selector": "^0.4.9",
"@equinor/fusion-react-person": "^0.6.0",
"@equinor/fusion-react-side-sheet": "1.0.2",
"@equinor/fusion-react-skeleton": "^0.2.14",
"@equinor/fusion-react-styles": "^0.5.11",
Expand All @@ -96,4 +98,4 @@
"workspaces": [
"packages/**"
]
}
}
7 changes: 7 additions & 0 deletions client/packages/components/README.md
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).
8 changes: 8 additions & 0 deletions client/packages/components/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "portal-components",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"build": "tsc"
}
}
100 changes: 100 additions & 0 deletions client/packages/components/src/components/my-account/MyAccount.tsx
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>
);
}
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>
);
};
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>
);
};
Loading
Loading