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,14 +104,12 @@ 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 {
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],
@ -123,9 +121,12 @@ function PlanUsage({ periodicUsage: rawPeriodicUsage }: Props) {
...cond( ...cond(
isPaidTenant && { isPaidTenant && {
basicQuota: currentSubscriptionBasicQuota[key], basicQuota: currentSubscriptionBasicQuota[key],
// Do not show tooltip if the basic quota is null (unlimited) and the usage is number-typed. // Do not show tooltip if the basic quota is null (unlimited) for m2m/API resource add-on.
...cond( ...cond(
!(currentSubscriptionBasicQuota[key] === null && typeof parsedUsage === 'number') && { !(
currentSubscriptionBasicQuota[key] === null &&
(key === 'machineToMachineLimit' || key === 'resourcesLimit')
) && {
tooltipKey: `subscription.usage.${ tooltipKey: `subscription.usage.${
isEnterprisePlan ? enterpriseTooltipKeyMap[key] : tooltipKeyMap[key] isEnterprisePlan ? enterpriseTooltipKeyMap[key] : tooltipKeyMap[key]
}`, }`,
@ -150,8 +151,7 @@ function PlanUsage({ periodicUsage: rawPeriodicUsage }: Props) {
isQuotaNoticeHidden: true, isQuotaNoticeHidden: true,
} }
), ),
}; }));
});
return ( return (
<div> <div>