Skip to content

Commit 9240877

Browse files
authored
refactor(console): update system limit toast copy (#7994)
1 parent 26ac91b commit 9240877

File tree

22 files changed

+52
-26
lines changed

22 files changed

+52
-26
lines changed

packages/console/src/components/SkuName/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ const getRegisteredSkuNamePhrase = (
2424

2525
type Props = {
2626
readonly skuId: string;
27+
readonly isEnterprise?: boolean;
2728
};
2829

29-
function SkuName({ skuId }: Props) {
30+
function SkuName({ skuId, isEnterprise = false }: Props) {
3031
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.subscription' });
31-
const skuNamePhrase = getRegisteredSkuNamePhrase(skuId);
32+
const skuNamePhrase = isEnterprise ? 'enterprise' : getRegisteredSkuNamePhrase(skuId);
3233
return <span>{String(t(skuNamePhrase))}</span>;
3334
}
3435

packages/console/src/consts/external-links.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const reservationLink = 'https://cal.com/logto/30min';
99
export const trustAndSecurityLink = 'https://logto.io/trust-and-security';
1010
export const pricingLink = 'https://logto.io/pricing';
1111
export const officialWebsiteContactPageLink = 'https://logto.io/contact';
12+
export const entityPolicyLink = 'https://docs.logto.io/logto-cloud/system-limit';
1213

1314
/** Docs link */
1415
export const organizationsFeatureLink = '/organizations';

packages/console/src/ds-components/Toast/ToastWithAction.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { type AdminConsoleKey } from '@logto/phrases';
22
import classNames from 'classnames';
3+
import { type ReactNode } from 'react';
34
import { toast } from 'react-hot-toast';
45

56
import Error from '@/assets/icons/toast-error.svg?react';
@@ -13,7 +14,7 @@ import styles from './index.module.scss';
1314
type ToastVariant = 'success' | 'error';
1415

1516
type ToastWithActionProps = {
16-
readonly message: string;
17+
readonly message: ReactNode;
1718
readonly variant: ToastVariant;
1819
readonly actionText: AdminConsoleKey;
1920
readonly actionHref: string;

packages/console/src/ds-components/Toast/index.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ div.toast {
88
color: var(--color-text);
99
box-shadow: var(--shadow-1);
1010
border-radius: _.unit(2);
11-
max-width: 412px;
11+
max-width: 480px;
1212

1313
.image {
1414
display: flex;

packages/console/src/hooks/use-system-limit-error-message.ts renamed to packages/console/src/hooks/use-system-limit-error-message.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { type AdminConsoleKey } from '@logto/phrases';
22
import { type RequestErrorBody } from '@logto/schemas';
3-
import { useCallback } from 'react';
4-
import { useTranslation } from 'react-i18next';
3+
import { useCallback, useContext } from 'react';
4+
import { Trans, useTranslation } from 'react-i18next';
55
import { z } from 'zod';
66

77
import { type SystemLimit } from '@/cloud/types/router';
8+
import SkuName from '@/components/SkuName';
9+
import { entityPolicyLink } from '@/consts';
10+
import { SubscriptionDataContext } from '@/contexts/SubscriptionDataProvider';
11+
import TextLink from '@/ds-components/TextLink';
812

913
type SystemLimitKey = keyof SystemLimit;
1014

@@ -59,8 +63,12 @@ const systemLimitEntityPhrases: Record<SystemLimitKey, AdminConsoleKey> = {
5963

6064
export const useSystemLimitErrorMessage = () => {
6165
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
66+
const {
67+
currentSubscription: { planId, isEnterprisePlan },
68+
} = useContext(SubscriptionDataContext);
69+
6270
const parseSystemLimitErrorMessage = useCallback(
63-
(errorBody: RequestErrorBody): string => {
71+
(errorBody: RequestErrorBody) => {
6472
if (errorBody.code !== 'system_limit.limit_exceeded') {
6573
return t('general.unknown_error');
6674
}
@@ -73,9 +81,18 @@ export const useSystemLimitErrorMessage = () => {
7381
const { key } = result.data;
7482

7583
const entity = t(systemLimitEntityPhrases[key]);
76-
return t('system_limit.limit_exceeded', { entity });
84+
return (
85+
<Trans
86+
components={{
87+
a: <TextLink href={entityPolicyLink} targetBlank="noopener" />,
88+
planName: <SkuName skuId={planId} isEnterprise={isEnterprisePlan} />,
89+
}}
90+
>
91+
{t('system_limit.limit_exceeded', { entity })}
92+
</Trans>
93+
);
7794
},
78-
[t]
95+
[t, planId, isEnterprisePlan]
7996
);
8097

8198
return {

packages/phrases/src/locales/ar/translation/admin-console/system-limit.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const system_limit = {
2-
limit_exceeded: 'وصل هذا المستأجر إلى حد {{entity}} وفقًا لسياسة حد الكيان الخاصة بـ Logto.',
2+
limit_exceeded:
3+
'لقد وصل مستأجر <planName/> إلى حد {{entity}} الخاص به بموجب <a>سياسة كيان Logto</a>.',
34
entities: {
45
application: 'التطبيق',
56
third_party_application: 'تطبيق الطرف الثالث',

packages/phrases/src/locales/de/translation/admin-console/system-limit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const system_limit = {
22
limit_exceeded:
3-
'Dieser Mandant hat das {{entity}}-Limit gemäß Logtos Entitätslimitrichtlinie erreicht.',
3+
'Dieser <planName/>-Mandant hat sein {{entity}}-Limit gemäß <a>Logtos Entitätsrichtlinie</a> erreicht.',
44
entities: {
55
application: 'Anwendung',
66
third_party_application: 'Drittanbieter-Anwendung',

packages/phrases/src/locales/en/translation/admin-console/system-limit.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const system_limit = {
2-
limit_exceeded: "This tenant has reached the {{entity}} limit per Logto's entity limit policy.",
2+
limit_exceeded:
3+
"This <planName/> tenant has reached its {{entity}} limit under <a>Logto's entity policy</a>.",
34
entities: {
45
application: 'application',
56
third_party_application: 'third-party application',

packages/phrases/src/locales/es/translation/admin-console/system-limit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const system_limit = {
22
limit_exceeded:
3-
'Este inquilino ha alcanzado el límite de {{entity}} según la política de límite de entidad de Logto.',
3+
'Este inquilino <planName/> ha alcanzado su límite de {{entity}} bajo <a>la política de entidad de Logto</a>.',
44
entities: {
55
application: 'aplicación',
66
third_party_application: 'aplicación de terceros',

packages/phrases/src/locales/fr/translation/admin-console/system-limit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const system_limit = {
22
limit_exceeded:
3-
"Ce locataire a atteint la limite de {{entity}} selon la politique de limite d'entité de Logto.",
3+
"Ce locataire <planName/> a atteint sa limite de {{entity}} selon <a>la politique d'entité de Logto</a>.",
44
entities: {
55
application: 'application',
66
third_party_application: 'application tierce',

0 commit comments

Comments
 (0)