feat(SPA): schema list and the sidebar Content group

This commit is contained in:
Florian Sylvain committed 2026-10-19 19:34:45 +02:00
1 parent 73a75d5cb9
commit 3c67cd2314
34 files changed
+2181 -18

No files matched your search

+66
View File
@@ -6445,8 +6445,74 @@ const editorSeoStates: Record<string, VisualState> = {
},
}
const schemaCustomTypes = [
['events', 'Events', 7, '2026-10-15T09:30:00Z'],
['recipes', 'Recipes', 4, '2026-10-02T09:30:00Z'],
['press-mentions', 'Press mentions', 5, '2026-09-18T09:30:00Z'],
].map(([key, name, fieldCount, updatedAt], index) => ({
id: index + 1,
key,
name,
icon: 'files',
fields: Array.from({ length: fieldCount as number }, (_, field) => ({ key: `field_${field}` })),
created_at: '2026-09-01T09:30:00Z',
updated_at: updatedAt,
}))
const schemaBuiltinTypes = [
['articles', 'Articles', 5],
['authors', 'Authors', 5],
['sites', 'Sites', 8],
['media', 'Media', 6],
['users', 'Users', 6],
].map(([key, name, fieldCount]) => ({
key,
name,
fields: Array.from({ length: fieldCount as number }, (_, field) => ({ key: `field_${field}` })),
}))
function schemaSession(role: string): ApiMock {
return {
status: 200,
body: { ...(verifiedSession.body as object), display_name: 'Marta Alves', role },
}
}
function schemaApi(overrides: Record<string, ApiMock> = {}): Record<string, ApiMock> {
return {
'GET /v1/auth/me': schemaSession('owner'),
'GET /v1/content-type': { status: 200, body: schemaCustomTypes },
'GET /v1/builtin-type': { status: 200, body: schemaBuiltinTypes },
...overrides,
}
}
const schemaStates: Record<string, VisualState> = {
Populated: { path: '/schema', api: schemaApi() },
Loading: {
path: '/schema',
api: schemaApi({ 'GET /v1/content-type': { status: 200, hang: true } }),
},
'Empty: no custom type yet': {
path: '/schema',
api: schemaApi({ 'GET /v1/content-type': { status: 200, body: [] } }),
},
Error: {
path: '/schema',
api: schemaApi({ 'GET /v1/content-type': { status: 500 } }),
},
'Forbidden (403)': {
path: '/schema',
api: schemaApi({
'GET /v1/auth/me': schemaSession('user'),
}),
},
'Built-in type: read-only view': { path: '/schema', skip: 'pending' },
}
export const visualStates: Record<string, Record<string, VisualState>> = {
sites: sitesStates,
schema: schemaStates,
authors: authorsStates,
activity: activityStates,
profile: {