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/bug/LabelChange.tsx | 8 +- webui/src/pages/bug/Message.tsx | 1 + webui/src/pages/bug/SetStatus.tsx | 8 +- webui/src/pages/bug/SetTitle.tsx | 8 +- webui/src/pages/identity/BugList.tsx | 4 +- webui/src/pages/identity/GetUserStatistic.graphql | 13 ++ webui/src/pages/identity/Identity.tsx | 207 ++++++++++++---------- webui/src/pages/identity/IdentityQuery.tsx | 24 +++ webui/src/pages/identity/index.tsx | 1 + webui/src/pages/list/BugRow.tsx | 4 +- webui/src/pages/list/ListQuery.tsx | 2 +- 11 files changed, 175 insertions(+), 105 deletions(-) create mode 100644 webui/src/pages/identity/GetUserStatistic.graphql create mode 100644 webui/src/pages/identity/IdentityQuery.tsx create mode 100644 webui/src/pages/identity/index.tsx (limited to 'webui/src/pages') diff --git a/webui/src/pages/bug/LabelChange.tsx b/webui/src/pages/bug/LabelChange.tsx index 712c33fa..868d8c9b 100644 --- a/webui/src/pages/bug/LabelChange.tsx +++ b/webui/src/pages/bug/LabelChange.tsx @@ -1,5 +1,6 @@ import React from 'react'; +import { Typography } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; import Author from 'src/components/Author'; @@ -10,11 +11,12 @@ import { LabelChangeFragment } from './LabelChangeFragment.generated'; const useStyles = makeStyles((theme) => ({ main: { - ...theme.typography.body2, + color: theme.palette.text.secondary, marginLeft: theme.spacing(1) + 40, }, author: { fontWeight: 'bold', + color: theme.palette.text.secondary, }, label: { maxWidth: '50ch', @@ -31,7 +33,7 @@ function LabelChange({ op }: Props) { const { added, removed } = op; const classes = useStyles(); return ( -
+ {added.length > 0 && added the } {added.map((label, index) => ( @@ -48,7 +50,7 @@ function LabelChange({ op }: Props) { {added.length + removed.length > 1 && 's'}{' '} -
+ ); } diff --git a/webui/src/pages/bug/Message.tsx b/webui/src/pages/bug/Message.tsx index 39b11ccd..808bb525 100644 --- a/webui/src/pages/bug/Message.tsx +++ b/webui/src/pages/bug/Message.tsx @@ -21,6 +21,7 @@ import MessageHistoryDialog from './MessageHistoryDialog'; const useStyles = makeStyles((theme) => ({ author: { fontWeight: 'bold', + color: theme.palette.info.contrastText, }, container: { display: 'flex', diff --git a/webui/src/pages/bug/SetStatus.tsx b/webui/src/pages/bug/SetStatus.tsx index 855848f9..f231b917 100644 --- a/webui/src/pages/bug/SetStatus.tsx +++ b/webui/src/pages/bug/SetStatus.tsx @@ -1,5 +1,6 @@ import React from 'react'; +import { Typography } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; import { Status } from '../../gqlTypes'; @@ -10,11 +11,12 @@ import { SetStatusFragment } from './SetStatusFragment.generated'; const useStyles = makeStyles((theme) => ({ main: { - ...theme.typography.body2, + color: theme.palette.text.secondary, marginLeft: theme.spacing(1) + 40, }, author: { fontWeight: 'bold', + color: theme.palette.text.secondary, }, })); @@ -29,11 +31,11 @@ function SetStatus({ op }: Props) { ]; return ( -
+ {status} this -
+ ); } diff --git a/webui/src/pages/bug/SetTitle.tsx b/webui/src/pages/bug/SetTitle.tsx index 98bea928..057062f7 100644 --- a/webui/src/pages/bug/SetTitle.tsx +++ b/webui/src/pages/bug/SetTitle.tsx @@ -1,5 +1,6 @@ import React from 'react'; +import { Typography } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; import Author from 'src/components/Author'; @@ -9,11 +10,12 @@ import { SetTitleFragment } from './SetTitleFragment.generated'; const useStyles = makeStyles((theme) => ({ main: { - ...theme.typography.body2, + color: theme.palette.text.secondary, marginLeft: theme.spacing(1) + 40, }, author: { fontWeight: 'bold', + color: theme.palette.text.secondary, }, before: { fontWeight: 'bold', @@ -31,14 +33,14 @@ type Props = { function SetTitle({ op }: Props) { const classes = useStyles(); return ( -
+ changed the title from {op.was} to {op.title}  -
+ ); } diff --git a/webui/src/pages/identity/BugList.tsx b/webui/src/pages/identity/BugList.tsx index e74c11d4..c7994827 100644 --- a/webui/src/pages/identity/BugList.tsx +++ b/webui/src/pages/identity/BugList.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { Card, Link, Typography } from '@material-ui/core'; +import { Card, Divider, Link, Typography } from '@material-ui/core'; import CircularProgress from '@material-ui/core/CircularProgress'; import { makeStyles } from '@material-ui/core/styles'; @@ -53,6 +53,7 @@ function BugList({ humanId }: Props) { {bug.title} + Created  @@ -64,6 +65,7 @@ function BugList({ humanId }: Props) { ); })} + {bugs?.length === 0 &&

No authored bugs by this user found.

} ); } diff --git a/webui/src/pages/identity/GetUserStatistic.graphql b/webui/src/pages/identity/GetUserStatistic.graphql new file mode 100644 index 00000000..318b860d --- /dev/null +++ b/webui/src/pages/identity/GetUserStatistic.graphql @@ -0,0 +1,13 @@ +query GetUserStatistic($authorQuery: String!, $participantQuery: String!, $actionQuery: String!) { + repository { + authored: allBugs(query: $authorQuery) { + totalCount + }, + participated: allBugs(query: $participantQuery) { + totalCount + } + actions: allBugs(query: $actionQuery) { + totalCount + } + } +} 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. + + +
+
+
+
); }; diff --git a/webui/src/pages/identity/IdentityQuery.tsx b/webui/src/pages/identity/IdentityQuery.tsx new file mode 100644 index 00000000..964a9bac --- /dev/null +++ b/webui/src/pages/identity/IdentityQuery.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { RouteComponentProps } from 'react-router-dom'; + +import CircularProgress from '@material-ui/core/CircularProgress'; + +import { useGetUserByIdQuery } from '../../components/Identity/UserIdentity.generated'; + +import Identity from './Identity'; + +type Props = RouteComponentProps<{ + id: string; +}>; + +const UserQuery: React.FC = ({ match }: Props) => { + const { loading, error, data } = useGetUserByIdQuery({ + variables: { userId: match.params.id }, + }); + if (loading) return ; + if (error) return

Error: {error}

; + if (!data?.repository?.identity) return

404.

; + return ; +}; + +export default UserQuery; diff --git a/webui/src/pages/identity/index.tsx b/webui/src/pages/identity/index.tsx new file mode 100644 index 00000000..06208687 --- /dev/null +++ b/webui/src/pages/identity/index.tsx @@ -0,0 +1 @@ +export { default } from './IdentityQuery'; diff --git a/webui/src/pages/list/BugRow.tsx b/webui/src/pages/list/BugRow.tsx index 87e45581..a1466d63 100644 --- a/webui/src/pages/list/BugRow.tsx +++ b/webui/src/pages/list/BugRow.tsx @@ -9,6 +9,7 @@ import CheckCircleOutline from '@material-ui/icons/CheckCircleOutline'; import CommentOutlinedIcon from '@material-ui/icons/CommentOutlined'; import ErrorOutline from '@material-ui/icons/ErrorOutline'; +import Author from 'src/components/Author'; import Date from 'src/components/Date'; import Label from 'src/components/Label'; import { Status } from 'src/gqlTypes'; @@ -117,7 +118,8 @@ function BugRow({ bug }: Props) {
{bug.humanId} opened  -  by {bug.author.displayName} +  by  +
diff --git a/webui/src/pages/list/ListQuery.tsx b/webui/src/pages/list/ListQuery.tsx index 2b46dca5..9aefd02d 100644 --- a/webui/src/pages/list/ListQuery.tsx +++ b/webui/src/pages/list/ListQuery.tsx @@ -14,7 +14,7 @@ import KeyboardArrowLeft from '@material-ui/icons/KeyboardArrowLeft'; import KeyboardArrowRight from '@material-ui/icons/KeyboardArrowRight'; import Skeleton from '@material-ui/lab/Skeleton'; -import { useCurrentIdentityQuery } from '../../components/CurrentIdentity/CurrentIdentity.generated'; +import { useCurrentIdentityQuery } from '../../components/Identity/CurrentIdentity.generated'; import IfLoggedIn from 'src/components/IfLoggedIn/IfLoggedIn'; import { parse, Query, stringify } from './Filter'; -- cgit