aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/layout/ReadonlyHidden.tsx
diff options
context:
space:
mode:
authorLuke Granger-Brown <git@lukegb.com>2020-06-18 02:52:33 +0100
committerMichael Muré <batolettre@gmail.com>2020-06-27 22:56:10 +0200
commit4a28f25347addf05708cdff37ecace4139f01779 (patch)
tree145e5fd420f70b182d66a5824d76300b5307d509 /webui/src/layout/ReadonlyHidden.tsx
parent23228101a2a38a139f6fc2cafc18e9f08d911089 (diff)
downloadgit-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.tsx19
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;