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 (#6629)

This commit is contained in:
Darcy Ye 2024-09-24 21:42:21 +08:00 committed by GitHub
parent 5a522226d5
commit fa6f8ef498
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -104,54 +104,54 @@ function PlanUsage({ periodicUsage: rawPeriodicUsage }: Props) {
isEnterprisePlan || isEnterprisePlan ||
(onlyShowPeriodicUsage && (key === 'mauLimit' || key === 'tokenLimit')) (onlyShowPeriodicUsage && (key === 'mauLimit' || key === 'tokenLimit'))
) )
.map((key) => { .map((key) => ({
const parsedUsage = getUsageByKey(key, { usage: getUsageByKey(key, {
periodicUsage, periodicUsage,
countBasedUsage: currentSubscriptionUsage, countBasedUsage: currentSubscriptionUsage,
basicQuota: currentSubscriptionBasicQuota, basicQuota: currentSubscriptionBasicQuota,
}); }),
return { usageKey: 'subscription.usage.usage_description_with_limited_quota',
usage: parsedUsage, titleKey: `subscription.usage.${titleKeyMap[key]}`,
usageKey: 'subscription.usage.usage_description_with_limited_quota', unitPrice: usageKeyPriceMap[key],
titleKey: `subscription.usage.${titleKeyMap[key]}`, ...cond(
unitPrice: usageKeyPriceMap[key], (key === 'tokenLimit' || key === 'mauLimit' || isPaidTenant) && {
...cond( quota: currentSubscriptionQuota[key],
(key === 'tokenLimit' || key === 'mauLimit' || isPaidTenant) && { }
quota: currentSubscriptionQuota[key], ),
} ...cond(
), isPaidTenant && {
...cond( basicQuota: currentSubscriptionBasicQuota[key],
isPaidTenant && { // Do not show tooltip if the basic quota is null (unlimited) for m2m/API resource add-on.
basicQuota: currentSubscriptionBasicQuota[key], ...cond(
// Do not show tooltip if the basic quota is null (unlimited) and the usage is number-typed. !(
...cond( currentSubscriptionBasicQuota[key] === null &&
!(currentSubscriptionBasicQuota[key] === null && typeof parsedUsage === 'number') && { (key === 'machineToMachineLimit' || key === 'resourcesLimit')
tooltipKey: `subscription.usage.${ ) && {
isEnterprisePlan ? enterpriseTooltipKeyMap[key] : tooltipKeyMap[key] tooltipKey: `subscription.usage.${
}`, isEnterprisePlan ? enterpriseTooltipKeyMap[key] : tooltipKeyMap[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.
// Per current pricing model design, it should apply to `enterpriseSsoLimit`.
...cond(
planId === ReservedPlanId.Pro &&
currentSubscriptionBasicQuota[key] === 0 && {
isQuotaNoticeHidden: true,
} }
), ),
}; // 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.
// Per current pricing model design, it should apply to `enterpriseSsoLimit`.
...cond(
planId === ReservedPlanId.Pro &&
currentSubscriptionBasicQuota[key] === 0 && {
isQuotaNoticeHidden: true,
}
),
}));
return ( return (
<div> <div>