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/ReadonlyHidden.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/ReadonlyHidden.tsx')
-rw-r--r-- | webui/src/layout/ReadonlyHidden.tsx | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/webui/src/layout/ReadonlyHidden.tsx b/webui/src/layout/ReadonlyHidden.tsx new file mode 100644 index 00000000..9ed0af6a --- /dev/null +++ b/webui/src/layout/ReadonlyHidden.tsx @@ -0,0 +1,19 @@ +import React from 'react'; + +import CurrentIdentityContext from './CurrentIdentityContext'; + +type Props = { children: React.ReactNode }; +const ReadonlyHidden = ({ children }: Props) => ( + <CurrentIdentityContext.Consumer> + {context => { + if (!context) return null; + const { loading, error, data } = context; + + if (error || loading || !data?.repository?.userIdentity) return null; + + return <>{children}</>; + }} + </CurrentIdentityContext.Consumer> +); + +export default ReadonlyHidden; |