aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/layout/ReadonlyHidden.tsx
blob: 9ed0af6acc625352924d4340b55c04868218a73e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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;