Jelajahi Sumber

add 0 case for usage middleware

Alexander Belanger 4 tahun lalu
induk
melakukan
1ee266fc54

+ 3 - 3
api/server/router/middleware/usage.go

@@ -73,9 +73,9 @@ func allowUsage(
 ) bool {
 ) bool {
 	switch metric {
 	switch metric {
 	case types.Users:
 	case types.Users:
-		return plan.Users > current.Users+1
+		return plan.Users == 0 || plan.Users > current.Users+1
 	case types.Clusters:
 	case types.Clusters:
-		return plan.Clusters > current.Clusters+1
+		return plan.Clusters == 0 || plan.Clusters > current.Clusters+1
 	default:
 	default:
 		return false
 		return false
 	}
 	}
@@ -93,7 +93,7 @@ func getMetricUsage(
 	case types.Users:
 	case types.Users:
 		return plan.Users, current.Users
 		return plan.Users, current.Users
 	case types.Clusters:
 	case types.Clusters:
-		return plan.Users, current.Users
+		return plan.Clusters, current.Clusters
 	default:
 	default:
 		return 0, 0
 		return 0, 0
 	}
 	}

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

@@ -365,12 +365,6 @@ const InvitePage: React.FunctionComponent<Props> = ({}) => {
     return mappedInviteList || [];
     return mappedInviteList || [];
   }, [invites, currentProject?.id, window?.location?.host, isHTTPS, user?.id]);
   }, [invites, currentProject?.id, window?.location?.host, isHTTPS, user?.id]);
 
 
-  const hasSeats = () => {
-    // TODO: if usage limit is 0, the project has unlimited seats. Otherwise, check
-    // the usage limit against the current usage. 
-    return true
-  }
-
   const hasSeats = () => {
   const hasSeats = () => {
     // If usage limit is 0, the project has unlimited seats. Otherwise, check
     // If usage limit is 0, the project has unlimited seats. Otherwise, check
     // the usage limit against the current usage.
     // the usage limit against the current usage.