From 5256da26ea4fa24134763a1c2d7112cd3d505c6e Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Tue, 19 Dec 2023 11:40:17 +0800 Subject: [PATCH] feat(console): add org feature items for comparison table (#5116) --- packages/console/src/consts/plan-quotas.ts | 42 ++++++++++++++++++- .../PlanQuotaKeyLabel/index.tsx | 5 +++ .../renderers/MauUnitPrices.tsx | 1 - .../PlanComparisonTable/renderers/index.tsx | 13 ++++++ .../Subscription/PlanComparisonTable/utils.ts | 10 +++++ packages/console/src/types/subscriptions.ts | 6 +++ 6 files changed, 75 insertions(+), 2 deletions(-) diff --git a/packages/console/src/consts/plan-quotas.ts b/packages/console/src/consts/plan-quotas.ts index f96120fb9..aa4d237a2 100644 --- a/packages/console/src/consts/plan-quotas.ts +++ b/packages/console/src/consts/plan-quotas.ts @@ -87,6 +87,36 @@ export const tokenLimitMap: Record> = { [ReservedPlanId.Pro]: 1_000_000, }; +export const allowedUsersPerOrganizationMap: Record | undefined> = { + [ReservedPlanId.Free]: 0, + [ReservedPlanId.Hobby]: null, + [ReservedPlanId.Pro]: undefined, +}; + +export const invitationEnabledMap: Record = { + [ReservedPlanId.Free]: false, + [ReservedPlanId.Hobby]: true, + [ReservedPlanId.Pro]: undefined, +}; + +export const orgRolesLimitMap: Record | undefined> = { + [ReservedPlanId.Free]: 0, + [ReservedPlanId.Hobby]: null, + [ReservedPlanId.Pro]: undefined, +}; + +export const orgPermissionsLimitMap: Record | undefined> = { + [ReservedPlanId.Free]: 0, + [ReservedPlanId.Hobby]: null, + [ReservedPlanId.Pro]: undefined, +}; + +export const justInTimeProvisioningEnabledMap: Record = { + [ReservedPlanId.Free]: false, + [ReservedPlanId.Hobby]: true, + [ReservedPlanId.Pro]: undefined, +}; + /** * Note: this is only for display purpose. * @@ -169,7 +199,17 @@ export const planTableGroupKeyMap: SubscriptionPlanTableGroupKeyMap = Object.fre 'rolesLimit', 'scopesPerRoleLimit', ], - [SubscriptionPlanTableGroupKey.organizations]: ['organizationsEnabled'], + [SubscriptionPlanTableGroupKey.organizations]: [ + 'organizationsEnabled', + // Todo @xiaoyijun [Pricing] Remove feature flag + ...condArray( + isDevelopmentFeaturesEnabled && 'allowedUsersPerOrganization', + isDevelopmentFeaturesEnabled && 'invitationEnabled', + isDevelopmentFeaturesEnabled && 'orgRolesLimit', + isDevelopmentFeaturesEnabled && 'orgPermissionsLimit', + isDevelopmentFeaturesEnabled && 'justInTimeProvisioningEnabled' + ), + ], [SubscriptionPlanTableGroupKey.auditLogs]: ['auditLogsRetentionDays'], [SubscriptionPlanTableGroupKey.hooks]: ['hooksLimit'], [SubscriptionPlanTableGroupKey.support]: ['communitySupportEnabled', 'ticketSupportResponseTime'], diff --git a/packages/console/src/pages/TenantSettings/Subscription/PlanComparisonTable/PlanQuotaKeyLabel/index.tsx b/packages/console/src/pages/TenantSettings/Subscription/PlanComparisonTable/PlanQuotaKeyLabel/index.tsx index 4f8b543c7..13b9f5bbd 100644 --- a/packages/console/src/pages/TenantSettings/Subscription/PlanComparisonTable/PlanQuotaKeyLabel/index.tsx +++ b/packages/console/src/pages/TenantSettings/Subscription/PlanComparisonTable/PlanQuotaKeyLabel/index.tsx @@ -48,6 +48,11 @@ const planQuotaKeyPhraseMap: { organizationsEnabled: isDevFeaturesEnabled ? 'organizations.monthly_active_organization' : 'organizations.organizations', + allowedUsersPerOrganization: 'organizations.allowed_users_per_org', + invitationEnabled: 'organizations.invitation', + orgRolesLimit: 'organizations.org_roles', + orgPermissionsLimit: 'organizations.org_permissions', + justInTimeProvisioningEnabled: 'organizations.just_in_time_provisioning', }; type Props = { diff --git a/packages/console/src/pages/TenantSettings/Subscription/PlanComparisonTable/renderers/MauUnitPrices.tsx b/packages/console/src/pages/TenantSettings/Subscription/PlanComparisonTable/renderers/MauUnitPrices.tsx index ebdf06d77..f4e3b4a60 100644 --- a/packages/console/src/pages/TenantSettings/Subscription/PlanComparisonTable/renderers/MauUnitPrices.tsx +++ b/packages/console/src/pages/TenantSettings/Subscription/PlanComparisonTable/renderers/MauUnitPrices.tsx @@ -11,7 +11,6 @@ type Props = { * TODO: @xiaoyijun [Pricing] Remove the unit price after the new pricing feature is ready. */ function MauUnitPrices({ prices }: Props) { - console.log(prices); if (prices === undefined) { return ; } diff --git a/packages/console/src/pages/TenantSettings/Subscription/PlanComparisonTable/renderers/index.tsx b/packages/console/src/pages/TenantSettings/Subscription/PlanComparisonTable/renderers/index.tsx index 012bbc507..8cdd5c3b4 100644 --- a/packages/console/src/pages/TenantSettings/Subscription/PlanComparisonTable/renderers/index.tsx +++ b/packages/console/src/pages/TenantSettings/Subscription/PlanComparisonTable/renderers/index.tsx @@ -132,6 +132,19 @@ export const quotaValueRenderer: Record< paymentType="usage" /> ), + allowedUsersPerOrganization: ({ table: { allowedUsersPerOrganization } }) => ( + + ), + invitationEnabled: ({ table: { invitationEnabled } }) => ( + + ), + orgRolesLimit: ({ table: { orgRolesLimit } }) => , + orgPermissionsLimit: ({ table: { orgPermissionsLimit } }) => ( + + ), + justInTimeProvisioningEnabled: ({ table: { justInTimeProvisioningEnabled } }) => ( + + ), // Audit logs auditLogsRetentionDays: ({ table: { auditLogsRetentionDays } }) => ( ; + invitationEnabled: boolean; + orgRolesLimit: Nullable; + orgPermissionsLimit: Nullable; + justInTimeProvisioningEnabled: boolean; } >;