From fd08426935c11e266fd7e4bcfc1de8b31d7bd160 Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Thu, 7 Sep 2023 17:32:55 +0800 Subject: [PATCH] chore: reorg webhook-related file structures (#4447) --- .../components/BasicWebhookForm/index.module.scss | 0 .../components/BasicWebhookForm/index.tsx | 10 +++++++--- .../Webhooks => }/components/SuccessRate/index.tsx | 0 .../CustomHeaderField/index.module.scss | 0 .../{components => }/CustomHeaderField/index.tsx | 0 .../{components => }/SigningKeyField/index.module.scss | 0 .../{components => }/SigningKeyField/index.tsx | 0 .../{components => }/TestWebhook/index.module.scss | 0 .../{components => }/TestWebhook/index.tsx | 0 .../src/pages/WebhookDetails/WebhookSettings/index.tsx | 8 ++++---- packages/console/src/pages/WebhookDetails/index.tsx | 3 +-- packages/console/src/pages/WebhookDetails/types.ts | 2 +- .../{components => }/CreateFormModal/CreateForm.tsx | 4 +--- .../{components => }/CreateFormModal/index.tsx | 0 packages/console/src/pages/Webhooks/index.tsx | 4 ++-- packages/console/src/pages/Webhooks/types.ts | 7 ------- 16 files changed, 16 insertions(+), 22 deletions(-) rename packages/console/src/{pages/Webhooks => }/components/BasicWebhookForm/index.module.scss (100%) rename packages/console/src/{pages/Webhooks => }/components/BasicWebhookForm/index.tsx (93%) rename packages/console/src/{pages/Webhooks => }/components/SuccessRate/index.tsx (100%) rename packages/console/src/pages/WebhookDetails/WebhookSettings/{components => }/CustomHeaderField/index.module.scss (100%) rename packages/console/src/pages/WebhookDetails/WebhookSettings/{components => }/CustomHeaderField/index.tsx (100%) rename packages/console/src/pages/WebhookDetails/WebhookSettings/{components => }/SigningKeyField/index.module.scss (100%) rename packages/console/src/pages/WebhookDetails/WebhookSettings/{components => }/SigningKeyField/index.tsx (100%) rename packages/console/src/pages/WebhookDetails/WebhookSettings/{components => }/TestWebhook/index.module.scss (100%) rename packages/console/src/pages/WebhookDetails/WebhookSettings/{components => }/TestWebhook/index.tsx (100%) rename packages/console/src/pages/Webhooks/{components => }/CreateFormModal/CreateForm.tsx (96%) rename packages/console/src/pages/Webhooks/{components => }/CreateFormModal/index.tsx (100%) delete mode 100644 packages/console/src/pages/Webhooks/types.ts diff --git a/packages/console/src/pages/Webhooks/components/BasicWebhookForm/index.module.scss b/packages/console/src/components/BasicWebhookForm/index.module.scss similarity index 100% rename from packages/console/src/pages/Webhooks/components/BasicWebhookForm/index.module.scss rename to packages/console/src/components/BasicWebhookForm/index.module.scss diff --git a/packages/console/src/pages/Webhooks/components/BasicWebhookForm/index.tsx b/packages/console/src/components/BasicWebhookForm/index.tsx similarity index 93% rename from packages/console/src/pages/Webhooks/components/BasicWebhookForm/index.tsx rename to packages/console/src/components/BasicWebhookForm/index.tsx index fc16b7b95..02a04b2d5 100644 --- a/packages/console/src/pages/Webhooks/components/BasicWebhookForm/index.tsx +++ b/packages/console/src/components/BasicWebhookForm/index.tsx @@ -1,4 +1,4 @@ -import { HookEvent } from '@logto/schemas'; +import { HookEvent, type Hook, type HookConfig } from '@logto/schemas'; import { Controller, useFormContext } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; @@ -8,8 +8,6 @@ import FormField from '@/ds-components/FormField'; import TextInput from '@/ds-components/TextInput'; import { uriValidator } from '@/utils/validator'; -import { type BasicWebhookFormType } from '../../types'; - import * as styles from './index.module.scss'; const hookEventOptions = Object.values(HookEvent).map((event) => ({ @@ -17,6 +15,12 @@ const hookEventOptions = Object.values(HookEvent).map((event) => ({ value: event, })); +export type BasicWebhookFormType = { + name: Hook['name']; + events: HookEvent[]; + url: HookConfig['url']; +}; + function BasicWebhookForm() { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const { diff --git a/packages/console/src/pages/Webhooks/components/SuccessRate/index.tsx b/packages/console/src/components/SuccessRate/index.tsx similarity index 100% rename from packages/console/src/pages/Webhooks/components/SuccessRate/index.tsx rename to packages/console/src/components/SuccessRate/index.tsx diff --git a/packages/console/src/pages/WebhookDetails/WebhookSettings/components/CustomHeaderField/index.module.scss b/packages/console/src/pages/WebhookDetails/WebhookSettings/CustomHeaderField/index.module.scss similarity index 100% rename from packages/console/src/pages/WebhookDetails/WebhookSettings/components/CustomHeaderField/index.module.scss rename to packages/console/src/pages/WebhookDetails/WebhookSettings/CustomHeaderField/index.module.scss diff --git a/packages/console/src/pages/WebhookDetails/WebhookSettings/components/CustomHeaderField/index.tsx b/packages/console/src/pages/WebhookDetails/WebhookSettings/CustomHeaderField/index.tsx similarity index 100% rename from packages/console/src/pages/WebhookDetails/WebhookSettings/components/CustomHeaderField/index.tsx rename to packages/console/src/pages/WebhookDetails/WebhookSettings/CustomHeaderField/index.tsx diff --git a/packages/console/src/pages/WebhookDetails/WebhookSettings/components/SigningKeyField/index.module.scss b/packages/console/src/pages/WebhookDetails/WebhookSettings/SigningKeyField/index.module.scss similarity index 100% rename from packages/console/src/pages/WebhookDetails/WebhookSettings/components/SigningKeyField/index.module.scss rename to packages/console/src/pages/WebhookDetails/WebhookSettings/SigningKeyField/index.module.scss diff --git a/packages/console/src/pages/WebhookDetails/WebhookSettings/components/SigningKeyField/index.tsx b/packages/console/src/pages/WebhookDetails/WebhookSettings/SigningKeyField/index.tsx similarity index 100% rename from packages/console/src/pages/WebhookDetails/WebhookSettings/components/SigningKeyField/index.tsx rename to packages/console/src/pages/WebhookDetails/WebhookSettings/SigningKeyField/index.tsx diff --git a/packages/console/src/pages/WebhookDetails/WebhookSettings/components/TestWebhook/index.module.scss b/packages/console/src/pages/WebhookDetails/WebhookSettings/TestWebhook/index.module.scss similarity index 100% rename from packages/console/src/pages/WebhookDetails/WebhookSettings/components/TestWebhook/index.module.scss rename to packages/console/src/pages/WebhookDetails/WebhookSettings/TestWebhook/index.module.scss diff --git a/packages/console/src/pages/WebhookDetails/WebhookSettings/components/TestWebhook/index.tsx b/packages/console/src/pages/WebhookDetails/WebhookSettings/TestWebhook/index.tsx similarity index 100% rename from packages/console/src/pages/WebhookDetails/WebhookSettings/components/TestWebhook/index.tsx rename to packages/console/src/pages/WebhookDetails/WebhookSettings/TestWebhook/index.tsx diff --git a/packages/console/src/pages/WebhookDetails/WebhookSettings/index.tsx b/packages/console/src/pages/WebhookDetails/WebhookSettings/index.tsx index e21837d37..7d0eba963 100644 --- a/packages/console/src/pages/WebhookDetails/WebhookSettings/index.tsx +++ b/packages/console/src/pages/WebhookDetails/WebhookSettings/index.tsx @@ -4,20 +4,20 @@ import { toast } from 'react-hot-toast'; import { useTranslation } from 'react-i18next'; import { useOutletContext } from 'react-router-dom'; +import BasicWebhookForm from '@/components/BasicWebhookForm'; import DetailsForm from '@/components/DetailsForm'; import FormCard from '@/components/FormCard'; import UnsavedChangesAlertModal from '@/components/UnsavedChangesAlertModal'; import useApi from '@/hooks/use-api'; import useDocumentationUrl from '@/hooks/use-documentation-url'; -import BasicWebhookForm from '@/pages/Webhooks/components/BasicWebhookForm'; import { trySubmitSafe } from '@/utils/form'; import { type WebhookDetailsFormType, type WebhookDetailsOutletContext } from '../types'; import { webhookDetailsParser } from '../utils'; -import CustomHeaderField from './components/CustomHeaderField'; -import SigningKeyField from './components/SigningKeyField'; -import TestWebhook from './components/TestWebhook'; +import CustomHeaderField from './CustomHeaderField'; +import SigningKeyField from './SigningKeyField'; +import TestWebhook from './TestWebhook'; function WebhookSettings() { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); diff --git a/packages/console/src/pages/WebhookDetails/index.tsx b/packages/console/src/pages/WebhookDetails/index.tsx index 43101b4af..6b33e44c9 100644 --- a/packages/console/src/pages/WebhookDetails/index.tsx +++ b/packages/console/src/pages/WebhookDetails/index.tsx @@ -15,6 +15,7 @@ import WebhookDark from '@/assets/icons/webhook-dark.svg'; import Webhook from '@/assets/icons/webhook.svg'; import DetailsPage from '@/components/DetailsPage'; import PageMeta from '@/components/PageMeta'; +import SuccessRate from '@/components/SuccessRate'; import { WebhookDetailsTabs } from '@/consts'; import ActionMenu, { ActionMenuItem } from '@/ds-components/ActionMenu'; import Card from '@/ds-components/Card'; @@ -28,8 +29,6 @@ import useTenantPathname from '@/hooks/use-tenant-pathname'; import useTheme from '@/hooks/use-theme'; import { buildUrl } from '@/utils/url'; -import SuccessRate from '../Webhooks/components/SuccessRate'; - import * as styles from './index.module.scss'; import { type WebhookDetailsOutletContext } from './types'; diff --git a/packages/console/src/pages/WebhookDetails/types.ts b/packages/console/src/pages/WebhookDetails/types.ts index df8d3152a..944057005 100644 --- a/packages/console/src/pages/WebhookDetails/types.ts +++ b/packages/console/src/pages/WebhookDetails/types.ts @@ -1,6 +1,6 @@ import { type HookResponse, type Hook } from '@logto/schemas'; -import { type BasicWebhookFormType } from '../Webhooks/types'; +import { type BasicWebhookFormType } from '@/components/BasicWebhookForm'; export type WebhookDetailsOutletContext = { hook: HookResponse; diff --git a/packages/console/src/pages/Webhooks/components/CreateFormModal/CreateForm.tsx b/packages/console/src/pages/Webhooks/CreateFormModal/CreateForm.tsx similarity index 96% rename from packages/console/src/pages/Webhooks/components/CreateFormModal/CreateForm.tsx rename to packages/console/src/pages/Webhooks/CreateFormModal/CreateForm.tsx index 5231a0a3c..3b8019aeb 100644 --- a/packages/console/src/pages/Webhooks/components/CreateFormModal/CreateForm.tsx +++ b/packages/console/src/pages/Webhooks/CreateFormModal/CreateForm.tsx @@ -3,6 +3,7 @@ import { useContext } from 'react'; import { FormProvider, useForm } from 'react-hook-form'; import { Trans, useTranslation } from 'react-i18next'; +import BasicWebhookForm, { type BasicWebhookFormType } from '@/components/BasicWebhookForm'; import ContactUsPhraseLink from '@/components/ContactUsPhraseLink'; import PlanName from '@/components/PlanName'; import QuotaGuardFooter from '@/components/QuotaGuardFooter'; @@ -14,9 +15,6 @@ import useSubscriptionPlan from '@/hooks/use-subscription-plan'; import { trySubmitSafe } from '@/utils/form'; import { hasReachedQuotaLimit } from '@/utils/quota'; -import { type BasicWebhookFormType } from '../../types'; -import BasicWebhookForm from '../BasicWebhookForm'; - type Props = { totalWebhookCount: number; onClose: (createdHook?: Hook) => void; diff --git a/packages/console/src/pages/Webhooks/components/CreateFormModal/index.tsx b/packages/console/src/pages/Webhooks/CreateFormModal/index.tsx similarity index 100% rename from packages/console/src/pages/Webhooks/components/CreateFormModal/index.tsx rename to packages/console/src/pages/Webhooks/CreateFormModal/index.tsx diff --git a/packages/console/src/pages/Webhooks/index.tsx b/packages/console/src/pages/Webhooks/index.tsx index a0f5bd22c..f9b161a9d 100644 --- a/packages/console/src/pages/Webhooks/index.tsx +++ b/packages/console/src/pages/Webhooks/index.tsx @@ -13,6 +13,7 @@ import WebhooksEmptyDark from '@/assets/images/webhooks-empty-dark.svg'; import WebhooksEmpty from '@/assets/images/webhooks-empty.svg'; import ItemPreview from '@/components/ItemPreview'; import ListPage from '@/components/ListPage'; +import SuccessRate from '@/components/SuccessRate'; import { defaultPageSize } from '@/consts'; import { hookEventLabel } from '@/consts/webhooks'; import Button from '@/ds-components/Button'; @@ -25,8 +26,7 @@ import useTenantPathname from '@/hooks/use-tenant-pathname'; import useTheme from '@/hooks/use-theme'; import { buildUrl } from '@/utils/url'; -import CreateFormModal from './components/CreateFormModal'; -import SuccessRate from './components/SuccessRate'; +import CreateFormModal from './CreateFormModal'; import * as styles from './index.module.scss'; const pageSize = defaultPageSize; diff --git a/packages/console/src/pages/Webhooks/types.ts b/packages/console/src/pages/Webhooks/types.ts deleted file mode 100644 index 42432e313..000000000 --- a/packages/console/src/pages/Webhooks/types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { type Hook, type HookConfig, type HookEvent } from '@logto/schemas'; - -export type BasicWebhookFormType = { - name: Hook['name']; - events: HookEvent[]; - url: HookConfig['url']; -};