Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(console): temporarily fix pro plan cannot invite members issue #5629

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@
function InviteMemberModal({ isOpen, onClose }: Props) {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.tenant_members' });
const { currentPlan } = useContext(SubscriptionDataContext);
const { currentTenantId, isDevTenant } = useContext(TenantsContext);
const tenantMembersMaxLimit = useMemo(() => {
if (currentPlan.id === ReservedPlanId.Pro || isDevTenant) {
return 10;
}
// Free plan can only have 1 admin, no other members allowed.
return 1;
}, [currentPlan.id, isDevTenant]);
const { currentTenantId } = useContext(TenantsContext);
// TODO: @charles update with actual quota guard later

Check warning on line 30 in packages/console/src/pages/TenantSettings/TenantMembers/InviteMemberModal/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/console/src/pages/TenantSettings/TenantMembers/InviteMemberModal/index.tsx#L30

[no-warning-comments] Unexpected 'todo' comment: 'TODO: @charles update with actual quota...'.
const tenantMembersMaxLimit = currentPlan.id === ReservedPlanId.Free ? 1 : 3;

const [isLoading, setIsLoading] = useState(false);
const cloudApi = useAuthedCloudApi();
Expand Down Expand Up @@ -71,17 +66,20 @@
const onSubmit = handleSubmit(async ({ emails, role }) => {
setIsLoading(true);
try {
// Count the current tenant members
const members = await cloudApi.get(`/api/tenants/:tenantId/members`, {
params: { tenantId: currentTenantId },
});
// Check if it will exceed the tenant member limit
if (emails.length + members.length > tenantMembersMaxLimit) {
setError('emails', {
type: 'custom',
message: t('errors.max_member_limit', { limit: tenantMembersMaxLimit }),
// Do not check seats for Pro plan for now
if (currentPlan.id === ReservedPlanId.Free || currentPlan.id === ReservedPlanId.Development) {
// Count the current tenant members
const members = await cloudApi.get(`/api/tenants/:tenantId/members`, {
params: { tenantId: currentTenantId },
});
return;
// Check if it will exceed the tenant member limit
if (emails.length + members.length > tenantMembersMaxLimit) {
setError('emails', {
type: 'custom',
message: t('errors.max_member_limit', { limit: tenantMembersMaxLimit }),
});
return;
}
}

await Promise.all(
Expand Down