From 4a28f25347addf05708cdff37ecace4139f01779 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Thu, 18 Jun 2020 02:52:33 +0100 Subject: Add support for read-only mode for web UI. Fixes #402. --- webui/src/layout/ReadonlyHidden.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 webui/src/layout/ReadonlyHidden.tsx (limited to 'webui/src/layout/ReadonlyHidden.tsx') 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) => ( + + {context => { + if (!context) return null; + const { loading, error, data } = context; + + if (error || loading || !data?.repository?.userIdentity) return null; + + return <>{children}; + }} + +); + +export default ReadonlyHidden; -- cgit