From 41e85023019bc13c06a1de2c431e0bd920e9e29a Mon Sep 17 00:00:00 2001 From: Sascha Date: Sat, 20 Mar 2021 15:13:10 +0100 Subject: Use profile page for each identity Authorcomponent links to the authors profile page. Replace pofile buglist with statistics --- webui/src/pages/identity/Identity.tsx | 207 +++++++++++++++++++--------------- 1 file changed, 114 insertions(+), 93 deletions(-) (limited to 'webui/src/pages/identity/Identity.tsx') diff --git a/webui/src/pages/identity/Identity.tsx b/webui/src/pages/identity/Identity.tsx index 8261c0f4..5bfc87c0 100644 --- a/webui/src/pages/identity/Identity.tsx +++ b/webui/src/pages/identity/Identity.tsx @@ -1,124 +1,145 @@ import React from 'react'; +import { Link as RouterLink } from 'react-router-dom'; -import { - Checkbox, - FormControlLabel, - Link, - Paper, - Typography, -} from '@material-ui/core'; +import { Link, Paper, Typography } from '@material-ui/core'; import Avatar from '@material-ui/core/Avatar'; +import CircularProgress from '@material-ui/core/CircularProgress'; +import Grid from '@material-ui/core/Grid'; import { makeStyles } from '@material-ui/core/styles'; import InfoIcon from '@material-ui/icons/Info'; import MailOutlineIcon from '@material-ui/icons/MailOutline'; -import { useCurrentIdentityQuery } from '../../components/CurrentIdentity/CurrentIdentity.generated'; +import { IdentityFragment } from '../../components/Identity/IdentityFragment.generated'; -import BugList from './BugList'; +import { useGetUserStatisticQuery } from './GetUserStatistic.generated'; const useStyles = makeStyles((theme) => ({ main: { maxWidth: 1000, margin: 'auto', - marginTop: theme.spacing(4), - padding: theme.spacing(3, 2), - display: 'flex', - }, - container: { - display: 'flex', - marginBottom: theme.spacing(1), - }, - leftSidebar: { - marginTop: theme.spacing(2), - flex: '0 0 200px', + marginTop: theme.spacing(3), }, content: { - marginTop: theme.spacing(5), - padding: theme.spacing(3, 2), - minWidth: 800, - backgroundColor: theme.palette.background.paper, - }, - rightSidebar: { - marginTop: theme.spacing(5), - flex: '0 0 200px', + padding: theme.spacing(0.5, 2, 2, 2), + wordWrap: 'break-word', }, large: { - width: theme.spacing(20), - height: theme.spacing(20), + minWidth: 200, + minHeight: 200, + margin: 'auto', + maxWidth: '100%', + maxHeight: '100%', }, - control: { - paddingBottom: theme.spacing(3), + heading: { + marginTop: theme.spacing(3), }, header: { ...theme.typography.h4, + wordBreak: 'break-word', + }, + infoIcon: { + verticalAlign: 'bottom', }, })); -const Identity = () => { +type Props = { + identity: IdentityFragment; +}; +const Identity = ({ identity }: Props) => { const classes = useStyles(); - const { data } = useCurrentIdentityQuery(); - const user = data?.repository?.userIdentity; - console.log(user); + const user = identity; + + const { loading, error, data } = useGetUserStatisticQuery({ + variables: { + authorQuery: 'author:' + user?.humanId, + participantQuery: 'participant:' + user?.humanId, + actionQuery: 'actor:' + user?.humanId, + }, + }); + + if (loading) return ; + if (error) return

Error: {error}

; + const statistic = data?.repository; + const authoredCount = statistic?.authored?.totalCount; + const participatedCount = statistic?.participated?.totalCount; + const actionCount = statistic?.actions?.totalCount; return (
-
-
-

- {user?.displayName ? user?.displayName : 'none'} -

- - {user?.displayName.charAt(0).toUpperCase()} - - - Your account - - - Name: {user?.name ? user?.name : '---'} - - - Id (truncated): {user?.humanId ? user?.humanId : '---'} - - - - Login: {user?.login ? user?.login : '---'} - - - - - {user?.email ? user?.email : '---'} - - - } - /> -
- - - Bugs authored by {user?.displayName} - - - -
-
+ + + + + {user?.displayName.charAt(0).toUpperCase()} + + + +
+

{user?.name}

+ + Name: {user?.displayName ? user?.displayName : '---'} + + + Id (truncated): {user?.humanId ? user?.humanId : '---'} + + + {user?.email && ( + + + + {user?.email} + + + )} +
+
+ +
+

Statistics

+ + + Created {authoredCount} bugs. + + + + + Participated to {participatedCount} bugs. + + + + + Interacted with {actionCount} bugs. + + +
+
+
+
); }; -- cgit