0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

feat(console): add org feature items for comparison table (#5116)

This commit is contained in:
Xiao Yijun 2023-12-19 11:40:17 +08:00 committed by GitHub
parent a5ef0d014e
commit 5256da26ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 75 additions and 2 deletions

View file

@ -87,6 +87,36 @@ export const tokenLimitMap: Record<string, Nullable<number>> = {
[ReservedPlanId.Pro]: 1_000_000,
};
export const allowedUsersPerOrganizationMap: Record<string, Nullable<number> | undefined> = {
[ReservedPlanId.Free]: 0,
[ReservedPlanId.Hobby]: null,
[ReservedPlanId.Pro]: undefined,
};
export const invitationEnabledMap: Record<string, boolean | undefined> = {
[ReservedPlanId.Free]: false,
[ReservedPlanId.Hobby]: true,
[ReservedPlanId.Pro]: undefined,
};
export const orgRolesLimitMap: Record<string, Nullable<number> | undefined> = {
[ReservedPlanId.Free]: 0,
[ReservedPlanId.Hobby]: null,
[ReservedPlanId.Pro]: undefined,
};
export const orgPermissionsLimitMap: Record<string, Nullable<number> | undefined> = {
[ReservedPlanId.Free]: 0,
[ReservedPlanId.Hobby]: null,
[ReservedPlanId.Pro]: undefined,
};
export const justInTimeProvisioningEnabledMap: Record<string, boolean | undefined> = {
[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'],

View file

@ -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 = {

View file

@ -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 <DynamicT forKey="subscription.quota_table.contact" />;
}

View file

@ -132,6 +132,19 @@ export const quotaValueRenderer: Record<
paymentType="usage"
/>
),
allowedUsersPerOrganization: ({ table: { allowedUsersPerOrganization } }) => (
<GenericQuotaLimit quota={allowedUsersPerOrganization} />
),
invitationEnabled: ({ table: { invitationEnabled } }) => (
<GenericFeatureFlag isEnabled={invitationEnabled} />
),
orgRolesLimit: ({ table: { orgRolesLimit } }) => <GenericQuotaLimit quota={orgRolesLimit} />,
orgPermissionsLimit: ({ table: { orgPermissionsLimit } }) => (
<GenericQuotaLimit quota={orgPermissionsLimit} />
),
justInTimeProvisioningEnabled: ({ table: { justInTimeProvisioningEnabled } }) => (
<GenericFeatureFlag isEnabled={justInTimeProvisioningEnabled} />
),
// Audit logs
auditLogsRetentionDays: ({ table: { auditLogsRetentionDays } }) => (
<GenericQuotaLimit

View file

@ -1,11 +1,16 @@
import { conditional, conditionalString } from '@silverhand/essentials';
import {
allowedUsersPerOrganizationMap,
appLogoAndFaviconEnabledMap,
customCssEnabledMap,
darkModeEnabledMap,
emailConnectorsEnabledMap,
i18nEnabledMap,
invitationEnabledMap,
justInTimeProvisioningEnabledMap,
orgPermissionsLimitMap,
orgRolesLimitMap,
passwordSignInEnabledMap,
passwordlessSignInEnabledMap,
smsConnectorsEnabledMap,
@ -48,6 +53,11 @@ export const constructPlanTableDataArray = (
smsConnectorsEnabled: smsConnectorsEnabledMap[id],
userManagementEnabled: userManagementEnabledMap[id],
tokenLimit: tokenLimitMap[id],
allowedUsersPerOrganization: allowedUsersPerOrganizationMap[id],
invitationEnabled: invitationEnabledMap[id],
orgRolesLimit: orgRolesLimitMap[id],
orgPermissionsLimit: orgPermissionsLimitMap[id],
justInTimeProvisioningEnabled: justInTimeProvisioningEnabledMap[id],
},
};
});

View file

@ -49,6 +49,12 @@ export type SubscriptionPlanTable = Partial<
smsConnectorsEnabled: boolean;
// User management
userManagementEnabled: boolean;
// Organization
allowedUsersPerOrganization: Nullable<number>;
invitationEnabled: boolean;
orgRolesLimit: Nullable<number>;
orgPermissionsLimit: Nullable<number>;
justInTimeProvisioningEnabled: boolean;
}
>;