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 --- .../components/Identity/CurrentIdentity.graphql | 9 ++ webui/src/components/Identity/CurrentIdentity.tsx | 114 +++++++++++++++++++++ .../components/Identity/IdentityFragment.graphql | 10 ++ webui/src/components/Identity/UserIdentity.graphql | 9 ++ 4 files changed, 142 insertions(+) create mode 100644 webui/src/components/Identity/CurrentIdentity.graphql create mode 100644 webui/src/components/Identity/CurrentIdentity.tsx create mode 100644 webui/src/components/Identity/IdentityFragment.graphql create mode 100644 webui/src/components/Identity/UserIdentity.graphql (limited to 'webui/src/components/Identity') diff --git a/webui/src/components/Identity/CurrentIdentity.graphql b/webui/src/components/Identity/CurrentIdentity.graphql new file mode 100644 index 00000000..054190df --- /dev/null +++ b/webui/src/components/Identity/CurrentIdentity.graphql @@ -0,0 +1,9 @@ +#import "./IdentityFragment.graphql" + +query CurrentIdentity { + repository { + userIdentity { + ...Identity + } + } +} diff --git a/webui/src/components/Identity/CurrentIdentity.tsx b/webui/src/components/Identity/CurrentIdentity.tsx new file mode 100644 index 00000000..1fd424c1 --- /dev/null +++ b/webui/src/components/Identity/CurrentIdentity.tsx @@ -0,0 +1,114 @@ +import React from 'react'; +import { Link as RouterLink } from 'react-router-dom'; + +import { + Button, + ClickAwayListener, + Grow, + Link, + MenuItem, + MenuList, + Paper, + Popper, +} from '@material-ui/core'; +import Avatar from '@material-ui/core/Avatar'; +import { makeStyles } from '@material-ui/core/styles'; +import LockIcon from '@material-ui/icons/Lock'; + +import { useCurrentIdentityQuery } from './CurrentIdentity.generated'; + +const useStyles = makeStyles((theme) => ({ + displayName: { + marginLeft: theme.spacing(2), + }, + hidden: { + display: 'none', + }, + profileLink: { + ...theme.typography.button, + }, + popupButton: { + textTransform: 'none', + color: theme.palette.primary.contrastText, + }, +})); + +const CurrentIdentity = () => { + const classes = useStyles(); + const { loading, error, data } = useCurrentIdentityQuery(); + + const [open, setOpen] = React.useState(false); + const anchorRef = React.useRef(null); + + if (error || loading || !data?.repository?.userIdentity) return null; + + const user = data.repository.userIdentity; + + const handleToggle = () => { + setOpen((prevOpen) => !prevOpen); + }; + + const handleClose = (event: any) => { + if (anchorRef.current && anchorRef.current.contains(event.target)) { + return; + } + setOpen(false); + }; + + return ( + <> + + + {({ TransitionProps, placement }) => ( + + + + + + + Open profile + + + + + + + )} + + + ); +}; + +export default CurrentIdentity; diff --git a/webui/src/components/Identity/IdentityFragment.graphql b/webui/src/components/Identity/IdentityFragment.graphql new file mode 100644 index 00000000..6c4e2483 --- /dev/null +++ b/webui/src/components/Identity/IdentityFragment.graphql @@ -0,0 +1,10 @@ +fragment Identity on Identity { + id + humanId + displayName + email + name + avatarUrl + isProtected + login +} diff --git a/webui/src/components/Identity/UserIdentity.graphql b/webui/src/components/Identity/UserIdentity.graphql new file mode 100644 index 00000000..9cf10248 --- /dev/null +++ b/webui/src/components/Identity/UserIdentity.graphql @@ -0,0 +1,9 @@ +#import "./IdentityFragment.graphql" + +query GetUserById($userId: String!) { + repository { + identity(prefix: $userId) { + ...Identity + } + } +} -- cgit From 774bae6d432c13cfa0de3ddc2f111927743243fe Mon Sep 17 00:00:00 2001 From: Sascha Date: Thu, 22 Apr 2021 14:02:43 +0200 Subject: Replace occurrences of humanId with the full Id Unless an ID must be shorted for user convenience, the full id should be used to prevent collisions. --- webui/src/components/Identity/CurrentIdentity.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webui/src/components/Identity') diff --git a/webui/src/components/Identity/CurrentIdentity.tsx b/webui/src/components/Identity/CurrentIdentity.tsx index 1fd424c1..2d62dcdb 100644 --- a/webui/src/components/Identity/CurrentIdentity.tsx +++ b/webui/src/components/Identity/CurrentIdentity.tsx @@ -96,7 +96,7 @@ const CurrentIdentity = () => { color="inherit" className={classes.profileLink} component={RouterLink} - to={`/user/${user.humanId}`} + to={`/user/${user.id}`} > Open profile -- cgit