chore: better organizes preview types

This commit is contained in:
James
2021-05-10 09:45:43 -04:00
parent 98c3315462
commit f9319bd055
5 changed files with 13 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
import { Data } from '../../forms/Form/types';
import { GeneratePreviewURL } from '../../../../collections/config/types';
import { GeneratePreviewURL } from '../../../../config/types';
export type Props = {
generatePreviewURL?: GeneratePreviewURL,

View File

@@ -1,5 +1,6 @@
import React from 'react';
import format from 'date-fns/format';
import { useConfig } from '@payloadcms/config-provider';
import Eyebrow from '../../elements/Eyebrow';
import Form from '../../forms/Form';
import PreviewButton from '../../elements/PreviewButton';
@@ -12,7 +13,6 @@ import LeaveWithoutSaving from '../../modals/LeaveWithoutSaving';
import { Props } from './types';
import './index.scss';
import { useConfig } from '@payloadcms/config-provider';
const baseClass = 'global-edit';
@@ -82,7 +82,7 @@ const DefaultGlobalView: React.FC<Props> = (props) => {
<div className={`${baseClass}__api-url`}>
<span className={`${baseClass}__label`}>
API URL
{' '}
{' '}
<CopyToClipboard value={apiURL} />
</span>
<a

View File

@@ -1,9 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { DeepRequired } from 'ts-essentials';
import { PaginateModel, PassportLocalModel } from 'mongoose';
import { Access } from '../../config/types';
import { Access, GeneratePreviewURL } from '../../config/types';
import { Field } from '../../fields/config/types';
import { Document } from '../../types';
import { PayloadRequest } from '../../express/types';
import { IncomingAuthType, Auth } from '../../auth/types';
import { IncomingUploadType, Upload } from '../../uploads/types';
@@ -90,13 +89,6 @@ export type AfterForgotPasswordHook = (args?: {
args?: any;
}) => any;
type GeneratePreviewURLOptions = {
locale: string
token: string
}
export type GeneratePreviewURL = (doc: Document, options: GeneratePreviewURLOptions) => string
export type PayloadCollectionConfig = {
slug: string;
labels?: {

View File

@@ -19,6 +19,13 @@ type Email = {
// eslint-disable-next-line no-use-before-define
type Plugin = (config: Config) => Config;
type GeneratePreviewURLOptions = {
locale: string
token: string
}
export type GeneratePreviewURL = (doc: Record<string, unknown>, options: GeneratePreviewURLOptions) => string
export type EmailTransport = Email & {
transport: Transporter;
transportOptions?: SMTPConnection.Options;

View File

@@ -2,7 +2,7 @@ import React from 'react';
import { Model, Document } from 'mongoose';
import { DeepRequired } from 'ts-essentials';
import { PayloadRequest } from '../../express/types';
import { Access } from '../../config/types';
import { Access, GeneratePreviewURL } from '../../config/types';
import { Field } from '../../fields/config/types';
export type BeforeValidateHook = (args?: {
@@ -39,7 +39,7 @@ export type GlobalModel = Model<Document>
export type PayloadGlobalConfig = {
slug: string
label?: string
preview?: (doc: Document, token: string) => string
preview?: GeneratePreviewURL
hooks?: {
beforeValidate?: BeforeValidateHook[]
beforeChange?: BeforeChangeHook[]