aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/layout/ReadonlyHidden.tsx
diff options
context:
space:
mode:
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;