Patch subscription plan frontend validation

This commit is contained in:
Tuan Dang
2023-06-12 17:47:32 +01:00
parent 342ee50063
commit 98efffafaa
6 changed files with 44 additions and 33 deletions
@@ -96,6 +96,13 @@ class EELicenseService {
return this.globalFeatureSet; return this.globalFeatureSet;
} }
public async refreshOrganizationPlan(organizationId: string) {
if (this.instanceType === 'cloud') {
this.localFeatureSet.del(organizationId);
await this.getOrganizationPlan(organizationId);
}
}
public async initGlobalFeatureSet() { public async initGlobalFeatureSet() {
const licenseServerKey = await getLicenseServerKey(); const licenseServerKey = await getLicenseServerKey();
const licenseKey = await getLicenseKey(); const licenseKey = await getLicenseKey();
+3 -1
View File
@@ -153,6 +153,7 @@ export const updateSubscriptionOrgQuantity = async ({
EELicenseService.localFeatureSet.del(organizationId); EELicenseService.localFeatureSet.del(organizationId);
} }
}
if (EELicenseService.instanceType === 'enterprise-self-hosted') { if (EELicenseService.instanceType === 'enterprise-self-hosted') {
// instance of Infisical is an enterprise self-hosted instance // instance of Infisical is an enterprise self-hosted instance
@@ -168,7 +169,8 @@ export const updateSubscriptionOrgQuantity = async ({
} }
); );
} }
}
await EELicenseService.refreshOrganizationPlan(organizationId);
return stripeSubscription; return stripeSubscription;
}; };
+2
View File
@@ -6,6 +6,7 @@ import {
Secret Secret
} from '../models'; } from '../models';
import { createBot } from '../helpers/bot'; import { createBot } from '../helpers/bot';
import { EELicenseService } from '../ee/services';
import { SecretService } from '../services'; import { SecretService } from '../services';
/** /**
@@ -40,6 +41,7 @@ export const createWorkspace = async ({
workspaceId: workspace._id workspaceId: workspace._id
}); });
await EELicenseService.refreshOrganizationPlan(organizationId);
return workspace; return workspace;
}; };
@@ -1,7 +1,7 @@
export type SubscriptionPlan = { export type SubscriptionPlan = {
_id: string; _id: string;
membersUsed: number; membersUsed: number;
membersLimit: number; memberLimit: number;
auditLogs: boolean; auditLogs: boolean;
customAlerts: boolean; customAlerts: boolean;
customRateLimits: boolean; customRateLimits: boolean;
+1 -1
View File
@@ -61,7 +61,7 @@ export const AppLayout = ({ children }: LayoutProps) => {
const { subscription } = useSubscription(); const { subscription } = useSubscription();
const host = window.location.origin; const host = window.location.origin;
const isAddingProjectsAllowed = ((subscription?.workspacesUsed || 1) < (subscription?.workspaceLimit || 3)) || host !== 'https://app.infisical.com'; const isAddingProjectsAllowed = subscription?.workspaceLimit ? (subscription.workspacesUsed < subscription.workspaceLimit) : true;
const createWs = useCreateWorkspace(); const createWs = useCreateWorkspace();
const uploadWsKey = useUploadWsKey(); const uploadWsKey = useUploadWsKey();
@@ -60,7 +60,7 @@ export const OrgSettingsPage = () => {
const [completeInviteLink, setcompleteInviteLink] = useState<string | undefined>(''); const [completeInviteLink, setcompleteInviteLink] = useState<string | undefined>('');
const isMoreUsersNotAllowed = ((subscription?.membersUsed || 0) >= (subscription?.membersLimit || 1)) && host === 'https://app.infisical.com'; const isMoreUsersNotAllowed = subscription?.memberLimit ? (subscription.membersUsed >= subscription.memberLimit) : false;
const onRenameOrg = async (name: string) => { const onRenameOrg = async (name: string) => {
if (!currentOrg?._id) return; if (!currentOrg?._id) return;