Procházet zdrojové kódy

Removed console and added loading to route guards

jnfrati před 4 roky
rodič
revize
112dc8b651

+ 3 - 6
dashboard/src/main/home/project-settings/InviteList.tsx

@@ -176,7 +176,6 @@ const InvitePage: React.FunctionComponent<Props> = ({}) => {
 
   const openEditModal = (user: any) => {
     if (setCurrentModal) {
-      console.log(user);
       setCurrentModal("EditInviteOrCollaboratorModal", {
         user,
         isInvite: user.status !== "accepted",
@@ -216,9 +215,7 @@ const InvitePage: React.FunctionComponent<Props> = ({}) => {
         Header: "Role",
         accessor: "kind",
         Cell: ({ row }) => {
-          return (
-            <Role>{row.values.kind || "Admin"}</Role>
-          );
+          return <Role>{row.values.kind || "Admin"}</Role>;
         },
       },
       {
@@ -325,7 +322,6 @@ const InvitePage: React.FunctionComponent<Props> = ({}) => {
     const mappedInviteList = inviteList.map(
       ({ accepted, expired, token, ...rest }) => {
         const currentUser: boolean = user.email === rest.email;
-        console.log(currentUser, user, rest);
         if (accepted) {
           return {
             status: "accepted",
@@ -420,7 +416,8 @@ const Flex = styled.div`
 
 const DeleteButton = styled.div`
   display: flex;
-  visibility: ${(props: { invis?: boolean }) => props.invis ? "hidden" : "visible"};
+  visibility: ${(props: { invis?: boolean }) =>
+    props.invis ? "hidden" : "visible"};
   align-items: center;
   justify-content: center;
   width: 30px;

+ 0 - 1
dashboard/src/shared/auth/AuthContext.tsx

@@ -26,7 +26,6 @@ const AuthProvider: React.FC = ({ children }) => {
             return;
           }
           const currentPolicy = res.data[0];
-          console.log(currentPolicy);
           setCurrentPolicy(
             populatePolicy(
               currentPolicy,

+ 6 - 0
dashboard/src/shared/auth/RouteGuard.tsx

@@ -25,6 +25,9 @@ const GuardedRoute: React.FC<RouteProps & GuardedRouteProps> = ({
   }, [currentPolicy, scope, resource, verb]);
 
   const render = (props: any) => {
+    if (!currentPolicy) {
+      return <div> Loading </div>;
+    }
     if (auth) {
       return children || <Component {...props} />;
     }
@@ -44,6 +47,9 @@ export const fakeGuardedRoute = <ComponentProps extends object>(
     return isAuthorized(currentPolicy, scope, resource, verb);
   }, [currentPolicy, scope, resource, verb]);
 
+  if (!currentPolicy) {
+    return <div>"loading"</div>;
+  }
   if (auth) {
     return <Component {...props} />;
   }