feat: v4.0.0 (#1016)
Co-authored-by: Denys Konovalov <kontakt@denyskon.de> Co-authored-by: Mathieu COSYNS <64072917+Mathieu-COSYNS@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
682576ffc4
commit
799c7e6936
@ -39,7 +39,7 @@ const i18n = {
|
||||
items: localeType,
|
||||
uniqueItems: true,
|
||||
},
|
||||
defaultLocale: localeType,
|
||||
default_locale: localeType,
|
||||
},
|
||||
};
|
||||
|
||||
@ -89,6 +89,90 @@ const filterRules = {
|
||||
],
|
||||
};
|
||||
|
||||
const themeColor = (required: boolean) => ({
|
||||
type: 'object',
|
||||
properties: {
|
||||
main: { type: 'string' },
|
||||
light: { type: 'string' },
|
||||
dark: { type: 'string' },
|
||||
contrastColor: { type: 'string' },
|
||||
},
|
||||
required: required ? ['main', 'light', 'dark', 'contrastColor'] : [],
|
||||
});
|
||||
|
||||
const theme = (required: boolean) => ({
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: { type: 'string' },
|
||||
...(required ? {} : { extends: { type: 'string' } }),
|
||||
text: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
primary: { type: 'string' },
|
||||
secondary: { type: 'string' },
|
||||
disabled: { type: 'string' },
|
||||
},
|
||||
required: required ? ['primary', 'secondary', 'disabled'] : [],
|
||||
},
|
||||
background: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
main: { type: 'string' },
|
||||
light: { type: 'string' },
|
||||
dark: { type: 'string' },
|
||||
divider: { type: 'string' },
|
||||
},
|
||||
required: required ? ['main', 'light', 'dark', 'divider'] : [],
|
||||
},
|
||||
scrollbar: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
main: { type: 'string' },
|
||||
light: { type: 'string' },
|
||||
},
|
||||
required: required ? ['main', 'light'] : [],
|
||||
},
|
||||
button: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
disabled: { type: 'string' },
|
||||
},
|
||||
required: required ? ['disabled'] : [],
|
||||
},
|
||||
primary: themeColor(required),
|
||||
error: themeColor(required),
|
||||
warning: themeColor(required),
|
||||
info: themeColor(required),
|
||||
success: themeColor(required),
|
||||
codemirror: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
theme: {
|
||||
type: 'string',
|
||||
examples: ['light', 'dark'],
|
||||
enum: ['light', 'dark'],
|
||||
},
|
||||
},
|
||||
required: required ? ['theme'] : [],
|
||||
},
|
||||
},
|
||||
required: required
|
||||
? [
|
||||
'name',
|
||||
'text',
|
||||
'background',
|
||||
'scrollbar',
|
||||
'button',
|
||||
'primary',
|
||||
'error',
|
||||
'warning',
|
||||
'info',
|
||||
'success',
|
||||
'codemirror',
|
||||
]
|
||||
: ['name', 'extends'],
|
||||
});
|
||||
|
||||
/**
|
||||
* Config for fields in both file and folder collections.
|
||||
*/
|
||||
@ -135,6 +219,7 @@ const viewFilters = {
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: { type: 'string' },
|
||||
label: { type: 'string' },
|
||||
field: { type: 'string' },
|
||||
pattern: {
|
||||
@ -149,7 +234,7 @@ const viewFilters = {
|
||||
],
|
||||
},
|
||||
},
|
||||
required: ['label', 'field', 'pattern'],
|
||||
required: ['name', 'label', 'field', 'pattern'],
|
||||
},
|
||||
};
|
||||
|
||||
@ -159,11 +244,12 @@ const viewGroups = {
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: { type: 'string' },
|
||||
label: { type: 'string' },
|
||||
field: { type: 'string' },
|
||||
pattern: { type: 'string' },
|
||||
},
|
||||
required: ['label', 'field'],
|
||||
required: ['name', 'label', 'field'],
|
||||
},
|
||||
};
|
||||
|
||||
@ -213,6 +299,13 @@ function getConfigSchema() {
|
||||
},
|
||||
},
|
||||
use_large_media_transforms_in_media_library: { type: 'boolean' },
|
||||
/**
|
||||
* Editorial Workflow
|
||||
*/
|
||||
always_fork: { type: 'boolean' },
|
||||
open_authoring: { type: 'boolean' },
|
||||
squash_merges: { type: 'boolean' },
|
||||
cms_label_prefix: { type: 'string' },
|
||||
},
|
||||
required: ['name'],
|
||||
},
|
||||
@ -260,8 +353,26 @@ function getConfigSchema() {
|
||||
},
|
||||
required: ['fields'],
|
||||
},
|
||||
view_filters: viewFilters,
|
||||
view_groups: viewGroups,
|
||||
view_filters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
default: {
|
||||
type: 'string',
|
||||
},
|
||||
filters: viewFilters,
|
||||
},
|
||||
required: ['filters'],
|
||||
},
|
||||
view_groups: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
default: {
|
||||
type: 'string',
|
||||
},
|
||||
groups: viewGroups,
|
||||
},
|
||||
required: ['groups'],
|
||||
},
|
||||
i18n: i18nCollection,
|
||||
hide: { type: 'boolean' },
|
||||
editor: {
|
||||
@ -383,10 +494,16 @@ function getConfigSchema() {
|
||||
media_library: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
display_in_navigation: { type: 'boolean' },
|
||||
max_file_size: { type: 'number' },
|
||||
folder_support: { type: 'boolean' },
|
||||
},
|
||||
},
|
||||
publish_mode: {
|
||||
type: 'string',
|
||||
enum: ['simple', 'editorial_workflow'],
|
||||
examples: ['editorial_workflow'],
|
||||
},
|
||||
slug: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
@ -420,16 +537,30 @@ function getConfigSchema() {
|
||||
},
|
||||
},
|
||||
search: { type: 'boolean' },
|
||||
theme: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
defaultTheme: { type: 'string' },
|
||||
includeStandardThemes: { type: 'boolean' },
|
||||
themes: {
|
||||
type: 'array',
|
||||
items: { oneOf: [theme(true), theme(false)] },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['backend', 'collections', 'media_folder'],
|
||||
};
|
||||
}
|
||||
|
||||
function getWidgetSchemas() {
|
||||
const schemas = getWidgets().reduce((acc, widget) => {
|
||||
acc[widget.name] = widget.schema ?? {};
|
||||
return acc;
|
||||
}, {} as Record<string, unknown>);
|
||||
const schemas = getWidgets().reduce(
|
||||
(acc, widget) => {
|
||||
acc[widget.name] = widget.schema ?? {};
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, unknown>,
|
||||
);
|
||||
return { ...schemas };
|
||||
}
|
||||
|
||||
|
9
packages/core/src/constants/enums.ts
Normal file
9
packages/core/src/constants/enums.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export enum PreviewState {
|
||||
Other = 'other',
|
||||
Success = 'success',
|
||||
}
|
||||
|
||||
export enum CollectionType {
|
||||
FOLDER,
|
||||
FILES,
|
||||
}
|
@ -2,11 +2,13 @@ import React from 'react';
|
||||
|
||||
import type { InferredField } from '../interface';
|
||||
|
||||
export type InferrableField = 'title' | 'shortTitle' | 'author' | 'date' | 'description' | 'image';
|
||||
|
||||
export const IDENTIFIER_FIELDS = ['title', 'path'] as const;
|
||||
|
||||
export const SORTABLE_FIELDS = ['title', 'date', 'author', 'description'] as const;
|
||||
export const SORTABLE_FIELDS = ['title', 'date', 'author', 'description'] as InferrableField[];
|
||||
|
||||
export const INFERABLE_FIELDS: Record<string, InferredField> = {
|
||||
export const INFERABLE_FIELDS: Record<InferrableField, InferredField> = {
|
||||
title: {
|
||||
type: 'string',
|
||||
secondaryTypes: [],
|
||||
|
30
packages/core/src/constants/publishModes.ts
Normal file
30
packages/core/src/constants/publishModes.ts
Normal file
@ -0,0 +1,30 @@
|
||||
// Create/edit workflow modes
|
||||
export const SIMPLE = 'simple';
|
||||
export const EDITORIAL_WORKFLOW = 'editorial_workflow';
|
||||
|
||||
export type Workflow = typeof SIMPLE | typeof EDITORIAL_WORKFLOW;
|
||||
|
||||
export enum WorkflowStatus {
|
||||
DRAFT = 'draft',
|
||||
PENDING_REVIEW = 'pending_review',
|
||||
PENDING_PUBLISH = 'pending_publish',
|
||||
}
|
||||
|
||||
export const STATUS_DESCRIPTIONS: Record<WorkflowStatus, string> = {
|
||||
[WorkflowStatus.DRAFT]: 'Draft',
|
||||
[WorkflowStatus.PENDING_REVIEW]: 'Waiting for Review',
|
||||
[WorkflowStatus.PENDING_PUBLISH]: 'Waiting to go live',
|
||||
};
|
||||
|
||||
export function workflowStatusFromString(status: string) {
|
||||
switch (status.toLowerCase()) {
|
||||
case 'draft':
|
||||
return WorkflowStatus.DRAFT;
|
||||
case 'pending_review':
|
||||
return WorkflowStatus.PENDING_REVIEW;
|
||||
case 'pending_publish':
|
||||
return WorkflowStatus.PENDING_PUBLISH;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ export const VIEW_STYLES = [VIEW_STYLE_TABLE, VIEW_STYLE_GRID];
|
||||
export const COLLECTION_CARD_WIDTH = 240;
|
||||
export const COLLECTION_CARD_HEIGHT = 204;
|
||||
export const COLLECTION_CARD_IMAGE_HEIGHT = 140;
|
||||
export const COLLECTION_CARD_HEIGHT_WITHOUT_IMAGE = 64;
|
||||
export const COLLECTION_CARD_HEIGHT_WITHOUT_IMAGE = 56;
|
||||
export const COLLECTION_CARD_MARGIN = 10;
|
||||
|
||||
export const EDITOR_SIZE_COMPACT = 'compact';
|
||||
|
Reference in New Issue
Block a user