0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

chore: reorg webhook-related file structures (#4447)

This commit is contained in:
Xiao Yijun 2023-09-07 17:32:55 +08:00 committed by GitHub
parent 2dfce739b1
commit fd08426935
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 16 additions and 22 deletions

View file

@ -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 {

View file

@ -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' });

View file

@ -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';

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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'];
};