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 ||
(onlyShowPeriodicUsage && (key === 'mauLimit' || key === 'tokenLimit'))
)
.map((key) => {
const parsedUsage = getUsageByKey(key, {
.map((key) => ({
usage: getUsageByKey(key, {
periodicUsage,
countBasedUsage: currentSubscriptionUsage,
basicQuota: currentSubscriptionBasicQuota,
});
return {
usage: parsedUsage,
usageKey: 'subscription.usage.usage_description_with_limited_quota',
titleKey: `subscription.usage.${titleKeyMap[key]}`,
unitPrice: usageKeyPriceMap[key],
...cond(
(key === 'tokenLimit' || key === 'mauLimit' || isPaidTenant) && {
quota: currentSubscriptionQuota[key],
}
),
...cond(
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.${
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,
}),
usageKey: 'subscription.usage.usage_description_with_limited_quota',
titleKey: `subscription.usage.${titleKeyMap[key]}`,
unitPrice: usageKeyPriceMap[key],
...cond(
(key === 'tokenLimit' || key === 'mauLimit' || isPaidTenant) && {
quota: currentSubscriptionQuota[key],
}
),
...cond(
isPaidTenant && {
basicQuota: currentSubscriptionBasicQuota[key],
// Do not show tooltip if the basic quota is null (unlimited) for m2m/API resource add-on.
...cond(
!(
currentSubscriptionBasicQuota[key] === null &&
(key === 'machineToMachineLimit' || key === 'resourcesLimit')
) && {
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,
}
),
}));
return (
<div>