@cossackframework/cms 0.0.0-stage → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +147 -2
- package/agent-docs.json +259 -0
- package/app/README.md +78 -0
- package/app/cossack-recipe.json +43 -0
- package/app/src/auth-bot-check.ts +32 -0
- package/app/src/auth-bot-token.ts +11 -0
- package/app/src/auth-input.ts +35 -0
- package/app/src/auth-options.ts +18 -0
- package/app/src/auth-providers.ts +16 -0
- package/app/src/auth.ts +1082 -0
- package/app/src/brand.ts +68 -0
- package/app/src/cms/ai.ts +54 -0
- package/app/src/cms/analytics.ts +33 -0
- package/app/src/cms/block-errors.ts +55 -0
- package/app/src/cms/block-inserter.ts +111 -0
- package/app/src/cms/block-panel.ts +68 -0
- package/app/src/cms/block-rows.ts +44 -0
- package/app/src/cms/block-tree.ts +585 -0
- package/app/src/cms/blocks.css +708 -0
- package/app/src/cms/builder.ts +126 -0
- package/app/src/cms/cache.ts +44 -0
- package/app/src/cms/carousel.client.ts +52 -0
- package/app/src/cms/collab/presence.ts +69 -0
- package/app/src/cms/collab/rich-text-collab.client.ts +197 -0
- package/app/src/cms/collab/rich-text-notes.client.ts +138 -0
- package/app/src/cms/collab/room.ts +881 -0
- package/app/src/cms/compare.client.ts +47 -0
- package/app/src/cms/condition-control.ts +109 -0
- package/app/src/cms/content-api.ts +143 -0
- package/app/src/cms/content.ts +524 -0
- package/app/src/cms/countdown.client.ts +37 -0
- package/app/src/cms/editor-layout-editor.ts +260 -0
- package/app/src/cms/editor-layout-view.ts +37 -0
- package/app/src/cms/editor.ts +381 -0
- package/app/src/cms/entry.ts +26 -0
- package/app/src/cms/feeds.ts +145 -0
- package/app/src/cms/field-controls.ts +222 -0
- package/app/src/cms/field-group-editor.ts +105 -0
- package/app/src/cms/field-group-view.ts +211 -0
- package/app/src/cms/form-view.ts +203 -0
- package/app/src/cms/form.client.ts +203 -0
- package/app/src/cms/guards.ts +27 -0
- package/app/src/cms/handoff.ts +202 -0
- package/app/src/cms/headings.ts +51 -0
- package/app/src/cms/icons.ts +80 -0
- package/app/src/cms/import.client.ts +16 -0
- package/app/src/cms/index.ts +191 -0
- package/app/src/cms/lightbox.client.ts +109 -0
- package/app/src/cms/machine.ts +118 -0
- package/app/src/cms/maintenance.ts +97 -0
- package/app/src/cms/manage.ts +1236 -0
- package/app/src/cms/mcp-tools.ts +388 -0
- package/app/src/cms/mcp.ts +242 -0
- package/app/src/cms/media-chooser.ts +123 -0
- package/app/src/cms/media-usage.ts +57 -0
- package/app/src/cms/middleware.ts +199 -0
- package/app/src/cms/middlewares.ts +13 -0
- package/app/src/cms/network-ui.ts +36 -0
- package/app/src/cms/network-view.ts +38 -0
- package/app/src/cms/notes-announce.ts +65 -0
- package/app/src/cms/notes-rail.ts +207 -0
- package/app/src/cms/notification-rules.ts +66 -0
- package/app/src/cms/recovery.ts +82 -0
- package/app/src/cms/replace.ts +63 -0
- package/app/src/cms/reserved-paths.ts +19 -0
- package/app/src/cms/rich-text-field.ts +325 -0
- package/app/src/cms/rich-text-schema.ts +91 -0
- package/app/src/cms/rich-text.client.ts +255 -0
- package/app/src/cms/search.client.ts +116 -0
- package/app/src/cms/seo-head.ts +78 -0
- package/app/src/cms/seo.ts +241 -0
- package/app/src/cms/settings-draft.ts +218 -0
- package/app/src/cms/settings-file.ts +127 -0
- package/app/src/cms/settings-form.ts +180 -0
- package/app/src/cms/settings-languages.ts +125 -0
- package/app/src/cms/settings-nav.ts +102 -0
- package/app/src/cms/settings-network.ts +151 -0
- package/app/src/cms/settings-permalinks.ts +114 -0
- package/app/src/cms/settings-scroll.ts +10 -0
- package/app/src/cms/settings-search.ts +77 -0
- package/app/src/cms/settings-section.ts +38 -0
- package/app/src/cms/share.client.ts +27 -0
- package/app/src/cms/site-editing.ts +219 -0
- package/app/src/cms/site-editor.client.ts +1008 -0
- package/app/src/cms/site-editor.ts +99 -0
- package/app/src/cms/site-export.ts +60 -0
- package/app/src/cms/site-forms.ts +143 -0
- package/app/src/cms/site-import.ts +28 -0
- package/app/src/cms/site-session.ts +36 -0
- package/app/src/cms/site-taskbar.ts +77 -0
- package/app/src/cms/site-view.ts +1014 -0
- package/app/src/cms/site.ts +1322 -0
- package/app/src/cms/sitemaps.ts +131 -0
- package/app/src/cms/stat.client.ts +56 -0
- package/app/src/cms/style-controls.ts +252 -0
- package/app/src/cms/tabs.client.ts +36 -0
- package/app/src/cms/taskbar.ts +134 -0
- package/app/src/cms/term-icons.ts +10 -0
- package/app/src/cms/traffic.ts +26 -0
- package/app/src/cms/ui.ts +170 -0
- package/app/src/cms/updates.ts +124 -0
- package/app/src/cms/uploads.ts +26 -0
- package/app/src/cms/worker.ts +13 -0
- package/app/src/config/auth.ts +30 -0
- package/app/src/config/cms.ts +18 -0
- package/app/src/dashboard/access.ts +344 -0
- package/app/src/dashboard/agent-icons.ts +44 -0
- package/app/src/dashboard/app-passwords.ts +74 -0
- package/app/src/dashboard/avatar-field.ts +58 -0
- package/app/src/dashboard/bulk.ts +53 -0
- package/app/src/dashboard/head.ts +29 -0
- package/app/src/dashboard/icons.ts +15 -0
- package/app/src/dashboard/list-table.ts +120 -0
- package/app/src/dashboard/modules/roles.ts +15 -0
- package/app/src/dashboard/modules/sessions.ts +15 -0
- package/app/src/dashboard/modules/settings.ts +15 -0
- package/app/src/dashboard/modules/users.ts +18 -0
- package/app/src/dashboard/page.ts +67 -0
- package/app/src/dashboard/registry.ts +13 -0
- package/app/src/dashboard/session-list.ts +98 -0
- package/app/src/dashboard/tabs.ts +26 -0
- package/app/src/dashboard/time-ago.ts +16 -0
- package/app/src/dashboard/types.ts +40 -0
- package/app/src/dashboard/user-sections.ts +172 -0
- package/app/src/lib/permissions.ts +84 -0
- package/app/src/middlewares/auth.ts +117 -0
- package/app/src/pages/(site)/[...path]/index.ts +609 -0
- package/app/src/pages/(site)/feed/[...rest]/index.ts +13 -0
- package/app/src/pages/(site)/feed/index.ts +12 -0
- package/app/src/pages/(site)/index.ts +11 -0
- package/app/src/pages/(site)/indexnow/[file]/index.ts +18 -0
- package/app/src/pages/(site)/layout.ts +219 -0
- package/app/src/pages/(site)/llms.txt/index.ts +23 -0
- package/app/src/pages/(site)/manifest.webmanifest/index.ts +29 -0
- package/app/src/pages/(site)/media/[id]/[name]/index.ts +59 -0
- package/app/src/pages/(site)/preview/[collection]/[id]/index.ts +115 -0
- package/app/src/pages/(site)/robots.txt/index.ts +29 -0
- package/app/src/pages/(site)/search/index.ts +36 -0
- package/app/src/pages/(site)/sitemap.xml/index.ts +26 -0
- package/app/src/pages/(site)/sitemaps/[file]/index.ts +33 -0
- package/app/src/pages/api/auth/session.ts +48 -0
- package/app/src/pages/api/cms/appearance/areas/[name].ts +12 -0
- package/app/src/pages/api/cms/appearance/areas/index.ts +6 -0
- package/app/src/pages/api/cms/appearance/locations/[location].ts +6 -0
- package/app/src/pages/api/cms/appearance/locations/index.ts +6 -0
- package/app/src/pages/api/cms/appearance/menus/[id].ts +12 -0
- package/app/src/pages/api/cms/appearance/menus/index.ts +13 -0
- package/app/src/pages/api/cms/appearance/themes/[name]/activate.ts +6 -0
- package/app/src/pages/api/cms/appearance/themes/index.ts +6 -0
- package/app/src/pages/api/cms/cache/purge.ts +6 -0
- package/app/src/pages/api/cms/collections/index.ts +6 -0
- package/app/src/pages/api/cms/commands/[plugin]/[command].ts +26 -0
- package/app/src/pages/api/cms/comments/[id].ts +9 -0
- package/app/src/pages/api/cms/comments/index.ts +126 -0
- package/app/src/pages/api/cms/comments/queue.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/autosave.ts +27 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/blocks/[block].ts +16 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/notes.ts +18 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/publish.ts +11 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/index.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/restore.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/index.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/unpublish.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry].ts +42 -0
- package/app/src/pages/api/cms/content/[collection]/index.ts +24 -0
- package/app/src/pages/api/cms/export/[collection].ts +37 -0
- package/app/src/pages/api/cms/forms/[slug]/index.ts +173 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/[submission]/files/[file].ts +25 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/export.ts +34 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/index.ts +24 -0
- package/app/src/pages/api/cms/import/[collection].ts +23 -0
- package/app/src/pages/api/cms/mcp.ts +29 -0
- package/app/src/pages/api/cms/me/index.ts +6 -0
- package/app/src/pages/api/cms/me/recent-blocks.ts +37 -0
- package/app/src/pages/api/cms/me/tokens/[id].ts +6 -0
- package/app/src/pages/api/cms/me/tokens/index.ts +13 -0
- package/app/src/pages/api/cms/media/[id].ts +6 -0
- package/app/src/pages/api/cms/media.ts +26 -0
- package/app/src/pages/api/cms/menus/[location].ts +14 -0
- package/app/src/pages/api/cms/network/sites/[id]/export.ts +15 -0
- package/app/src/pages/api/cms/network/sites/[id]/index.ts +9 -0
- package/app/src/pages/api/cms/network/sites/index.ts +14 -0
- package/app/src/pages/api/cms/notes/[id].ts +13 -0
- package/app/src/pages/api/cms/notes/index.ts +6 -0
- package/app/src/pages/api/cms/payments/webhook.ts +28 -0
- package/app/src/pages/api/cms/plugins/[name]/grant.ts +6 -0
- package/app/src/pages/api/cms/plugins/[name]/revoke.ts +6 -0
- package/app/src/pages/api/cms/plugins/index.ts +6 -0
- package/app/src/pages/api/cms/recovery.ts +29 -0
- package/app/src/pages/api/cms/redirects/index.ts +9 -0
- package/app/src/pages/api/cms/roles/index.ts +6 -0
- package/app/src/pages/api/cms/schema/[collection].ts +13 -0
- package/app/src/pages/api/cms/search.ts +16 -0
- package/app/src/pages/api/cms/settings/[group].ts +9 -0
- package/app/src/pages/api/cms/settings/index.ts +9 -0
- package/app/src/pages/api/cms/site-export.ts +34 -0
- package/app/src/pages/api/cms/taxonomies/index.ts +6 -0
- package/app/src/pages/api/cms/terms/[taxonomy]/[id].ts +12 -0
- package/app/src/pages/api/cms/terms/[taxonomy]/index.ts +9 -0
- package/app/src/pages/api/cms/uploads/[id]/complete.ts +15 -0
- package/app/src/pages/api/cms/uploads/[id]/index.ts +15 -0
- package/app/src/pages/api/cms/uploads/index.ts +26 -0
- package/app/src/pages/api/cms/users/[id]/index.ts +12 -0
- package/app/src/pages/api/cms/users/[id]/meta.ts +40 -0
- package/app/src/pages/api/cms/users/index.ts +12 -0
- package/app/src/pages/api/cms/webhooks/[id].ts +6 -0
- package/app/src/pages/api/cms/webhooks/index.ts +9 -0
- package/app/src/pages/auth/[provider]/callback.ts +11 -0
- package/app/src/pages/auth/[provider]/redirect.ts +9 -0
- package/app/src/pages/auth/forgot-password/index.ts +75 -0
- package/app/src/pages/auth/layout.ts +32 -0
- package/app/src/pages/auth/login/index.ts +198 -0
- package/app/src/pages/auth/magic/index.ts +68 -0
- package/app/src/pages/auth/register/index.ts +117 -0
- package/app/src/pages/auth/reset-password/index.ts +65 -0
- package/app/src/pages/auth/setup/index.ts +194 -0
- package/app/src/pages/auth/two-factor/index.ts +67 -0
- package/app/src/pages/auth/verify/index.ts +62 -0
- package/app/src/pages/dashboard/(cms)/appearance/customize/index.ts +263 -0
- package/app/src/pages/dashboard/(cms)/appearance/dashboard-menu/index.ts +241 -0
- package/app/src/pages/dashboard/(cms)/appearance/index.ts +89 -0
- package/app/src/pages/dashboard/(cms)/appearance/menus/[id]/index.ts +697 -0
- package/app/src/pages/dashboard/(cms)/appearance/menus/index.ts +145 -0
- package/app/src/pages/dashboard/(cms)/appearance/widgets/index.ts +279 -0
- package/app/src/pages/dashboard/(cms)/blocks/index.ts +84 -0
- package/app/src/pages/dashboard/(cms)/calendar/index.ts +92 -0
- package/app/src/pages/dashboard/(cms)/collections/[name]/index.ts +525 -0
- package/app/src/pages/dashboard/(cms)/collections/index.ts +72 -0
- package/app/src/pages/dashboard/(cms)/collections/new/index.ts +66 -0
- package/app/src/pages/dashboard/(cms)/comments/index.ts +237 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/index.ts +2382 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/revisions/index.ts +126 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/index.ts +693 -0
- package/app/src/pages/dashboard/(cms)/field-groups/[id]/index.ts +193 -0
- package/app/src/pages/dashboard/(cms)/field-groups/index.ts +65 -0
- package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/[submission]/index.ts +279 -0
- package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/index.ts +170 -0
- package/app/src/pages/dashboard/(cms)/forms/index.ts +171 -0
- package/app/src/pages/dashboard/(cms)/media/[id]/index.ts +317 -0
- package/app/src/pages/dashboard/(cms)/media/index.ts +156 -0
- package/app/src/pages/dashboard/(cms)/media/new/index.ts +9 -0
- package/app/src/pages/dashboard/(cms)/media/summary/index.ts +74 -0
- package/app/src/pages/dashboard/(cms)/my-sites/index.ts +63 -0
- package/app/src/pages/dashboard/(cms)/network/index.ts +53 -0
- package/app/src/pages/dashboard/(cms)/network/plugins/index.ts +110 -0
- package/app/src/pages/dashboard/(cms)/network/sites/[id]/index.ts +243 -0
- package/app/src/pages/dashboard/(cms)/network/sites/index.ts +186 -0
- package/app/src/pages/dashboard/(cms)/network/sites/new/index.ts +77 -0
- package/app/src/pages/dashboard/(cms)/network/themes/index.ts +82 -0
- package/app/src/pages/dashboard/(cms)/network/updates/index.ts +48 -0
- package/app/src/pages/dashboard/(cms)/network/users/[id]/index.ts +176 -0
- package/app/src/pages/dashboard/(cms)/network/users/index.ts +174 -0
- package/app/src/pages/dashboard/(cms)/network/users/new/index.ts +66 -0
- package/app/src/pages/dashboard/(cms)/plugins/index.ts +172 -0
- package/app/src/pages/dashboard/(cms)/profile/public/index.ts +105 -0
- package/app/src/pages/dashboard/(cms)/registrations/index.ts +70 -0
- package/app/src/pages/dashboard/(cms)/settings/index.ts +359 -0
- package/app/src/pages/dashboard/(cms)/settings/json/index.ts +202 -0
- package/app/src/pages/dashboard/(cms)/settings/layout.ts +67 -0
- package/app/src/pages/dashboard/(cms)/taxonomies/[name]/index.ts +85 -0
- package/app/src/pages/dashboard/(cms)/taxonomies/index.ts +98 -0
- package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/[id]/index.ts +244 -0
- package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/index.ts +148 -0
- package/app/src/pages/dashboard/(cms)/tools/activity/index.ts +94 -0
- package/app/src/pages/dashboard/(cms)/tools/automations/index.ts +131 -0
- package/app/src/pages/dashboard/(cms)/tools/cache/index.ts +92 -0
- package/app/src/pages/dashboard/(cms)/tools/export/index.ts +99 -0
- package/app/src/pages/dashboard/(cms)/tools/health/index.ts +189 -0
- package/app/src/pages/dashboard/(cms)/tools/jobs/index.ts +93 -0
- package/app/src/pages/dashboard/(cms)/tools/links/index.ts +115 -0
- package/app/src/pages/dashboard/(cms)/tools/redirects/index.ts +161 -0
- package/app/src/pages/dashboard/(cms)/tools/replace/index.ts +124 -0
- package/app/src/pages/dashboard/(cms)/tools/schema/index.ts +54 -0
- package/app/src/pages/dashboard/(cms)/tools/seo/index.ts +156 -0
- package/app/src/pages/dashboard/(cms)/tools/updates/index.ts +114 -0
- package/app/src/pages/dashboard/(cms)/tools/webhooks/index.ts +182 -0
- package/app/src/pages/dashboard/index.ts +214 -0
- package/app/src/pages/dashboard/layout.ts +320 -0
- package/app/src/pages/dashboard/profile/index.ts +211 -0
- package/app/src/pages/dashboard/profile/security/index.ts +255 -0
- package/app/src/pages/dashboard/roles/[id]/index.ts +116 -0
- package/app/src/pages/dashboard/roles/index.ts +134 -0
- package/app/src/pages/dashboard/roles/new/index.ts +95 -0
- package/app/src/pages/dashboard/sessions/index.ts +105 -0
- package/app/src/pages/dashboard/users/[id]/index.ts +472 -0
- package/app/src/pages/dashboard/users/index.ts +299 -0
- package/app/src/pages/dashboard/users/new/index.ts +123 -0
- package/app/src/passkeys.client.ts +18 -0
- package/app/src/plugins/default-theme/assets/cover.svg +31 -0
- package/app/src/plugins/default-theme/assets/logo.svg +8 -0
- package/app/src/plugins/default-theme/parts/comments.ts +66 -0
- package/app/src/plugins/default-theme/parts/list.ts +38 -0
- package/app/src/plugins/default-theme/parts/media.ts +15 -0
- package/app/src/plugins/default-theme/parts/options.ts +45 -0
- package/app/src/plugins/default-theme/plugin.json +275 -0
- package/app/src/plugins/default-theme/templates/archive.ts +14 -0
- package/app/src/plugins/default-theme/templates/entry-blank.ts +13 -0
- package/app/src/plugins/default-theme/templates/entry.ts +27 -0
- package/app/src/plugins/default-theme/templates/home.ts +8 -0
- package/app/src/plugins/default-theme/templates/layout.ts +40 -0
- package/app/src/plugins/default-theme/templates/not-found.ts +10 -0
- package/app/src/plugins/default-theme/templates/search.ts +32 -0
- package/app/src/services/rbac.ts +65 -0
- package/app/src/services/roles.ts +89 -0
- package/app/src/services/users.ts +173 -0
- package/package.json +123 -3
- package/src/automations.ts +95 -0
- package/src/bindings.ts +138 -0
- package/src/block-references.ts +239 -0
- package/src/block-shape.ts +155 -0
- package/src/blocks.ts +1157 -0
- package/src/cache.ts +54 -0
- package/src/checks.ts +198 -0
- package/src/cloudflare-workers.d.ts +13 -0
- package/src/cloudflare.ts +61 -0
- package/src/collab.ts +372 -0
- package/src/collections.ts +421 -0
- package/src/comments.ts +46 -0
- package/src/cron.ts +95 -0
- package/src/dashboard-menu.ts +105 -0
- package/src/diff.ts +113 -0
- package/src/editor-layout.ts +316 -0
- package/src/errors.ts +50 -0
- package/src/field-groups.ts +498 -0
- package/src/fields.ts +411 -0
- package/src/form-builder.ts +1053 -0
- package/src/forms.ts +109 -0
- package/src/highlight.ts +134 -0
- package/src/hooks.ts +510 -0
- package/src/icon-catalog.ts +55 -0
- package/src/icons.ts +128 -0
- package/src/images.ts +149 -0
- package/src/index.ts +100 -0
- package/src/isolate-core.ts +245 -0
- package/src/isolate.ts +19 -0
- package/src/isolation.ts +69 -0
- package/src/mail.ts +182 -0
- package/src/manifest.ts +476 -0
- package/src/media.ts +193 -0
- package/src/menus.ts +287 -0
- package/src/module.ts +32 -0
- package/src/modules/content.ts +64 -0
- package/src/modules/forms.ts +35 -0
- package/src/node.ts +66 -0
- package/src/notes.ts +237 -0
- package/src/permissions.ts +139 -0
- package/src/plugin-settings.ts +114 -0
- package/src/records.ts +56 -0
- package/src/redirects.ts +59 -0
- package/src/resource.ts +245 -0
- package/src/richtext.ts +402 -0
- package/src/schema-json.ts +112 -0
- package/src/search.ts +89 -0
- package/src/seo.ts +477 -0
- package/src/server/accounts.ts +418 -0
- package/src/server/ai.ts +33 -0
- package/src/server/api-tokens.ts +91 -0
- package/src/server/areas.ts +116 -0
- package/src/server/audit.ts +94 -0
- package/src/server/auth.ts +89 -0
- package/src/server/automations.ts +190 -0
- package/src/server/autosaves.ts +69 -0
- package/src/server/brand-icons.ts +50 -0
- package/src/server/brands.ts +86 -0
- package/src/server/budget.ts +97 -0
- package/src/server/cache.ts +104 -0
- package/src/server/capabilities.ts +333 -0
- package/src/server/cloudflare.ts +92 -0
- package/src/server/comments.ts +237 -0
- package/src/server/drafts.ts +176 -0
- package/src/server/field-groups.ts +88 -0
- package/src/server/files.ts +780 -0
- package/src/server/forms.ts +726 -0
- package/src/server/handoffs.ts +107 -0
- package/src/server/host-schema.ts +312 -0
- package/src/server/host.ts +2892 -0
- package/src/server/images.ts +34 -0
- package/src/server/index.ts +59 -0
- package/src/server/indexnow.ts +91 -0
- package/src/server/isolation.ts +183 -0
- package/src/server/locked.ts +45 -0
- package/src/server/mail.ts +93 -0
- package/src/server/markdown.ts +24 -0
- package/src/server/menus.ts +286 -0
- package/src/server/network-policy.ts +60 -0
- package/src/server/network.ts +665 -0
- package/src/server/notes.ts +275 -0
- package/src/server/outbox.ts +213 -0
- package/src/server/path-moves.ts +33 -0
- package/src/server/payments.ts +59 -0
- package/src/server/previews.ts +62 -0
- package/src/server/purge.ts +140 -0
- package/src/server/reconcile.ts +38 -0
- package/src/server/redirects.ts +183 -0
- package/src/server/repository.ts +1107 -0
- package/src/server/schedules.ts +105 -0
- package/src/server/schema.ts +562 -0
- package/src/server/security.ts +391 -0
- package/src/server/seed.ts +52 -0
- package/src/server/shared-fields.ts +34 -0
- package/src/server/site-export.ts +151 -0
- package/src/server/site-import.ts +482 -0
- package/src/server/site-search.ts +289 -0
- package/src/server/site-settings.ts +286 -0
- package/src/server/sites.ts +243 -0
- package/src/server/stores.ts +314 -0
- package/src/server/stripe.ts +173 -0
- package/src/server/taxonomies.ts +415 -0
- package/src/server/tokens.ts +25 -0
- package/src/server/traffic.ts +118 -0
- package/src/server/users.ts +653 -0
- package/src/server/webhooks.ts +245 -0
- package/src/settings-controls.ts +54 -0
- package/src/settings-document.ts +111 -0
- package/src/settings.ts +426 -0
- package/src/storage/cloudflare.ts +94 -0
- package/src/storage/index.ts +30 -0
- package/src/storage/node.ts +114 -0
- package/src/taxonomy.ts +51 -0
- package/src/theme.ts +1135 -0
- package/src/to-markdown.ts +179 -0
- package/src/updates.ts +126 -0
- package/src/version.ts +2 -0
- package/src/vite.d.ts +25 -0
- package/src/vite.js +199 -0
- package/src/webhooks.ts +107 -0
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import { Cossack, Page, State, Server, Client, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { input } from '@cossackframework/core/input';
|
|
3
|
+
import { AlertDialog, Badge, Button, Card, CardBody, CardHeader, Checkbox, Field, Input, NativeSelect, Tabs, Textarea } from '@cossackframework/ui';
|
|
4
|
+
import { html, component, type TemplateResult } from '@cossackframework/renderer';
|
|
5
|
+
import { bindingPaths, findBlock, flattenBlocks, flattenGroupFields, hasPermission, isCmsError, PERMISSIONS, RESERVED_FIELDS, SCHEMA_PROPERTIES, SCHEMA_TYPE_LABELS, SCHEMA_TYPES, SEO_TEMPLATE_VARIABLES, updateBlock, type Block, type RichTextDoc, type SchemaType, type ThemePresets } from '@cossackframework/cms';
|
|
6
|
+
import { collectionDraft, definitionOf, type CollectionDraft } from '#app/cms/builder';
|
|
7
|
+
import { blockPanel } from '#app/cms/block-panel';
|
|
8
|
+
import { BlockTree } from '#app/cms/block-tree';
|
|
9
|
+
import { blockFilePreviews, blockOptions, findMedia, optionsOf, sourceChoices } from '#app/cms/content';
|
|
10
|
+
import { EditorLayoutEditor, type EditorLayoutDraft } from '#app/cms/editor-layout-editor';
|
|
11
|
+
import { CORE_FIELDS, editorBoxes, editorLayoutTypes, resolveEditorLayout, type EditorBox, type EditorLayout, type EditorLayoutAddition } from '@cossackframework/cms';
|
|
12
|
+
import { blocksInput, controlValue, editorBlocks, editorInput, type BlockOption, type EditorBlock, type EditorField, type SourceChoices } from '#app/cms/editor';
|
|
13
|
+
import { bindingChoices, blockFields, moveItem, type BindingChoice, type MediaHooks, type MediaPreview } from '#app/cms/field-controls';
|
|
14
|
+
import { requireAny } from '#app/cms/guards';
|
|
15
|
+
import { iconSelect } from '#app/cms/term-icons';
|
|
16
|
+
import { chooserKind, closedChooser, mediaChooser, uploadMedia, withFile, type MediaChooserState } from '#app/cms/media-chooser';
|
|
17
|
+
import { RichTextField, richTextEditors } from '#app/cms/rich-text-field';
|
|
18
|
+
import { activePresets } from '#app/cms/site';
|
|
19
|
+
import { styleValues, withStyle, type BlockTab, type StyleValues } from '#app/cms/style-controls';
|
|
20
|
+
import { iconButton, linkButton, notice, pageHeader, rememberTab, tabFromQuery } from '#app/cms/ui';
|
|
21
|
+
|
|
22
|
+
/** The template block being edited in the panel. */
|
|
23
|
+
interface BlockDialog { id: string; values: Record<string, unknown>; style: StyleValues; tab: BlockTab; errors: Record<string, string> }
|
|
24
|
+
|
|
25
|
+
/** A field group as the manager lists it: attached in this order, with its fields for the template's bindings. */
|
|
26
|
+
interface GroupRow { id: string; title: string; placement: 'main' | 'sidebar'; fields: { name: string; label: string; kind: string }[]; /** The plugin it comes from, which attaches it; empty for a group made here. */ plugin: string }
|
|
27
|
+
|
|
28
|
+
/** The manager's tabs: the collection's settings, how search engines see its entries, and the arrangement of its entry editor. */
|
|
29
|
+
const TABS = ['general', 'seo', 'editor'] as const;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/** The bindable kind of a field block's type. */
|
|
33
|
+
const BINDABLE: Record<string, EditorField['kind']> = { text: 'string', textarea: 'text', markdown: 'text', number: 'number', integer: 'integer', boolean: 'boolean', choice: 'enum', date: 'datetime' };
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Define a collection in three parts: its features (the standard fields and behaviours, as
|
|
37
|
+
* toggles), the field groups attached to it in order, and the content template new entries
|
|
38
|
+
* start with. Saving changes no data; attaching and detaching groups adds and drops indexes.
|
|
39
|
+
*/
|
|
40
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageCollections)] })
|
|
41
|
+
export default class CollectionBuilder extends Cossack {
|
|
42
|
+
@State() draft: CollectionDraft | null = null;
|
|
43
|
+
/** Fields the module declares by hand, which the manager shows but does not edit. */
|
|
44
|
+
@State() builtinFields: string[] = [];
|
|
45
|
+
/** The module's features, which stay on. */
|
|
46
|
+
@State() builtinFeatures: string[] = [];
|
|
47
|
+
@State() builtinTaxonomies: string[] = [];
|
|
48
|
+
/** The groups attached to the collection, in order. */
|
|
49
|
+
@State() groups: GroupRow[] = [];
|
|
50
|
+
/** Groups that exist and are not attached. */
|
|
51
|
+
@State() available: { id: string; title: string }[] = [];
|
|
52
|
+
/** The group picked to attach. */
|
|
53
|
+
@State() attaching = '';
|
|
54
|
+
@State() taxonomies: { name: string; label: string }[] = [];
|
|
55
|
+
@State() blocks: { name: string; label: string }[] = [];
|
|
56
|
+
@State() targets: { name: string; label: string }[] = [];
|
|
57
|
+
/** Fields structured data can map to: the collection's own and its groups', with labels. */
|
|
58
|
+
@State() fieldNames: { name: string; label: string }[] = [];
|
|
59
|
+
@State() message = '';
|
|
60
|
+
@State() error = '';
|
|
61
|
+
@State() confirmDelete = false;
|
|
62
|
+
/** The content template: the blocks a new entry starts with, held as control values while edited. */
|
|
63
|
+
@State() template: EditorBlock[] = [];
|
|
64
|
+
@State() options: BlockOption[] = [];
|
|
65
|
+
@State() previews: Record<string, MediaPreview> = {};
|
|
66
|
+
@State() presets: Required<ThemePresets> = { colors: [], gradients: [], fontSizes: [], spacing: [] };
|
|
67
|
+
/** What template blocks' form, collection and term fields choose from. */
|
|
68
|
+
@State() sources: SourceChoices = { forms: [], collections: [], terms: [], locations: [], authors: [], roles: [] };
|
|
69
|
+
@State() dialog: BlockDialog | null = null;
|
|
70
|
+
@State() chooser: MediaChooserState = closedChooser();
|
|
71
|
+
@State() tab: (typeof TABS)[number] = 'general';
|
|
72
|
+
/** The editor layout as control values: the stored one or the default, with what active plugins add, boxes that are gone kept and marked. */
|
|
73
|
+
@State() layout: EditorLayoutDraft = { tabs: [], sidebar: [] };
|
|
74
|
+
@State() boxes: EditorBox[] = [];
|
|
75
|
+
@State() layoutOptions: BlockOption[] = [];
|
|
76
|
+
@State() missing: string[] = [];
|
|
77
|
+
@State() added: Record<string, string> = {};
|
|
78
|
+
@State() additions: EditorLayoutAddition[] = [];
|
|
79
|
+
/** The layout is stored, or was changed here, so saving the collection keeps it. */
|
|
80
|
+
@State() layoutStored = false;
|
|
81
|
+
|
|
82
|
+
head(): HeadValue {
|
|
83
|
+
return { title: this.draft ? `${this.draft.label} — ${__('Collection')}` : __('Collection') };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async init() {
|
|
87
|
+
await this.load(this.c.req.param('name') ?? '');
|
|
88
|
+
if (this.c.req.query('created') === '1') this.message = __('Collection created. Add its fields, then save.');
|
|
89
|
+
this.tab = tabFromQuery(this.c.req.query('tab'), TABS);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@Server()
|
|
93
|
+
async load(name: string) {
|
|
94
|
+
const cms = this.c.get('cms');
|
|
95
|
+
let definition;
|
|
96
|
+
try { definition = cms.collection(name); }
|
|
97
|
+
catch { this.error = __('This collection does not exist.'); this.c.status(404); return; }
|
|
98
|
+
if (definition.managed) { this.error = __('This collection is managed by its module and has its own screens.'); this.c.status(404); return; }
|
|
99
|
+
const builtin = cms.builtinCollection(name);
|
|
100
|
+
this.draft = collectionDraft(definition);
|
|
101
|
+
this.builtinTaxonomies = [...(builtin?.taxonomies ?? [])];
|
|
102
|
+
this.builtinFields = Object.keys(builtin?.fields ?? {});
|
|
103
|
+
this.builtinFeatures = Object.entries(builtin?.features ?? {}).filter(([, on]) => on).map(([feature]) => feature);
|
|
104
|
+
const attached = cms.fieldGroupsFor({ kind: 'collection', name });
|
|
105
|
+
this.groups = attached.map(group => ({ id: group.id, title: group.title, placement: group.placement ?? 'main', fields: this.groupFields(group.blocks), plugin: group.plugin ?? '' }));
|
|
106
|
+
this.available = (await cms.fieldGroups.all()).filter(group => !attached.some(entry => entry.id === group.id)).map(group => ({ id: group.id, title: group.title }));
|
|
107
|
+
this.attaching = '';
|
|
108
|
+
this.taxonomies = cms.taxonomies.declarations.map(taxonomy => ({ name: taxonomy.name, label: taxonomy.label }));
|
|
109
|
+
this.blocks = (await cms.blocks()).map(block => ({ name: block.name, label: block.label }));
|
|
110
|
+
this.targets = cms.collections().map(collection => ({ name: collection.name, label: collection.label }));
|
|
111
|
+
const resource = cms.resourceById(`cms/${name}`);
|
|
112
|
+
this.fieldNames = Object.entries(resource.fields).filter(([field, declaration]) => !['slug', 'status', 'parent', 'menuOrder', 'seo', 'locale', 'translationGroup', 'commentsOpen', 'template', 'password', 'content'].includes(field) && !['blocks', 'richtext', 'json', 'vector', 'bigint'].includes(declaration.kind))
|
|
113
|
+
.map(([field, declaration]) => ({ name: field, label: declaration.label ?? field }));
|
|
114
|
+
// The template is built from the same blocks as entries, patterns, form inputs and field blocks aside.
|
|
115
|
+
const options = await blockOptions(cms);
|
|
116
|
+
this.options = options.filter(option => option.name !== 'core/pattern' && !option.input && !option.field);
|
|
117
|
+
this.template = editorBlocks((definition.template ?? []) as EditorBlock[], options);
|
|
118
|
+
this.previews = await blockFilePreviews(cms, this.template);
|
|
119
|
+
this.presets = await activePresets(cms);
|
|
120
|
+
this.sources = await sourceChoices(cms);
|
|
121
|
+
// The editor's boxes and their arrangement; the layout's block types offer the boxes as the Box block's choices.
|
|
122
|
+
this.boxes = editorBoxes({ collection: definition, fields: resource.fields, groups: attached, taxonomies: this.taxonomies.filter(taxonomy => (definition.taxonomies ?? []).includes(taxonomy.name)), special: CORE_FIELDS });
|
|
123
|
+
this.additions = cms.editorLayoutAdditions(name);
|
|
124
|
+
const resolved = resolveEditorLayout(definition.editor, this.boxes, this.additions, { keep: true });
|
|
125
|
+
this.missing = resolved.missing;
|
|
126
|
+
this.added = resolved.added;
|
|
127
|
+
this.layoutOptions = optionsOf(editorLayoutTypes(this.boxes, resolved.missing));
|
|
128
|
+
this.layout = { tabs: editorBlocks(resolved.tabs as EditorBlock[], this.layoutOptions), sidebar: editorBlocks(resolved.sidebar as EditorBlock[], this.layoutOptions) };
|
|
129
|
+
this.layoutStored = definition.editor !== undefined;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@Client()
|
|
133
|
+
showTab(tab: (typeof TABS)[number]) {
|
|
134
|
+
this.tab = tab;
|
|
135
|
+
rememberTab(tab, TABS);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@Client()
|
|
139
|
+
changeLayout(layout: EditorLayoutDraft) {
|
|
140
|
+
this.layout = layout;
|
|
141
|
+
this.layoutStored = true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@Client()
|
|
145
|
+
setDraft<K extends keyof CollectionDraft>(key: K, value: CollectionDraft[K]) {
|
|
146
|
+
if (this.draft) this.draft = { ...this.draft, [key]: value };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@Client()
|
|
150
|
+
toggleTaxonomy(name: string, checked: boolean) {
|
|
151
|
+
if (!this.draft) return;
|
|
152
|
+
this.setDraft('taxonomies', checked ? [...new Set([...this.draft.taxonomies, name])] : this.draft.taxonomies.filter(entry => entry !== name));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** A group's fields at any depth, with the kind a template binding may show. */
|
|
156
|
+
private groupFields(blocks: readonly Block[]): GroupRow['fields'] {
|
|
157
|
+
return flattenGroupFields(blocks).flatMap(block => {
|
|
158
|
+
const name = String(block.data.name ?? '');
|
|
159
|
+
return name ? [{ name, label: String(block.data.label ?? name), kind: BINDABLE[block.type.replace(/^field\//, '')] ?? '' }] : [];
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@Client()
|
|
164
|
+
moveGroup(index: number, delta: number) {
|
|
165
|
+
this.groups = moveItem(this.groups, index, delta);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@Client()
|
|
169
|
+
detachGroup(id: string) {
|
|
170
|
+
const group = this.groups.find(entry => entry.id === id);
|
|
171
|
+
this.groups = this.groups.filter(entry => entry.id !== id);
|
|
172
|
+
if (group) this.available = [...this.available, { id: group.id, title: group.title }];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Attach a group: its fields are read on the server, so the template's bindings know them. */
|
|
176
|
+
@Server()
|
|
177
|
+
async attachGroup(id: string) {
|
|
178
|
+
if (!hasPermission(this.c.get('principal'), PERMISSIONS.manageCollections) || this.groups.some(entry => entry.id === id)) return;
|
|
179
|
+
const group = await this.c.get('cms').fieldGroups.get(id);
|
|
180
|
+
if (!group) return;
|
|
181
|
+
this.groups = [...this.groups, { id: group.id, title: group.title, placement: group.placement ?? 'main', fields: this.groupFields(group.blocks), plugin: group.plugin ?? '' }];
|
|
182
|
+
this.available = this.available.filter(entry => entry.id !== id);
|
|
183
|
+
this.attaching = '';
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@Client()
|
|
187
|
+
async submit() {
|
|
188
|
+
if (!this.draft) return;
|
|
189
|
+
await this.save(this.draft, this.groups.map(group => group.id), this.template, this.layoutStored ? this.layout : null);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@Server()
|
|
193
|
+
async save(input: CollectionDraft, groups: string[], template: EditorBlock[] = [], layout: EditorLayoutDraft | null = null) {
|
|
194
|
+
this.error = '';
|
|
195
|
+
this.message = '';
|
|
196
|
+
// The collection is the one this address edits, whatever the draft names; new ones start on their own page.
|
|
197
|
+
const name = this.c.req.param('name') ?? '';
|
|
198
|
+
if (!this.c.get('cms').collections().some(collection => collection.name === name)) { this.error = __('Collection not found.'); return; }
|
|
199
|
+
const draft: CollectionDraft = { ...input, name };
|
|
200
|
+
// The block types are read again here: the template is checked against what the host has.
|
|
201
|
+
const options = await blockOptions(this.c.get('cms'));
|
|
202
|
+
const types = new Map(options.map(option => [option.name, option]));
|
|
203
|
+
const converted = blocksInput(template, types);
|
|
204
|
+
if ('error' in converted) { this.error = `${__('Content template')}: ${converted.error}`; return; }
|
|
205
|
+
// The layout's boxes are checked by name, so a box that is not available now (a detached group's) is kept.
|
|
206
|
+
const layoutTypes = new Map(optionsOf(editorLayoutTypes()).map(option => [option.name, option]));
|
|
207
|
+
const tabs = layout ? blocksInput(layout.tabs, layoutTypes) : { value: [] };
|
|
208
|
+
const sidebar = layout ? blocksInput(layout.sidebar, layoutTypes) : { value: [] };
|
|
209
|
+
if ('error' in tabs) { this.error = `${__('Editor layout')}: ${tabs.error}`; return; }
|
|
210
|
+
if ('error' in sidebar) { this.error = `${__('Editor layout')}: ${sidebar.error}`; return; }
|
|
211
|
+
const editor: EditorLayout | undefined = layout ? { tabs: tabs.value as Block[], sidebar: sidebar.value as Block[] } : undefined;
|
|
212
|
+
try {
|
|
213
|
+
const saved = await this.c.get('cms').saveCollection(definitionOf(draft, converted.value as Block[], editor), this.c.get('principal'), { groups: groups.map((id, order) => ({ id, order })) });
|
|
214
|
+
await this.load(saved.name);
|
|
215
|
+
this.message = __('Collection saved.');
|
|
216
|
+
} catch (error) {
|
|
217
|
+
this.error = isCmsError(error) ? error.message : __('The collection could not be saved.');
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@Server()
|
|
222
|
+
async remove() {
|
|
223
|
+
try {
|
|
224
|
+
await this.c.get('cms').deleteCollection(this.c.req.param('name') ?? '', this.c.get('principal'));
|
|
225
|
+
return this.redirect('/dashboard/collections');
|
|
226
|
+
} catch (error) {
|
|
227
|
+
this.error = isCmsError(error) ? error.message : __('The collection could not be deleted.');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// --- The content template ---------------------------------------------------------
|
|
232
|
+
|
|
233
|
+
@Client()
|
|
234
|
+
private changeTemplate(blocks: EditorBlock[]) {
|
|
235
|
+
this.template = blocks;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
@Client()
|
|
239
|
+
editTemplateBlock(id: string) {
|
|
240
|
+
const block = findBlock(this.template, id);
|
|
241
|
+
const option = this.options.find(entry => entry.name === block?.type);
|
|
242
|
+
if (!block || !option) return;
|
|
243
|
+
this.dialog = { id, errors: {}, tab: 'general', style: styleValues(block), values: Object.fromEntries(option.fields.filter(field => field.kind !== 'richtext').map(field => [field.name, block.data[field.name] ?? controlValue(field, field.defaultValue)])) };
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
@Client()
|
|
247
|
+
setDialogValue(name: string, value: unknown) {
|
|
248
|
+
if (this.dialog) this.applyDialog({ ...this.dialog, values: { ...this.dialog.values, [name]: value }, errors: { ...this.dialog.errors, [name]: '' } });
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@Client()
|
|
252
|
+
setDialogStyle(style: StyleValues) {
|
|
253
|
+
if (this.dialog) this.applyDialog({ ...this.dialog, style });
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** The panel's values and style go into the template block at once; a value its field cannot take stays in the panel with its message. */
|
|
257
|
+
@Client()
|
|
258
|
+
applyDialog(dialog: BlockDialog) {
|
|
259
|
+
const block = findBlock(this.template, dialog.id);
|
|
260
|
+
const option = this.options.find(entry => entry.name === block?.type);
|
|
261
|
+
if (!block || !option) return;
|
|
262
|
+
const fields = option.fields.filter(field => field.kind !== 'richtext');
|
|
263
|
+
const { input, errors } = editorInput(fields, dialog.values);
|
|
264
|
+
this.dialog = { ...dialog, errors: { ...dialog.errors, ...errors } };
|
|
265
|
+
this.template = updateBlock(this.template, dialog.id, entry => withStyle({ ...entry, data: { ...Object.fromEntries(Object.entries(entry.data).filter(([name]) => option.fields.find(field => field.name === name)?.kind === 'richtext')), ...input } }, dialog.style));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** The collection's fields a template block's text may show (`{{ $.price }}`): the title, the excerpt and the attached groups' text-like fields. */
|
|
269
|
+
private bindings(): BindingChoice[] {
|
|
270
|
+
const own = this.groups.flatMap(group => group.fields).flatMap(field => field.kind ? [{ name: field.name, label: field.label, kind: field.kind as EditorField['kind'], media: false }] : []);
|
|
271
|
+
return bindingChoices([{ name: 'title', label: __('Title'), kind: 'string', media: false }, ...(this.draft?.excerpt ? [{ name: 'excerpt', label: __('Excerpt'), kind: 'text' as const, media: false }] : []), ...own]);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** Template bindings that name no field of the collection: a detached group's, or a renamed one. The site shows them empty. */
|
|
275
|
+
private unresolvedBindings(): string[] {
|
|
276
|
+
const known = new Set([...RESERVED_FIELDS, ...(this.draft?.taxonomies ?? []), ...this.builtinFields, ...this.groups.flatMap(group => group.fields.map(field => field.name))]);
|
|
277
|
+
const paths = flattenBlocks(this.template as unknown as Block[]).flatMap(block => Object.values(block.data).flatMap(value => bindingPaths(value)));
|
|
278
|
+
return [...new Set(paths.filter(path => !known.has(path.split('.')[0]!)))];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
@Server({ input: input.args(input.string({ maxLength: 2000 })) })
|
|
282
|
+
async searchMedia(search: string) {
|
|
283
|
+
if (!hasPermission(this.c.get('principal'), PERMISSIONS.manageCollections)) return;
|
|
284
|
+
this.chooser = { ...this.chooser, search, items: await findMedia(this.c.get('cms'), search, this.chooser.kind) };
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
@Client()
|
|
288
|
+
async openChooser(field: string, multiple: boolean, kind = 'image') {
|
|
289
|
+
this.chooser = { ...this.chooser, open: true, error: '', field, multiple, kind };
|
|
290
|
+
await this.searchMedia(this.chooser.search);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
@Client()
|
|
294
|
+
async filterMedia(kind: string) {
|
|
295
|
+
this.chooser = { ...this.chooser, kind };
|
|
296
|
+
await this.searchMedia(this.chooser.search);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
@Client()
|
|
300
|
+
chooseFile(file: MediaPreview) {
|
|
301
|
+
this.previews = { ...this.previews, [file.id]: file };
|
|
302
|
+
if (this.chooser.field.startsWith('editor:')) {
|
|
303
|
+
richTextEditors.get(this.chooser.field.slice('editor:'.length))?.insertImage({ src: file.url, alt: file.alt || file.title, mediaId: file.id });
|
|
304
|
+
this.chooser = { ...this.chooser, open: false };
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
this.setDialogValue(this.chooser.field, withFile(this.dialog?.values[this.chooser.field], file.id, this.chooser.multiple));
|
|
308
|
+
if (!this.chooser.multiple) this.chooser = { ...this.chooser, open: false };
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
@Client()
|
|
312
|
+
async uploadFile(event: Event) {
|
|
313
|
+
const { files, error } = await uploadMedia(event.currentTarget as HTMLInputElement);
|
|
314
|
+
this.chooser = { ...this.chooser, error };
|
|
315
|
+
for (const file of files) this.chooseFile(file);
|
|
316
|
+
await this.searchMedia('');
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** A rich text block's text, written in the tree: the words every new entry starts with. */
|
|
320
|
+
private templateControl(field: EditorField, value: unknown, change: (value: unknown) => void, id: string): TemplateResult | null {
|
|
321
|
+
if (field.kind !== 'richtext') return null;
|
|
322
|
+
return component(RichTextField, {
|
|
323
|
+
id, label: field.label, value: (value as RichTextDoc | null) ?? null, blocks: [], placeholder: __('Starting text, or leave it empty…'), onChange: (doc: RichTextDoc) => change(doc),
|
|
324
|
+
onMedia: () => this.openChooser(`editor:${id}`, false), onInsertBlock: () => undefined, onEditBlock: () => undefined,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
private templateCard(draft: CollectionDraft): TemplateResult {
|
|
329
|
+
const dialog = this.dialog;
|
|
330
|
+
const block = dialog ? findBlock(this.template, dialog.id) : undefined;
|
|
331
|
+
const option = this.options.find(entry => entry.name === block?.type) ?? null;
|
|
332
|
+
const media = (field: string): MediaHooks => ({ previews: this.previews, choose: multiple => this.openChooser(field, multiple, chooserKind(option?.fields.find(entry => entry.name === field))) });
|
|
333
|
+
const fields = option ? { ...option, fields: option.fields.filter(field => field.kind !== 'richtext') } : null;
|
|
334
|
+
const unresolved = this.unresolvedBindings();
|
|
335
|
+
return html`${component(Card, {}, html`
|
|
336
|
+
${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Content template')}</h2>
|
|
337
|
+
<p class="text-sm text-muted-foreground">${__('The blocks every new entry starts with, in this order: a structure such as a heading, an image and a rich text, with data blocks for what the entry stores. Editors fill them in.')}</p>`)}
|
|
338
|
+
${component(CardBody, { class: 'space-y-4' }, html`
|
|
339
|
+
${unresolved.length ? notice(`${__('These bindings name no field of the collection and show nothing on the site')}: ${unresolved.map(path => `{{ $.${path} }}`).join(', ')}.`, 'error') : null}
|
|
340
|
+
${component(BlockTree, {
|
|
341
|
+
id: 'template', blocks: this.template, options: this.options, allowed: [], previews: this.previews,
|
|
342
|
+
onChange: (blocks: EditorBlock[]) => this.changeTemplate(blocks), onEdit: (id: string) => this.editTemplateBlock(id),
|
|
343
|
+
control: (field: EditorField, value: unknown, change: (value: unknown) => void, _block: EditorBlock, id: string) => this.templateControl(field, value, change, id),
|
|
344
|
+
})}
|
|
345
|
+
${this.template.length ? component(Field, { label: __('Editors may'), for: 'collection-template-lock', control: attributes => component(NativeSelect, { ...attributes, '@change': (event: Event) => this.setDraft('templateLock', (event.target as HTMLSelectElement).value as CollectionDraft['templateLock']) }, html`
|
|
346
|
+
<option value="" ?selected=${!draft.templateLock}>${__('Change the blocks freely')}</option>
|
|
347
|
+
<option value="insert" ?selected=${draft.templateLock === 'insert'}>${__('Reorder the blocks, but not add or remove any')}</option>
|
|
348
|
+
<option value="all" ?selected=${draft.templateLock === 'all'}>${__('Only fill the blocks in')}</option>`) }) : null}`)}
|
|
349
|
+
`)}
|
|
350
|
+
${blockPanel({
|
|
351
|
+
id: 'template-block', open: Boolean(dialog && option), option, tab: dialog?.tab ?? 'general', style: dialog?.style ?? styleValues({}), presets: this.presets,
|
|
352
|
+
onTab: tab => { if (this.dialog) this.dialog = { ...this.dialog, tab }; }, onStyle: style => this.setDialogStyle(style),
|
|
353
|
+
onClose: () => { this.dialog = null; },
|
|
354
|
+
general: dialog && fields ? (fields.fields.length ? blockFields(fields, dialog.values, (name, value) => this.setDialogValue(name, value), `template-${dialog.id}`, media, dialog.errors, this.bindings(), this.sources)
|
|
355
|
+
: html`<p class="text-sm text-muted-foreground">${__('This block has no settings.')}</p>`) : html``,
|
|
356
|
+
})}
|
|
357
|
+
${mediaChooser(this.chooser, { search: text => this.searchMedia(text), filter: kind => this.filterMedia(kind), choose: file => this.chooseFile(file), upload: event => this.uploadFile(event), close: () => { this.chooser = { ...this.chooser, open: false }; } })}`;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
private check(label: string, checked: boolean, change: (checked: boolean) => void, options: { disabled?: boolean; hint?: string } = {}): TemplateResult {
|
|
361
|
+
return html`<div class="[&_.cs-checkbox]:items-start [&_.cs-checkbox>input]:mt-0.5">${component(Checkbox, { checked, disabled: options.disabled === true, '@change': (event: Event) => change((event.target as HTMLInputElement).checked) },
|
|
362
|
+
html`<span>${label}${options.hint ? html`<span class="block text-xs text-muted-foreground">${options.hint}</span>` : null}</span>`)}</div>`;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** The attached groups, in order, with Attach and New. */
|
|
366
|
+
private groupsCard(draft: CollectionDraft): TemplateResult {
|
|
367
|
+
const row = (group: GroupRow, index: number) => html`<li class="flex items-center gap-3 rounded-md border border-border bg-background px-3 py-2" data-group=${group.id}>
|
|
368
|
+
<div class="min-w-0 flex-1">
|
|
369
|
+
<a href=${`/dashboard/field-groups/${group.id}`} class="font-medium text-foreground hover:text-primary no-underline">${group.title}</a>
|
|
370
|
+
<p class="text-xs text-muted-foreground">${group.fields.length === 1 ? __('1 field') : `${group.fields.length} ${__('fields')}`} · ${group.placement === 'sidebar' ? __('Sidebar') : __('Main column')}</p>
|
|
371
|
+
</div>
|
|
372
|
+
${group.plugin ? component(Badge, { variant: 'outline' }, `${__('Plugin')} ${group.plugin}`) : html`
|
|
373
|
+
${iconButton(`group-${group.id}-up`, 'arrow-up', `${__('Move up')} ${group.title}`, () => this.moveGroup(index, -1), { disabled: index === 0 })}
|
|
374
|
+
${iconButton(`group-${group.id}-down`, 'arrow-down', `${__('Move down')} ${group.title}`, () => this.moveGroup(index, 1), { disabled: index === this.groups.length - 1 })}
|
|
375
|
+
${iconButton(`group-${group.id}-remove`, 'close-circle', `${__('Remove')} ${group.title}`, () => this.detachGroup(group.id), { danger: true })}`}
|
|
376
|
+
</li>`;
|
|
377
|
+
return component(Card, {}, html`
|
|
378
|
+
${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Field groups')}</h2>
|
|
379
|
+
<p class="text-sm text-muted-foreground">${__('The boxes of fields entries of this collection have, in this order. A group can show on several collections; edit its fields on its own page.')}
|
|
380
|
+
${this.builtinFields.length ? ` ${__('Built-in fields')}: ${this.builtinFields.join(', ')}.` : ''}</p>`)}
|
|
381
|
+
${component(CardBody, { class: 'space-y-4' }, html`
|
|
382
|
+
${this.groups.length ? html`<ol class="space-y-2">${this.groups.map(row)}</ol>` : html`<p class="text-sm text-muted-foreground">${__('No field groups attached. Entries have the features above only.')}</p>`}
|
|
383
|
+
<div class="flex flex-wrap items-end gap-2">
|
|
384
|
+
${this.available.length ? html`<div class="min-w-48 flex-1">${component(Field, { label: __('Attach a group'), for: 'collection-attach', control: attributes => component(NativeSelect, { ...attributes, '@change': (event: Event) => { this.attaching = (event.target as HTMLSelectElement).value; } }, html`
|
|
385
|
+
<option value="" ?selected=${!this.attaching}>${__('Choose a field group…')}</option>
|
|
386
|
+
${this.available.map(group => html`<option value=${group.id} ?selected=${group.id === this.attaching}>${group.title}</option>`)}`) })}</div>
|
|
387
|
+
${component(Button, { type: 'button', variant: 'outline', disabled: !this.attaching, '@click': () => this.attachGroup(this.attaching) }, __('Attach'))}` : null}
|
|
388
|
+
${linkButton(__('New field group'), `/dashboard/field-groups/new?collection=${draft.name}`, 'outline')}
|
|
389
|
+
</div>`)}`);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
@Client()
|
|
393
|
+
mapProperty(property: string, name: string) {
|
|
394
|
+
if (!this.draft) return;
|
|
395
|
+
const map = { ...this.draft.schemaMap };
|
|
396
|
+
if (name) map[property] = name; else delete map[property];
|
|
397
|
+
this.setDraft('schemaMap', map);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** Structured data, robots and title templates of entries on the site. */
|
|
401
|
+
private searchCard(draft: CollectionDraft): TemplateResult {
|
|
402
|
+
const properties = SCHEMA_PROPERTIES[draft.schemaType];
|
|
403
|
+
const variables = Object.entries(SEO_TEMPLATE_VARIABLES).map(([name]) => `%${name}%`).join(', ');
|
|
404
|
+
const text = (key: 'seoTitle' | 'seoDescription' | 'archiveTitle', label: string, placeholder: string) => component(Field, { label, for: `collection-${key}`, hint: `${__('Empty uses Settings → SEO.')} ${__('Variables')}: ${variables}`,
|
|
405
|
+
control: attributes => component(Input, { ...attributes, placeholder, '.value': draft[key], '@input': (event: Event) => this.setDraft(key, (event.target as HTMLInputElement).value) }) });
|
|
406
|
+
return component(Card, {}, html`
|
|
407
|
+
${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Search engines')}</h2>
|
|
408
|
+
<p class="text-sm text-muted-foreground">${__('How entries appear to search and answer engines: their structured data, robots directives and title templates.')}</p>`)}
|
|
409
|
+
${component(CardBody, { class: 'space-y-5' }, html`
|
|
410
|
+
${component(Field, { label: __('Structured data type'), for: 'collection-schema', hint: __('The schema.org type of each entry\'s JSON-LD. Articles name their author and publisher; other types take properties from the fields below.'),
|
|
411
|
+
control: attributes => component(NativeSelect, { ...attributes, '@change': (event: Event) => this.setDraft('schemaType', (event.target as HTMLSelectElement).value as SchemaType) }, html`
|
|
412
|
+
${SCHEMA_TYPES.map(type => html`<option value=${type} ?selected=${type === draft.schemaType}>${__(SCHEMA_TYPE_LABELS[type])}</option>`)}`) })}
|
|
413
|
+
${properties.length ? html`<div class="grid gap-x-6 gap-y-3 md:grid-cols-2">
|
|
414
|
+
${properties.map(property => component(Field, { label: __(property.label), for: `collection-schema-${property.name}`, hint: __(property.hint), control: attributes => component(NativeSelect, { ...attributes, '@change': (event: Event) => this.mapProperty(property.name, (event.target as HTMLSelectElement).value) }, html`
|
|
415
|
+
<option value="" ?selected=${!draft.schemaMap[property.name]}>—</option>
|
|
416
|
+
${this.fieldNames.map(field => html`<option value=${field.name} ?selected=${draft.schemaMap[property.name] === field.name}>${field.label} (${field.name})</option>`)}`) }))}
|
|
417
|
+
</div>` : null}
|
|
418
|
+
<div class="grid gap-x-8 gap-y-3 md:grid-cols-2 border-t border-border pt-4">
|
|
419
|
+
${this.check(__('Hide entries from search engines'), draft.noindex, checked => this.setDraft('noindex', checked), { hint: __('noindex on every entry; they leave the sitemap too.') })}
|
|
420
|
+
${this.check(__('Do not follow links on entries'), draft.nofollow, checked => this.setDraft('nofollow', checked), { hint: __('nofollow: engines do not pass on the entries\' links.') })}
|
|
421
|
+
${draft.path.trim() ? this.check(__('Hide the archive from search engines'), draft.archiveNoindex, checked => this.setDraft('archiveNoindex', checked), { hint: __('noindex on the archive and its pages; entries stay indexed.') }) : null}
|
|
422
|
+
</div>
|
|
423
|
+
<div class="grid gap-4 border-t border-border pt-4">
|
|
424
|
+
${text('seoTitle', __('Entry title template'), '%title% %sep% %site%')}
|
|
425
|
+
${text('seoDescription', __('Entry description template'), '%excerpt%')}
|
|
426
|
+
${draft.path.trim() ? text('archiveTitle', __('Archive title template'), '%title% %sep% %site%') : null}
|
|
427
|
+
</div>`)}`);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/** The Search engines tab: the settings of entries on the site, or why there are none. */
|
|
431
|
+
private seoTab(draft: CollectionDraft): TemplateResult {
|
|
432
|
+
return html`<div class="max-w-4xl">${draft.public ? this.searchCard(draft)
|
|
433
|
+
: notice(__('Entries of this collection are not on the site, so search engines do not see them. Turn on Show entries on the site in General to set their structured data, robots directives and title templates.'), 'info')}</div>`;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** The Editor tab: the entry editor's arrangement. */
|
|
437
|
+
private editorTab(): TemplateResult {
|
|
438
|
+
return html`<div class="space-y-4">
|
|
439
|
+
<p class="text-sm text-muted-foreground">${__('How the entry editor is arranged: the tabs of its main column and the meta boxes of its sidebar. Save the collection to keep the layout.')}</p>
|
|
440
|
+
${component(EditorLayoutEditor, { id: 'layout', layout: this.layout, options: this.layoutOptions, boxes: this.boxes, missing: this.missing, added: this.added, additions: this.additions, error: this.error, onChange: (layout: EditorLayoutDraft) => this.changeLayout(layout) })}
|
|
441
|
+
</div>`;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
render() {
|
|
445
|
+
const draft = this.draft;
|
|
446
|
+
if (!draft) return notice(this.error || __('This collection does not exist.'), 'error');
|
|
447
|
+
const locked = (feature: string) => draft.builtin && this.builtinFeatures.includes(feature);
|
|
448
|
+
const control = (key: 'label' | 'singular' | 'description' | 'path', label: string, hint?: string) => component(Field, { label, for: `collection-${key}`, ...(hint ? { hint } : {}),
|
|
449
|
+
control: attributes => component(Input, { ...attributes, '.value': draft[key], '@input': (event: Event) => this.setDraft(key, (event.target as HTMLInputElement).value) }) });
|
|
450
|
+
return html`<div class="space-y-6">
|
|
451
|
+
${pageHeader(draft.label, {
|
|
452
|
+
description: `${__('Collection')} cms/${draft.name}${draft.builtin ? ` · ${__('built in')}` : ''}`,
|
|
453
|
+
actions: html`<a href=${`/dashboard/content/${draft.name}`} class="text-sm text-primary hover:underline">${__('View entries')}</a>
|
|
454
|
+
${component(Button, { type: 'button', '@click': () => this.submit() }, __('Save collection'))}`,
|
|
455
|
+
})}
|
|
456
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
457
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
458
|
+
${component(Tabs, {
|
|
459
|
+
id: 'collection', label: __('Collection'), value: this.tab, variant: 'underline',
|
|
460
|
+
onValueChange: (tab: string) => this.showTab(tab as (typeof TABS)[number]),
|
|
461
|
+
items: [
|
|
462
|
+
{ value: 'general', label: __('General'), content: html`<div class="grid gap-6 xl:grid-cols-[minmax(0,1fr)_22rem]">
|
|
463
|
+
<div class="space-y-6">
|
|
464
|
+
${component(Card, {}, html`
|
|
465
|
+
${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Features')}</h2>
|
|
466
|
+
<p class="text-sm text-muted-foreground">${__('The standard fields and behaviours every entry has, with fixed names themes and code rely on. Every entry has a title.')}</p>`)}
|
|
467
|
+
${component(CardBody, {}, html`<div class="grid gap-x-8 gap-y-3 md:grid-cols-2">
|
|
468
|
+
${this.check(__('Content'), draft.content, checked => this.setDraft('content', checked), { disabled: locked('content'), hint: __('Blocks: headings, images and rich text, which the content template starts.') })}
|
|
469
|
+
${this.check(__('Excerpt'), draft.excerpt, checked => this.setDraft('excerpt', checked), { disabled: locked('excerpt'), hint: __('A short summary for lists, feeds and link previews.') })}
|
|
470
|
+
${this.check(__('Featured image'), draft.featuredImage, checked => this.setDraft('featuredImage', checked), { disabled: locked('featuredImage'), hint: __('One image from the media library, in the sidebar.') })}
|
|
471
|
+
${this.check(__('Password protection'), draft.password, checked => this.setDraft('password', checked), { disabled: locked('password'), hint: __('A password field in the sidebar: visitors type it to read the entry.') })}
|
|
472
|
+
${this.check(__('Members only'), draft.members, checked => this.setDraft('members', checked), { disabled: locked('members'), hint: __('A switch in the sidebar: only signed-in users read the entry; visitors see its title and a sign-in link.') })}
|
|
473
|
+
${this.check(__('Revisions'), draft.revisions, checked => this.setDraft('revisions', checked), { hint: __('Keep every version of an entry to compare and restore.') })}
|
|
474
|
+
${this.check(__('Generate slugs from titles'), draft.slug, checked => this.setDraft('slug', checked), { disabled: draft.builtin })}
|
|
475
|
+
${this.check(__('Drafts and publishing'), draft.publishable, checked => this.setDraft('publishable', checked), { disabled: draft.builtin, hint: __('Visitors see published entries only.') })}
|
|
476
|
+
${this.check(__('Nested entries'), draft.hierarchical, checked => this.setDraft('hierarchical', checked), { disabled: draft.builtin, hint: __('Entries can have a parent, like pages.') })}
|
|
477
|
+
${this.check(__('Comments'), draft.comments, checked => this.setDraft('comments', checked), { hint: __('Visitors can comment on published entries; Settings → Discussion moderates them.') })}
|
|
478
|
+
</div>
|
|
479
|
+
<div class="mt-5 border-t border-border pt-4">
|
|
480
|
+
<h3 class="mb-2 text-sm font-semibold text-foreground">${__('Taxonomies')}</h3>
|
|
481
|
+
<div class="grid gap-x-8 gap-y-2 md:grid-cols-2">
|
|
482
|
+
${this.taxonomies.map(taxonomy => this.check(taxonomy.label, draft.taxonomies.includes(taxonomy.name), checked => this.toggleTaxonomy(taxonomy.name, checked), { disabled: this.builtinTaxonomies.includes(taxonomy.name) }))}
|
|
483
|
+
</div>
|
|
484
|
+
<a href="/dashboard/taxonomies" class="mt-2 inline-block text-sm text-primary hover:underline">${__('Manage taxonomies')}</a>
|
|
485
|
+
</div>`)}
|
|
486
|
+
`)}
|
|
487
|
+
${this.groupsCard(draft)}
|
|
488
|
+
${draft.content ? this.templateCard(draft) : null}
|
|
489
|
+
</div>
|
|
490
|
+
<aside class="space-y-6">
|
|
491
|
+
${component(Card, {}, component(CardBody, { class: 'space-y-4' }, html`
|
|
492
|
+
<h2 class="text-base font-semibold text-foreground">${__('Settings')}</h2>
|
|
493
|
+
${control('label', __('Plural name'))}
|
|
494
|
+
${control('singular', __('Singular name'))}
|
|
495
|
+
${control('description', __('Description'))}
|
|
496
|
+
${iconSelect('collection-icon', draft.icon, value => this.setDraft('icon', value), undefined, { hint: __('Shown in the dashboard menu.'), allowEmpty: false })}
|
|
497
|
+
${this.check(__('Show entries on the site'), draft.public, checked => this.setDraft('public', checked), { disabled: draft.builtin && draft.name === 'pages' })}
|
|
498
|
+
${draft.public ? this.check(__('List entries in the XML sitemap'), draft.sitemap, checked => this.setDraft('sitemap', checked), { hint: __('Published entries not marked noindex, with their featured images.') }) : null}
|
|
499
|
+
${draft.public && !(draft.builtin && draft.name === 'pages') ? control('path', __('URL path'), draft.path.trim()
|
|
500
|
+
? `${__('Entries at')} /${draft.path.trim()}/${draft.slug ? 'slug' : 'id'}`
|
|
501
|
+
: `${__('Entries at the site root')}: /${draft.slug ? 'slug' : 'id'}. ${__('Slugs stay unique across pages and other root collections.')}`) : null}
|
|
502
|
+
${draft.publishable ? null : component(Field, { label: __('Who can read entries'), for: 'collection-visibility', control: attributes => component(NativeSelect, { ...attributes, '@change': (event: Event) => this.setDraft('visibility', (event.target as HTMLSelectElement).value as 'public' | 'private') }, html`
|
|
503
|
+
<option value="private" ?selected=${draft.visibility === 'private'}>${__('Editors only')}</option>
|
|
504
|
+
<option value="public" ?selected=${draft.visibility === 'public'}>${__('Everyone')}</option>`) })}
|
|
505
|
+
`))}
|
|
506
|
+
${draft.builtin ? null : component(Card, {}, component(CardBody, { class: 'space-y-3' }, html`
|
|
507
|
+
<h2 class="text-base font-semibold text-destructive">${__('Delete collection')}</h2>
|
|
508
|
+
<p class="text-sm text-muted-foreground">${__('Deletes the collection, its table and every entry.')}</p>
|
|
509
|
+
${component(Button, { type: 'button', variant: 'destructive', size: 'sm', '@click': () => { this.confirmDelete = true; } }, __('Delete collection'))}
|
|
510
|
+
`))}
|
|
511
|
+
</aside>
|
|
512
|
+
</div>` },
|
|
513
|
+
{ value: 'seo', label: __('Search engines'), content: this.seoTab(draft) },
|
|
514
|
+
{ value: 'editor', label: __('Editor'), content: this.editorTab() },
|
|
515
|
+
],
|
|
516
|
+
})}
|
|
517
|
+
${component(AlertDialog, {
|
|
518
|
+
id: 'delete-collection-dialog', open: this.confirmDelete, title: `${__('Delete')} ${draft.label}?`,
|
|
519
|
+
description: __('Every entry of this collection is deleted with it. This cannot be undone.'),
|
|
520
|
+
cancelLabel: __('Cancel'), actionLabel: __('Delete'), actionVariant: 'destructive',
|
|
521
|
+
onAction: () => { this.confirmDelete = false; void this.remove(); }, onOpenChange: () => { this.confirmDelete = false; },
|
|
522
|
+
})}
|
|
523
|
+
</div>`;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Cossack, Page, State, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Badge, Card, CardBody, Icon } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { PERMISSIONS } from '@cossackframework/cms';
|
|
5
|
+
import { requireAny } from '#app/cms/guards';
|
|
6
|
+
import { icon } from '#app/cms/icons';
|
|
7
|
+
import { linkButton, pageHeader } from '#app/cms/ui';
|
|
8
|
+
|
|
9
|
+
interface Row { name: string; label: string; singular: string; icon: string; builtin: boolean; entries: number; fields: number; taxonomies: string[]; path: string | null }
|
|
10
|
+
|
|
11
|
+
/** Collections: content types such as posts, pages and products, as a list table. Each has its own document table and fields. */
|
|
12
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageCollections)] })
|
|
13
|
+
export default class CollectionsPage extends Cossack {
|
|
14
|
+
@State() rows: Row[] = [];
|
|
15
|
+
|
|
16
|
+
head(): HeadValue {
|
|
17
|
+
return { title: 'Collections' };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async init() {
|
|
21
|
+
const cms = this.c.get('cms');
|
|
22
|
+
const principal = this.c.get('principal');
|
|
23
|
+
const labels = new Map(cms.taxonomies.declarations.map(taxonomy => [taxonomy.name, taxonomy.label]));
|
|
24
|
+
// A managed collection (forms) has screens of its own and is not listed.
|
|
25
|
+
this.rows = await Promise.all(cms.collections().filter(collection => !collection.managed).map(async collection => ({
|
|
26
|
+
name: collection.name, label: collection.label, singular: collection.singular, icon: collection.icon ?? 'document-text', builtin: collection.builtin === true,
|
|
27
|
+
entries: await cms.resource(`cms/${collection.name}`).count({}, { principal }).catch(() => 0),
|
|
28
|
+
fields: Object.keys(collection.fields).length, taxonomies: (collection.taxonomies ?? []).map(name => labels.get(name) ?? name), path: collection.path ?? null,
|
|
29
|
+
})));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
render() {
|
|
33
|
+
const th = 'px-3 py-2 font-medium';
|
|
34
|
+
const td = 'px-3 py-2';
|
|
35
|
+
return html`<div class="space-y-6">
|
|
36
|
+
${pageHeader(__('Collections'), {
|
|
37
|
+
description: __('Content types and their fields. Each collection has its own list, editor and site URLs.'),
|
|
38
|
+
titleActions: linkButton(__('New collection'), '/dashboard/collections/new', 'primary', { size: 'sm' }),
|
|
39
|
+
})}
|
|
40
|
+
${component(Card, {}, component(CardBody, { class: 'p-0' }, html`
|
|
41
|
+
<div class="overflow-x-auto">
|
|
42
|
+
<table class="w-full text-sm">
|
|
43
|
+
<thead><tr class="border-b border-border text-left text-xs uppercase tracking-wide text-muted-foreground">
|
|
44
|
+
<th class=${th}>${__('Collection')}</th><th class=${th}>${__('Name')}</th><th class=${`${th} text-right`}>${__('Entries')}</th>
|
|
45
|
+
<th class=${`${th} text-right`}>${__('Added fields')}</th><th class=${th}>${__('Taxonomies')}</th><th class=${th}>${__('URL')}</th>
|
|
46
|
+
</tr></thead>
|
|
47
|
+
<tbody>${this.rows.map(row => html`<tr class="group border-b border-border last:border-0 align-top" data-collection=${row.name}>
|
|
48
|
+
<td class=${td}>
|
|
49
|
+
<div class="flex items-start gap-3">
|
|
50
|
+
<span class="mt-0.5 inline-flex shrink-0 text-muted-foreground [&_svg]:size-5">${component(Icon, { entry: icon(row.icon), size: 20 })}</span>
|
|
51
|
+
<div class="min-w-0">
|
|
52
|
+
<a href=${`/dashboard/collections/${row.name}`} class="font-medium text-foreground hover:text-primary no-underline">${row.label}</a>
|
|
53
|
+
${row.builtin ? html` ${component(Badge, { variant: 'secondary' }, __('Built in'))}` : null}
|
|
54
|
+
<div class="mt-1 flex flex-wrap items-center gap-2 text-xs opacity-80 group-hover:opacity-100">
|
|
55
|
+
<a href=${`/dashboard/collections/${row.name}`} class="text-primary hover:underline">${__('Edit')}</a>
|
|
56
|
+
<span aria-hidden="true" class="text-muted-foreground">|</span>
|
|
57
|
+
<a href=${`/dashboard/content/${row.name}`} class="text-primary hover:underline">${__('Entries')}</a>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</td>
|
|
62
|
+
<td class=${td}><code class="text-xs text-muted-foreground">${row.name}</code><span class="block text-xs text-muted-foreground">${row.singular}</span></td>
|
|
63
|
+
<td class=${`${td} text-right text-muted-foreground`}>${row.entries}</td>
|
|
64
|
+
<td class=${`${td} text-right text-muted-foreground`}>${row.fields}</td>
|
|
65
|
+
<td class=${`${td} text-muted-foreground`}>${row.taxonomies.join(', ') || '—'}</td>
|
|
66
|
+
<td class=${`${td} text-muted-foreground`}>${row.path === null ? component(Badge, { variant: 'outline' }, __('Disabled')) : html`<code class="text-xs">/${row.path}</code>`}</td>
|
|
67
|
+
</tr>`)}</tbody>
|
|
68
|
+
</table>
|
|
69
|
+
</div>`))}
|
|
70
|
+
</div>`;
|
|
71
|
+
}
|
|
72
|
+
}
|