From d369e0c8637c00b7ed9f39781cb53e865ffae057 Mon Sep 17 00:00:00 2001 From: Xiao Yijun <xiaoyijun@silverhand.io> Date: Fri, 26 May 2023 10:44:41 +0800 Subject: [PATCH] refactor(console): remove webhook creation limit (#3903) --- .../components/CreateFormModal/index.tsx | 31 +------------------ packages/console/src/pages/Webhooks/index.tsx | 1 - .../de/translation/admin-console/webhooks.ts | 2 -- .../en/translation/admin-console/webhooks.ts | 2 -- .../es/translation/admin-console/webhooks.ts | 2 -- .../fr/translation/admin-console/webhooks.ts | 2 -- .../it/translation/admin-console/webhooks.ts | 2 -- .../ja/translation/admin-console/webhooks.ts | 2 -- .../ko/translation/admin-console/webhooks.ts | 2 -- .../translation/admin-console/webhooks.ts | 2 -- .../translation/admin-console/webhooks.ts | 2 -- .../translation/admin-console/webhooks.ts | 2 -- .../ru/translation/admin-console/webhooks.ts | 2 -- .../translation/admin-console/webhooks.ts | 2 -- .../translation/admin-console/webhooks.ts | 2 -- .../translation/admin-console/webhooks.ts | 2 -- .../translation/admin-console/webhooks.ts | 2 -- packages/shared/src/constants.ts | 1 - packages/shared/src/universal.ts | 1 - 19 files changed, 1 insertion(+), 63 deletions(-) delete mode 100644 packages/shared/src/constants.ts diff --git a/packages/console/src/pages/Webhooks/components/CreateFormModal/index.tsx b/packages/console/src/pages/Webhooks/components/CreateFormModal/index.tsx index 22d997d2f..f7b56e5a9 100644 --- a/packages/console/src/pages/Webhooks/components/CreateFormModal/index.tsx +++ b/packages/console/src/pages/Webhooks/components/CreateFormModal/index.tsx @@ -1,11 +1,6 @@ import { type Hook } from '@logto/schemas'; -import { webhookLimit } from '@logto/shared/universal'; -import { Trans, useTranslation } from 'react-i18next'; import Modal from 'react-modal'; -import ConfirmModal from '@/components/ConfirmModal'; -import TextLink from '@/components/TextLink'; -import { contactEmail, contactEmailLink } from '@/consts'; import * as modalStyles from '@/scss/modal.module.scss'; import CreateForm from './CreateForm'; @@ -13,33 +8,9 @@ import CreateForm from './CreateForm'; type Props = { isOpen: boolean; onClose: (createdHook?: Hook) => void; - existingHooksCount: number; }; -function CreateFormModal({ isOpen, onClose, existingHooksCount }: Props) { - const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); - const shouldBlockCreation = existingHooksCount >= webhookLimit; - - if (shouldBlockCreation) { - return ( - <ConfirmModal - isOpen={isOpen} - cancelButtonText="general.got_it" - onCancel={() => { - onClose(); - }} - > - <Trans - components={{ - a: <TextLink to={contactEmailLink} />, - }} - > - {t('webhooks.create_form.block_description', { link: contactEmail })} - </Trans> - </ConfirmModal> - ); - } - +function CreateFormModal({ isOpen, onClose }: Props) { return ( <Modal shouldCloseOnOverlayClick diff --git a/packages/console/src/pages/Webhooks/index.tsx b/packages/console/src/pages/Webhooks/index.tsx index fe70f6300..f60f5cb0c 100644 --- a/packages/console/src/pages/Webhooks/index.tsx +++ b/packages/console/src/pages/Webhooks/index.tsx @@ -140,7 +140,6 @@ function Webhooks() { }} widgets={ <CreateFormModal - existingHooksCount={data?.length ?? 0} isOpen={isCreateNew} onClose={(createdHook?: Hook) => { if (createdHook) { diff --git a/packages/phrases/src/locales/de/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/de/translation/admin-console/webhooks.ts index b0f58c7b5..defe08248 100644 --- a/packages/phrases/src/locales/de/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/de/translation/admin-console/webhooks.ts @@ -37,8 +37,6 @@ const webhooks = { create_webhook: 'Webhook erstellen', missing_event_error: 'Sie müssen mindestens ein Ereignis auswählen.', https_format_error: 'HTTPS-Format erforderlich aus Sicherheitsgründen.', - block_description: - 'Die aktuelle Version unterstützt nur bis zu drei Webhooks. Wenn Sie zusätzliche Webhooks benötigen, senden Sie bitte eine E-Mail an unser Support-Team unter <a>{{link}}</a> und wir helfen Ihnen gerne weiter.', }, webhook_created: 'Der Webhook {{name}} wurde erfolgreich erstellt.', }; diff --git a/packages/phrases/src/locales/en/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/en/translation/admin-console/webhooks.ts index 70ee7c5b3..bf27d71ae 100644 --- a/packages/phrases/src/locales/en/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/en/translation/admin-console/webhooks.ts @@ -36,8 +36,6 @@ const webhooks = { create_webhook: 'Create webhook', missing_event_error: 'You have to select at least one event.', https_format_error: 'HTTPS format required for security reasons.', - block_description: - 'The current version supports only up to three webhooks. If you require additional webhooks, please email our support team at <a>{{link}}</a> and we will be happy to assist you.', }, webhook_created: 'The webhook {{name}} has been successfully created.', }; diff --git a/packages/phrases/src/locales/es/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/es/translation/admin-console/webhooks.ts index 81e597408..e08028da1 100644 --- a/packages/phrases/src/locales/es/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/es/translation/admin-console/webhooks.ts @@ -37,8 +37,6 @@ const webhooks = { create_webhook: 'Crear webhook', missing_event_error: 'Debe seleccionar al menos un evento.', https_format_error: 'Se requiere formato HTTPS por motivos de seguridad.', - block_description: - 'La versión actual admite hasta tres webhooks. Si necesita webhooks adicionales, envíe un correo electrónico a nuestro equipo de soporte a <a>{{link}}</a> y estaremos encantados de ayudarle.', }, webhook_created: 'El webhook {{name}} se ha creado correctamente.', }; diff --git a/packages/phrases/src/locales/fr/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/fr/translation/admin-console/webhooks.ts index d6dd7c8a1..0e4dabf4d 100644 --- a/packages/phrases/src/locales/fr/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/fr/translation/admin-console/webhooks.ts @@ -37,8 +37,6 @@ const webhooks = { create_webhook: 'Créer un webhook', missing_event_error: 'Vous devez sélectionner au moins un événement.', https_format_error: 'Format HTTPS requis pour des raisons de sécurité.', - block_description: - "La version actuelle prend en charge jusqu'à trois webhooks. Si vous avez besoin de webhooks supplémentaires, veuillez envoyer un e-mail à notre équipe d'assistance <a>{{link}}</a> et nous serons heureux de vous aider.", }, webhook_created: 'Le webhook {{name}} a été créé avec succès.', }; diff --git a/packages/phrases/src/locales/it/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/it/translation/admin-console/webhooks.ts index 7c5feabb6..218344499 100644 --- a/packages/phrases/src/locales/it/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/it/translation/admin-console/webhooks.ts @@ -36,8 +36,6 @@ const webhooks = { create_webhook: 'Crea webhook', missing_event_error: 'Devi selezionare almeno un evento.', https_format_error: 'Richiesto formato HTTPS per motivi di sicurezza.', - block_description: - "La versione corrente supporta solo fino a tre webhook. Se hai bisogno di ulteriori webhook, ti preghiamo di inviare un'email al nostro team di supporto su <a>{{link}}</a> e saremo lieti di assisterti.", }, webhook_created: 'Il webhook {{name}} è stato creato con successo.', }; diff --git a/packages/phrases/src/locales/ja/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/ja/translation/admin-console/webhooks.ts index 080278aa3..56b6e059b 100644 --- a/packages/phrases/src/locales/ja/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/ja/translation/admin-console/webhooks.ts @@ -36,8 +36,6 @@ const webhooks = { create_webhook: 'Webhookを作成する', missing_event_error: '少なくとも1つのイベントを選択する必要があります。', https_format_error: 'セキュリティ上の理由からHTTPS形式が必要です。', - block_description: - '現在のバージョンでは、最大3個の Webhook にしか対応していません。追加の webhook が必要な場合は、サポートチーム <a>{{link}}</a> までご連絡ください。', }, webhook_created: 'Webhook {{name}}が正常に作成されました。', }; diff --git a/packages/phrases/src/locales/ko/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/ko/translation/admin-console/webhooks.ts index d33f41ed4..4280ca7d6 100644 --- a/packages/phrases/src/locales/ko/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/ko/translation/admin-console/webhooks.ts @@ -36,8 +36,6 @@ const webhooks = { create_webhook: 'Webhook 생성', missing_event_error: '하나 이상의 이벤트를 선택해야 합니다.', https_format_error: '보안 상의 이유로 HTTPS 형식이 필요합니다.', - block_description: - '현재 버전은 최대 세 개의 웹훅만 지원합니다. 추가 웹훅이 필요한 경우 지원팀 <a>{{link}}</a>에 문의하시기 바랍니다.', }, webhook_created: 'Webhook {{name}}가 성공적으로 생성되었습니다.', }; diff --git a/packages/phrases/src/locales/pl-pl/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/pl-pl/translation/admin-console/webhooks.ts index 7ac7bc9ff..912ddb4af 100644 --- a/packages/phrases/src/locales/pl-pl/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/pl-pl/translation/admin-console/webhooks.ts @@ -37,8 +37,6 @@ const webhooks = { create_webhook: 'Utwórz webhook', missing_event_error: 'Musisz wybrać przynajmniej jedno zdarzenie.', https_format_error: 'Wymagany format HTTPS ze względu na bezpieczeństwo.', - block_description: - 'Aktualna wersja obsługuje tylko do trzech webhooków. Jeśli potrzebujesz dodatkowych webhooków, wyślij e-mail do naszego zespołu pomocy technicznej na adres <a>{{link}}</a>, a chętnie Ci pomożemy.', }, webhook_created: 'Webhook {{name}} został pomyślnie utworzony.', }; diff --git a/packages/phrases/src/locales/pt-br/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/pt-br/translation/admin-console/webhooks.ts index 5d86dea1c..55505519a 100644 --- a/packages/phrases/src/locales/pt-br/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/pt-br/translation/admin-console/webhooks.ts @@ -36,8 +36,6 @@ const webhooks = { create_webhook: 'Criar webhook', missing_event_error: 'Você precisa selecionar pelo menos um evento.', https_format_error: 'Formato HTTPS necessário por motivos de segurança.', - block_description: - 'A versão atual suporta apenas até três webhooks. Se você precisar de webhooks adicionais, envie um e-mail para nossa equipe de suporte em <a>{{link}}</a> e teremos prazer em ajudá-lo.', }, webhook_created: 'O webhook {{name}foi criado com sucesso.', }; diff --git a/packages/phrases/src/locales/pt-pt/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/pt-pt/translation/admin-console/webhooks.ts index 5c6beb714..d290e9b79 100644 --- a/packages/phrases/src/locales/pt-pt/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/pt-pt/translation/admin-console/webhooks.ts @@ -37,8 +37,6 @@ const webhooks = { create_webhook: 'Criar webhook', missing_event_error: 'Você deve selecionar pelo menos um evento.', https_format_error: 'Formato HTTPS exigido por motivos de segurança.', - block_description: - 'A versão atual suporta apenas até três webhooks. Se você precisar de webhooks adicionais, envie um e-mail para nossa equipe de suporte em <a>{{link}}</a> e ficaremos felizes em ajudá-lo.', }, webhook_created: 'O webhook {{name}} foi criado com sucesso.', }; diff --git a/packages/phrases/src/locales/ru/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/ru/translation/admin-console/webhooks.ts index 9a7f796fa..9ef9ccec3 100644 --- a/packages/phrases/src/locales/ru/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/ru/translation/admin-console/webhooks.ts @@ -37,8 +37,6 @@ const webhooks = { create_webhook: 'Создать вебхук', missing_event_error: 'Вы должны выбрать как минимум одно событие.', https_format_error: 'Требуется формат HTTPS по соображениям безопасности.', - block_description: - 'Текущая версия поддерживает только до трех вебхуков. Если вам нужны дополнительные вебхуки, напишите нашей службе поддержки по адресу <a>{{link}}</a>, и мы с удовольствием вам поможем.', }, webhook_created: 'Вебхук {{name}} был успешно создан.', }; diff --git a/packages/phrases/src/locales/tr-tr/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/tr-tr/translation/admin-console/webhooks.ts index 2a3af21f8..7b884b2fe 100644 --- a/packages/phrases/src/locales/tr-tr/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/tr-tr/translation/admin-console/webhooks.ts @@ -36,8 +36,6 @@ const webhooks = { create_webhook: 'Webhook Oluştur', missing_event_error: 'En az bir olay seçmeniz gerekiyor.', https_format_error: 'Güvenliği nedeniyle HTTPS biçimi gereklidir.', - block_description: - 'Geçerli sürüm üç adede kadar webhooks destekler. Ek webhooks gerekiyorsa, lütfen <a>{{link}}</a> e-posta ile destek ekibimize başvurun, yardımcı olmaktan memnuniyet duyarız.', }, webhook_created: 'Webhook {{name}} başarıyla oluşturuldu.', }; diff --git a/packages/phrases/src/locales/zh-cn/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/zh-cn/translation/admin-console/webhooks.ts index 28c0e0d8b..117572bb6 100644 --- a/packages/phrases/src/locales/zh-cn/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/zh-cn/translation/admin-console/webhooks.ts @@ -33,8 +33,6 @@ const webhooks = { create_webhook: '创建Webhook', missing_event_error: '您必须至少选择一个事件。', https_format_error: 'HTTPS格式为安全性所必须。', - block_description: - '当前版本仅支持最多三个Webhook。如果你需要额外的Webhook,请通过<a>{{link}}</a>向我们的支持团队发送电子邮件,我们将很乐意提供帮助。', }, webhook_created: 'Webhook {{name}} 已成功创建。', }; diff --git a/packages/phrases/src/locales/zh-hk/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/zh-hk/translation/admin-console/webhooks.ts index ba5ffa29e..f2c0cf28d 100644 --- a/packages/phrases/src/locales/zh-hk/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/zh-hk/translation/admin-console/webhooks.ts @@ -34,8 +34,6 @@ const webhooks = { create_webhook: '創建 Webhook', missing_event_error: '您必須至少選擇一個事件。', https_format_error: '出於安全原因,需要 HTTPS 格式。', - block_description: - '目前版本僅支持三條 Webhook。 如果需要額外的 Webhook,請發送電子郵件至我們的支持團隊 <a>{{link}}</a>,我們將樂意為你提供協助。', }, webhook_created: 'Webhook {{name}} 成功創建。', }; diff --git a/packages/phrases/src/locales/zh-tw/translation/admin-console/webhooks.ts b/packages/phrases/src/locales/zh-tw/translation/admin-console/webhooks.ts index 2f9e14a65..3916a0a2a 100644 --- a/packages/phrases/src/locales/zh-tw/translation/admin-console/webhooks.ts +++ b/packages/phrases/src/locales/zh-tw/translation/admin-console/webhooks.ts @@ -34,8 +34,6 @@ const webhooks = { create_webhook: '創建 webhook', missing_event_error: '您需要選擇至少一個事件。', https_format_error: 'HTTPS 格式要求為了安全原因。', - block_description: - '目前版本僅支持三條 Webhook。 如果需要額外的 Webhook,請發送電子郵件至我們的支持團隊 <a>{{link}}</a>,我們將樂意為你提供協助。', }, webhook_created: 'Webhook {{name}} 已成功創建。', }; diff --git a/packages/shared/src/constants.ts b/packages/shared/src/constants.ts deleted file mode 100644 index 0bf36d544..000000000 --- a/packages/shared/src/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const webhookLimit = 3; diff --git a/packages/shared/src/universal.ts b/packages/shared/src/universal.ts index 64b5349fc..7bf661541 100644 --- a/packages/shared/src/universal.ts +++ b/packages/shared/src/universal.ts @@ -1,3 +1,2 @@ export * from './database/index.js'; export * from './utils/index.js'; -export * from './constants.js';