0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(console): fix console resource usage tooltip (#6628)

This commit is contained in:
Darcy Ye 2024-09-24 19:01:02 +08:00 committed by GitHub
parent eccba56481
commit 5a522226d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 46 additions and 27 deletions

View file

@ -104,12 +104,14 @@ function PlanUsage({ periodicUsage: rawPeriodicUsage }: Props) {
isEnterprisePlan || isEnterprisePlan ||
(onlyShowPeriodicUsage && (key === 'mauLimit' || key === 'tokenLimit')) (onlyShowPeriodicUsage && (key === 'mauLimit' || key === 'tokenLimit'))
) )
.map((key) => ({ .map((key) => {
usage: getUsageByKey(key, { const parsedUsage = getUsageByKey(key, {
periodicUsage, periodicUsage,
countBasedUsage: currentSubscriptionUsage, countBasedUsage: currentSubscriptionUsage,
basicQuota: currentSubscriptionBasicQuota, basicQuota: currentSubscriptionBasicQuota,
}), });
return {
usage: parsedUsage,
usageKey: 'subscription.usage.usage_description_with_limited_quota', usageKey: 'subscription.usage.usage_description_with_limited_quota',
titleKey: `subscription.usage.${titleKeyMap[key]}`, titleKey: `subscription.usage.${titleKeyMap[key]}`,
unitPrice: usageKeyPriceMap[key], unitPrice: usageKeyPriceMap[key],
@ -120,10 +122,24 @@ function PlanUsage({ periodicUsage: rawPeriodicUsage }: Props) {
), ),
...cond( ...cond(
isPaidTenant && { isPaidTenant && {
basicQuota: currentSubscriptionBasicQuota[key],
// Do not show tooltip if the basic quota is null (unlimited) and the usage is number-typed.
...cond(
!(currentSubscriptionBasicQuota[key] === null && typeof parsedUsage === 'number') && {
tooltipKey: `subscription.usage.${ tooltipKey: `subscription.usage.${
isEnterprisePlan ? enterpriseTooltipKeyMap[key] : tooltipKeyMap[key] isEnterprisePlan ? enterpriseTooltipKeyMap[key] : tooltipKeyMap[key]
}`, }`,
basicQuota: currentSubscriptionBasicQuota[key], }
),
// Show tooltip for number-typed basic quota for 'organizationsLimit'.
...cond(
key === 'organizationsLimit' &&
typeof currentSubscriptionBasicQuota[key] === 'number' &&
currentSubscriptionBasicQuota[key] > 0 && {
tooltipKey:
'subscription.usage.organizations.tooltip_for_enterprise_with_numbered_basic_quota',
}
),
} }
), ),
// Hide the quota notice for Pro plans if the basic quota is 0. // Hide the quota notice for Pro plans if the basic quota is 0.
@ -134,7 +150,8 @@ function PlanUsage({ periodicUsage: rawPeriodicUsage }: Props) {
isQuotaNoticeHidden: true, isQuotaNoticeHidden: true,
} }
), ),
})); };
});
return ( return (
<div> <div>

View file

@ -21,6 +21,8 @@ const usage = {
description_for_enterprise: '(Included)', description_for_enterprise: '(Included)',
tooltip_for_enterprise: tooltip_for_enterprise:
'Inclusion depends on your plan. If the organization feature isnt in your initial contract, it will be added to your bill when you activate it. The add-on costs ${{price, number}}/month, regardless of the number of organizations or their activity.', 'Inclusion depends on your plan. If the organization feature isnt in your initial contract, it will be added to your bill when you activate it. The add-on costs ${{price, number}}/month, regardless of the number of organizations or their activity.',
tooltip_for_enterprise_with_numbered_basic_quota:
'Your plan includes the first {{basicQuota}} organizations for free. If you need more, you can add them with the organization add-on at a flat rate of ${{price, number}} per month, regardless of the number of organizations or their activity level.',
}, },
mfa: { mfa: {
title: 'MFA', title: 'MFA',