diff options
author | Luke Granger-Brown <git@lukegb.com> | 2020-06-18 02:52:33 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-06-27 22:56:10 +0200 |
commit | 4a28f25347addf05708cdff37ecace4139f01779 (patch) | |
tree | 145e5fd420f70b182d66a5824d76300b5307d509 /webui/src/layout/CurrentIdentity.tsx | |
parent | 23228101a2a38a139f6fc2cafc18e9f08d911089 (diff) | |
download | git-bug-4a28f25347addf05708cdff37ecace4139f01779.tar.gz |
Add support for read-only mode for web UI.
Fixes #402.
Diffstat (limited to 'webui/src/layout/CurrentIdentity.tsx')
-rw-r--r-- | webui/src/layout/CurrentIdentity.tsx | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/webui/src/layout/CurrentIdentity.tsx b/webui/src/layout/CurrentIdentity.tsx index 21f489ef..55060179 100644 --- a/webui/src/layout/CurrentIdentity.tsx +++ b/webui/src/layout/CurrentIdentity.tsx @@ -3,7 +3,7 @@ import React from 'react'; import Avatar from '@material-ui/core/Avatar'; import { makeStyles } from '@material-ui/core/styles'; -import { useCurrentIdentityQuery } from './CurrentIdentity.generated'; +import CurrentIdentityContext from './CurrentIdentityContext'; const useStyles = makeStyles(theme => ({ displayName: { @@ -13,18 +13,26 @@ const useStyles = makeStyles(theme => ({ const CurrentIdentity = () => { const classes = useStyles(); - const { loading, error, data } = useCurrentIdentityQuery(); - if (error || loading || !data?.repository?.userIdentity) return null; - - const user = data.repository.userIdentity; return ( - <> - <Avatar src={user.avatarUrl ? user.avatarUrl : undefined}> - {user.displayName.charAt(0).toUpperCase()} - </Avatar> - <div className={classes.displayName}>{user.displayName}</div> - </> + <CurrentIdentityContext.Consumer> + {context => { + if (!context) return null; + const { loading, error, data } = context as any; + + if (error || loading || !data?.repository?.userIdentity) return null; + + const user = data.repository.userIdentity; + return ( + <> + <Avatar src={user.avatarUrl ? user.avatarUrl : undefined}> + {user.displayName.charAt(0).toUpperCase()} + </Avatar> + <div className={classes.displayName}>{user.displayName}</div> + </> + ); + }} + </CurrentIdentityContext.Consumer> ); }; |