Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix enterprise console issues #6578

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions packages/console/src/components/PlanUsage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ const getUsageByKey = (
return periodicUsage[key];
}

// Show enabled status for organization feature.
if (key === 'organizationsLimit') {
return countBasedUsage[key] > 0;
}

return countBasedUsage[key];
};

Expand Down Expand Up @@ -101,7 +96,11 @@ function PlanUsage({ periodicUsage: rawPeriodicUsage }: Props) {
}
),
...cond(
(key === 'tokenLimit' || key === 'mauLimit') && { quota: currentSubscriptionQuota[key] }
(key === 'tokenLimit' || key === 'mauLimit' || key === 'organizationsLimit') &&
// Do not show `xxx / 0` in displaying usage.
currentSubscriptionQuota[key] !== 0 && {
quota: currentSubscriptionQuota[key],
}
),
// Hide usage tip for Enterprise plan.
isUsageTipHidden: isEnterprisePlan,
Expand Down
10 changes: 9 additions & 1 deletion packages/console/src/components/SkuName/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { ReservedPlanId } from '@logto/schemas';
import { type TFuncKey } from 'i18next';
import { useContext } from 'react';
import { useTranslation } from 'react-i18next';

import { SubscriptionDataContext } from '@/contexts/SubscriptionDataProvider';
import { ReservedSkuId } from '@/types/subscriptions';

const registeredSkuIdNamePhraseMap: Record<
Expand All @@ -19,8 +22,13 @@ type Props = {
readonly skuId: string;
};

function SkuName({ skuId }: Props) {
function SkuName({ skuId: rawSkuId }: Props) {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.subscription' });
const {
currentSubscription: { isEnterprisePlan },
} = useContext(SubscriptionDataContext);
const skuId = isEnterprisePlan ? ReservedPlanId.Enterprise : rawSkuId;

const skuNamePhrase = registeredSkuIdNamePhraseMap[skuId];

/**
Expand Down
7 changes: 4 additions & 3 deletions packages/console/src/pages/Mfa/MfaForm/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MfaFactor, MfaPolicy, ReservedPlanId, type SignInExperience } from '@logto/schemas';
import { MfaFactor, MfaPolicy, type SignInExperience } from '@logto/schemas';
import { useContext, useMemo } from 'react';
import { Controller, useForm } from 'react-hook-form';
import { toast } from 'react-hot-toast';
Expand All @@ -18,6 +18,7 @@ import Switch from '@/ds-components/Switch';
import useApi from '@/hooks/use-api';
import useDocumentationUrl from '@/hooks/use-documentation-url';
import { trySubmitSafe } from '@/utils/form';
import { isPaidPlan } from '@/utils/subscription';

import { type MfaConfigForm, type MfaConfig } from '../types';

Expand All @@ -34,12 +35,12 @@ type Props = {

function MfaForm({ data, onMfaUpdated }: Props) {
const {
currentSubscription: { planId },
currentSubscription: { planId, isEnterprisePlan },
currentSubscriptionQuota,
mutateSubscriptionQuotaAndUsages,
} = useContext(SubscriptionDataContext);
const isMfaDisabled =
isCloud && !currentSubscriptionQuota.mfaEnabled && planId !== ReservedPlanId.Pro;
isCloud && !currentSubscriptionQuota.mfaEnabled && !isPaidPlan(planId, isEnterprisePlan);

const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const { getDocumentationUrl } = useDocumentationUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
color: var(--color-text-secondary);
}
}

.notification {
margin-top: _.unit(3);
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ function SwitchPlanActionBar({ onSubscriptionUpdated, currentSkuId, logtoSkus }:
const isCurrentSku = currentSkuId === skuId;
const isDowngrade = isDowngradePlan(currentSkuId, skuId);

// Let user contact us for Pro plan when they are currently on Enterprise plan.
return isEnterprisePlan && skuId === ReservedPlanId.Pro ? (
// Let user contact us when they are currently on Enterprise plan. Do not allow users to self-serve downgrade.
return isEnterprisePlan ? (
<div>
<a href={contactEmailLink} className={styles.buttonLink} rel="noopener">
<Button title="general.contact_us_action" />
Expand Down
Loading