@@ -4,7 +4,7 @@ import { Trans, useTranslation } from 'react-i18next';
44
55import { type LogtoSkuResponse } from '@/cloud/types/router' ;
66import SkuName from '@/components/SkuName' ;
7- import { comingSoonSkuQuotaKeys } from '@/consts/plan-quotas' ;
7+ import { comingSoonSkuQuotaKeys , hiddenQuotaDiffUsageKeys } from '@/consts/plan-quotas' ;
88import { type LogtoSkuQuota , type LogtoSkuQuotaEntries } from '@/types/skus' ;
99
1010import PlanQuotaDiffCard from './PlanQuotaDiffCard' ;
@@ -15,24 +15,31 @@ type Props = {
1515 readonly targetSku : LogtoSkuResponse ;
1616} ;
1717
18- const excludeSkuComingSoonFeatures = (
19- quotaDiff : Partial < LogtoSkuQuota >
20- ) : Partial < LogtoSkuQuota > => {
18+ /**
19+ * Exclude the quota items that are hidden in the downgrade plan notification modal.
20+ * - Coming soon features
21+ * - Add-on/legacy features whose quotas vary based on the current plan
22+ */
23+ const excludeHiddenUsages = ( quotaDiff : Partial < LogtoSkuQuota > ) : Partial < LogtoSkuQuota > => {
2124 // eslint-disable-next-line no-restricted-syntax
2225 const entries = Object . entries ( quotaDiff ) as LogtoSkuQuotaEntries ;
23- return Object . fromEntries ( entries . filter ( ( [ key ] ) => ! comingSoonSkuQuotaKeys . includes ( key ) ) ) ;
26+ return Object . fromEntries (
27+ entries . filter (
28+ ( [ key ] ) => ! comingSoonSkuQuotaKeys . includes ( key ) && ! hiddenQuotaDiffUsageKeys . includes ( key )
29+ )
30+ ) ;
2431} ;
2532
2633function DowngradeConfirmModalContent ( { currentSku, targetSku } : Props ) {
2734 const { t } = useTranslation ( undefined , { keyPrefix : 'admin_console' } ) ;
2835
2936 const currentSkuQuotaDiff = useMemo (
30- ( ) => excludeSkuComingSoonFeatures ( diff ( targetSku . quota , currentSku . quota ) ) ,
37+ ( ) => excludeHiddenUsages ( diff ( targetSku . quota , currentSku . quota ) ) ,
3138 [ targetSku . quota , currentSku . quota ]
3239 ) ;
3340
3441 const targetSkuQuotaDiff = useMemo (
35- ( ) => excludeSkuComingSoonFeatures ( diff ( currentSku . quota , targetSku . quota ) ) ,
42+ ( ) => excludeHiddenUsages ( diff ( currentSku . quota , targetSku . quota ) ) ,
3643 [ targetSku . quota , currentSku . quota ]
3744 ) ;
3845
0 commit comments