@cossackframework/cms 0.0.0 → 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 +145 -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 +114 -2
- 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,170 @@
|
|
|
1
|
+
import { Cossack, Page, State, Server, Client, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Badge, Button, Card, CardBody, Checkbox, Input, NativeSelect } from '@cossackframework/ui';
|
|
3
|
+
import { html, component, type TemplateResult } from '@cossackframework/renderer';
|
|
4
|
+
import { displayValue, isCmsError, PERMISSIONS, SUBMISSION_STATUSES, type SubmissionStatus } from '@cossackframework/cms';
|
|
5
|
+
import type { LoadedForm } from '@cossackframework/cms/server';
|
|
6
|
+
import { requireAny } from '#app/cms/guards';
|
|
7
|
+
import { linkButton, notice, pageHeader, shortDate } from '#app/cms/ui';
|
|
8
|
+
|
|
9
|
+
/** Columns the inbox shows: the form's first inputs, as Gravity Forms' entry list. */
|
|
10
|
+
const COLUMNS = 4;
|
|
11
|
+
const PAGE_SIZE = 25;
|
|
12
|
+
|
|
13
|
+
interface Row { id: string; status: SubmissionStatus; cells: string[]; date: string }
|
|
14
|
+
|
|
15
|
+
type Tab = 'all' | SubmissionStatus;
|
|
16
|
+
const BULK: Record<Tab, [string, string][]> = {
|
|
17
|
+
all: [['read', 'Mark as read'], ['new', 'Mark as unread'], ['spam', 'Mark as spam'], ['trash', 'Move to trash']],
|
|
18
|
+
new: [['read', 'Mark as read'], ['spam', 'Mark as spam'], ['trash', 'Move to trash']],
|
|
19
|
+
read: [['new', 'Mark as unread'], ['spam', 'Mark as spam'], ['trash', 'Move to trash']],
|
|
20
|
+
spam: [['read', 'Not spam'], ['delete', 'Delete permanently']],
|
|
21
|
+
trash: [['read', 'Restore'], ['delete', 'Delete permanently']],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A form's submissions: status tabs with counts, search over the text answers, the newest
|
|
26
|
+
* first a page at a time, bulk actions and a CSV export. Needs `cms:submissions`.
|
|
27
|
+
*/
|
|
28
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageSubmissions)] })
|
|
29
|
+
export default class SubmissionsPage extends Cossack {
|
|
30
|
+
@State() form: { id: string; title: string; slug: string } | null = null;
|
|
31
|
+
@State() columns: string[] = [];
|
|
32
|
+
@State() status: Tab = 'all';
|
|
33
|
+
@State() counts: Record<string, number> = {};
|
|
34
|
+
@State() rows: Row[] = [];
|
|
35
|
+
@State() search = '';
|
|
36
|
+
@State() after = '';
|
|
37
|
+
@State() next = '';
|
|
38
|
+
@State() selected: string[] = [];
|
|
39
|
+
@State() bulk = '';
|
|
40
|
+
@State() error = '';
|
|
41
|
+
|
|
42
|
+
head(): HeadValue {
|
|
43
|
+
return { title: this.form ? `${__('Submissions')}: ${this.form.title}` : __('Submissions') };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async init() {
|
|
47
|
+
const status = this.c.req.query('status') ?? '';
|
|
48
|
+
this.status = (SUBMISSION_STATUSES as readonly string[]).includes(status) ? status as SubmissionStatus : 'all';
|
|
49
|
+
this.search = (this.c.req.query('q') ?? '').slice(0, 200);
|
|
50
|
+
this.after = (this.c.req.query('after') ?? '').slice(0, 200);
|
|
51
|
+
await this.load();
|
|
52
|
+
if (!this.form) this.c.status(404);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private async loaded(): Promise<LoadedForm | null> {
|
|
56
|
+
return this.c.get('cms').forms.get(this.c.req.param('id') ?? '');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Server()
|
|
60
|
+
private async load() {
|
|
61
|
+
const cms = this.c.get('cms');
|
|
62
|
+
const principal = this.c.get('principal');
|
|
63
|
+
const form = await this.loaded();
|
|
64
|
+
if (!form) { this.form = null; return; }
|
|
65
|
+
this.form = { id: form.ref.id, title: form.ref.title, slug: form.ref.slug };
|
|
66
|
+
const inputs = form.ref.inputs.slice(0, COLUMNS);
|
|
67
|
+
this.columns = inputs.map(input => input.label);
|
|
68
|
+
const counts = await cms.forms.counts(form, principal);
|
|
69
|
+
this.counts = { ...counts, all: counts.new + counts.read };
|
|
70
|
+
try {
|
|
71
|
+
const page = await cms.forms.list(form, { ...(this.status === 'all' ? {} : { status: this.status }), ...(this.search ? { search: this.search } : {}), ...(this.after && !this.search ? { after: this.after } : {}), limit: PAGE_SIZE }, principal);
|
|
72
|
+
this.rows = page.items.map(item => ({ id: item.id, status: item.status, date: shortDate(item.createdAt), cells: inputs.map(input => displayValue(input, item.values[input.name]).slice(0, 120)) }));
|
|
73
|
+
this.next = page.next ?? '';
|
|
74
|
+
this.error = '';
|
|
75
|
+
} catch (error) {
|
|
76
|
+
if (!isCmsError(error)) throw error;
|
|
77
|
+
this.rows = [];
|
|
78
|
+
this.error = error.message;
|
|
79
|
+
}
|
|
80
|
+
this.selected = [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@Server()
|
|
84
|
+
async apply(ids: string[], action: string) {
|
|
85
|
+
const cms = this.c.get('cms');
|
|
86
|
+
const form = await this.loaded();
|
|
87
|
+
if (!form) return;
|
|
88
|
+
try {
|
|
89
|
+
if (action === 'delete') await cms.forms.delete(form, ids, this.c.get('principal'));
|
|
90
|
+
else if ((SUBMISSION_STATUSES as readonly string[]).includes(action)) await cms.forms.setStatus(form, ids, action as SubmissionStatus, this.c.get('principal'));
|
|
91
|
+
} catch (error) { if (!isCmsError(error)) throw error; this.error = error.message; return; }
|
|
92
|
+
await this.load();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@Client()
|
|
96
|
+
async applyBulk() {
|
|
97
|
+
if (!this.bulk || !this.selected.length) return;
|
|
98
|
+
await this.apply(this.selected, this.bulk);
|
|
99
|
+
this.bulk = '';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@Client()
|
|
103
|
+
toggle(id: string, checked: boolean) {
|
|
104
|
+
this.selected = checked ? [...new Set([...this.selected, id])] : this.selected.filter(entry => entry !== id);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@Client()
|
|
108
|
+
toggleAll(checked: boolean) {
|
|
109
|
+
this.selected = checked ? this.rows.map(row => row.id) : [];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private href(changes: Record<string, string>) {
|
|
113
|
+
const next = { status: this.status === 'all' ? '' : this.status, q: this.search, ...changes };
|
|
114
|
+
const params = new URLSearchParams(Object.entries(next).filter(([, value]) => value));
|
|
115
|
+
return `/dashboard/forms/${this.form?.id ?? ''}/submissions${params.size ? `?${params}` : ''}`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private row(row: Row): TemplateResult {
|
|
119
|
+
const detail = `/dashboard/forms/${this.form?.id ?? ''}/submissions/${row.id}`;
|
|
120
|
+
const unread = row.status === 'new';
|
|
121
|
+
return html`<tr class=${`border-b border-border last:border-0 align-top ${unread ? 'font-semibold' : ''}`} data-submission=${row.id} data-status=${row.status}>
|
|
122
|
+
<td class="px-3 py-2">${component(Checkbox, { checked: this.selected.includes(row.id), 'aria-label': `${__('Select submission from')} ${row.date}`, '@change': (event: Event) => this.toggle(row.id, (event.target as HTMLInputElement).checked) })}</td>
|
|
123
|
+
${row.cells.map((cell, index) => html`<td class="max-w-xs px-3 py-2"><span class="block truncate">${index === 0 ? html`<a href=${detail} class="text-foreground hover:text-primary">${cell || __('(empty)')}</a>` : cell}</span></td>`)}
|
|
124
|
+
<td class="whitespace-nowrap px-3 py-2 text-xs text-muted-foreground"><a href=${detail} class="text-muted-foreground hover:text-primary">${row.date}</a></td>
|
|
125
|
+
<td class="px-3 py-2">${unread ? component(Badge, { variant: 'default' }, __('New')) : row.status === 'spam' ? component(Badge, { variant: 'destructive' }, __('Spam'))
|
|
126
|
+
: row.status === 'trash' ? component(Badge, { variant: 'secondary' }, __('Trash')) : null}</td>
|
|
127
|
+
</tr>`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
render() {
|
|
131
|
+
if (!this.form) return html`<div class="space-y-4">${pageHeader(__('Submissions'))}${notice(__('This form does not exist.'), 'error')}<a href="/dashboard/forms" class="text-sm text-primary hover:underline">${__('All forms')}</a></div>`;
|
|
132
|
+
const tabs: [Tab, string][] = [['all', __('All')], ['new', __('Unread')], ['read', __('Read')], ['spam', __('Spam')], ['trash', __('Trash')]];
|
|
133
|
+
const exportUrl = `/api/cms/forms/${this.form.id}/submissions/export${this.status === 'all' ? '' : `?status=${this.status}`}`;
|
|
134
|
+
return html`<div class="space-y-6">
|
|
135
|
+
${pageHeader(`${__('Submissions')}: ${this.form.title}`, {
|
|
136
|
+
description: `${__('Form')} ${this.form.slug}`,
|
|
137
|
+
actions: html`${linkButton(__('Export CSV'), exportUrl, 'outline')}${linkButton(__('Edit form'), `/dashboard/content/forms/${this.form.id}`, 'outline')}`,
|
|
138
|
+
})}
|
|
139
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
140
|
+
<div class="flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
|
|
141
|
+
<nav aria-label=${__('Filter by status')} class="flex flex-wrap gap-x-3 gap-y-1 text-sm">${tabs.map(([key, label], index) => html`${index ? html`<span class="text-muted-foreground" aria-hidden="true">|</span>` : null}
|
|
142
|
+
<a href=${this.href({ status: key === 'all' ? '' : key, q: '' })} aria-current=${this.status === key ? 'page' : 'false'}
|
|
143
|
+
class=${this.status === key ? 'font-semibold text-foreground no-underline' : 'text-primary no-underline hover:underline'}>${label} <span class="text-muted-foreground">(${this.counts[key] ?? 0})</span></a>`)}</nav>
|
|
144
|
+
<form method="get" class="flex flex-wrap gap-2" role="search">
|
|
145
|
+
${this.status !== 'all' ? html`<input type="hidden" name="status" value=${this.status}>` : null}
|
|
146
|
+
${component(Input, { type: 'search', name: 'q', size: 'sm', value: this.search, placeholder: __('Search submissions'), 'aria-label': __('Search submissions') })}
|
|
147
|
+
${component(Button, { type: 'submit', size: 'sm', variant: 'outline' }, __('Search'))}
|
|
148
|
+
</form>
|
|
149
|
+
</div>
|
|
150
|
+
<div class="flex items-center gap-2">
|
|
151
|
+
${component(NativeSelect, { size: 'sm', inline: true, 'aria-label': __('Bulk actions'), '@change': (event: Event) => { this.bulk = (event.target as HTMLSelectElement).value; } }, html`
|
|
152
|
+
<option value="" ?selected=${!this.bulk}>${__('Bulk actions')}</option>
|
|
153
|
+
${BULK[this.status].map(([value, label]) => html`<option value=${value}>${__(label)}</option>`)}`)}
|
|
154
|
+
${component(Button, { type: 'button', size: 'sm', variant: 'outline', disabled: !this.bulk || !this.selected.length, '@click': () => this.applyBulk() }, __('Apply'))}
|
|
155
|
+
</div>
|
|
156
|
+
${component(Card, {}, component(CardBody, { class: 'p-0' }, html`<div class="overflow-x-auto"><table class="w-full text-sm">
|
|
157
|
+
<thead><tr class="border-b border-border text-left text-xs uppercase tracking-wide text-muted-foreground">
|
|
158
|
+
<th class="w-10 px-3 py-2">${component(Checkbox, { checked: this.rows.length > 0 && this.selected.length === this.rows.length, 'aria-label': __('Select all'), '@change': (event: Event) => this.toggleAll((event.target as HTMLInputElement).checked) })}</th>
|
|
159
|
+
${this.columns.map(column => html`<th class="px-3 py-2 font-medium">${column}</th>`)}
|
|
160
|
+
<th class="px-3 py-2 font-medium">${__('Submitted')}</th><th class="px-3 py-2"><span class="sr-only">${__('Status')}</span></th>
|
|
161
|
+
</tr></thead>
|
|
162
|
+
<tbody>${this.rows.map(row => this.row(row))}</tbody></table>
|
|
163
|
+
${this.rows.length ? null : html`<p class="px-4 py-10 text-center text-sm text-muted-foreground">${this.search ? __('No submissions match.') : __('No submissions yet.')}</p>`}</div>`))}
|
|
164
|
+
${this.after || this.next ? html`<nav aria-label=${__('Pages')} class="flex justify-between text-sm">
|
|
165
|
+
${this.after ? html`<a href=${this.href({})} class="text-primary hover:underline">${__('Newest')}</a>` : html`<span></span>`}
|
|
166
|
+
${this.next ? html`<a href=${this.href({ after: this.next })} class="text-primary hover:underline">${__('Older')}</a>` : null}
|
|
167
|
+
</nav>` : null}
|
|
168
|
+
</div>`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { Client, Cossack, Page, Server, State, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { AlertDialog, Badge } from '@cossackframework/ui';
|
|
3
|
+
import { html, component, type TemplateResult } from '@cossackframework/renderer';
|
|
4
|
+
import { evaluateRule, hasPermission, isCmsError, PERMISSIONS } from '@cossackframework/cms';
|
|
5
|
+
import { bulkBar, type BulkChoice } from '#app/dashboard/bulk';
|
|
6
|
+
import { listTable, rowActions } from '#app/dashboard/list-table';
|
|
7
|
+
import { requireAny } from '#app/cms/guards';
|
|
8
|
+
import { linkButton, notice, pageHeader } from '#app/cms/ui';
|
|
9
|
+
|
|
10
|
+
/** What a bulk action writes to each selected form. */
|
|
11
|
+
const BULK_PATCHES: Record<string, Record<string, unknown>> = {
|
|
12
|
+
on: { enabled: true }, off: { enabled: false }, publish: { status: 'published' }, draft: { status: 'draft' },
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
interface Row {
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
slug: string;
|
|
19
|
+
fields: number;
|
|
20
|
+
fresh: number;
|
|
21
|
+
kept: number;
|
|
22
|
+
/** Why the form takes nothing now; empty while it is open. */
|
|
23
|
+
closed: string;
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
published: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Forms, as Gravity Forms lists them: each with its new and kept submissions and whether it
|
|
30
|
+
* takes submissions now. Editing opens the entry editor; submissions open the inbox.
|
|
31
|
+
*/
|
|
32
|
+
@Page({ transport: 'http', middlewares: [requireAny('cms/forms:read', 'cms/forms:update', 'cms/forms:create', PERMISSIONS.manageSubmissions)] })
|
|
33
|
+
export default class FormsPage extends Cossack {
|
|
34
|
+
@State() rows: Row[] = [];
|
|
35
|
+
@State() canEdit = false;
|
|
36
|
+
@State() canCreate = false;
|
|
37
|
+
@State() canHandle = false;
|
|
38
|
+
@State() canDelete = false;
|
|
39
|
+
@State() selected: string[] = [];
|
|
40
|
+
@State() bulk = '';
|
|
41
|
+
/** A bulk action waiting for confirmation. */
|
|
42
|
+
@State() pendingBulk: BulkChoice | null = null;
|
|
43
|
+
@State() message = '';
|
|
44
|
+
@State() error = '';
|
|
45
|
+
|
|
46
|
+
head(): HeadValue {
|
|
47
|
+
return { title: __('Forms') };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async init() {
|
|
51
|
+
const cms = this.c.get('cms');
|
|
52
|
+
const principal = this.c.get('principal');
|
|
53
|
+
const access = cms.resourceById('cms/forms').access;
|
|
54
|
+
this.canCreate = evaluateRule(access.create, principal) !== 'deny';
|
|
55
|
+
this.canEdit = evaluateRule(access.update, principal) !== 'deny';
|
|
56
|
+
this.canDelete = evaluateRule(access.delete, principal) !== 'deny';
|
|
57
|
+
this.canHandle = hasPermission(principal, PERMISSIONS.manageSubmissions);
|
|
58
|
+
await this.load();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private async load() {
|
|
62
|
+
const cms = this.c.get('cms');
|
|
63
|
+
const principal = this.c.get('principal');
|
|
64
|
+
const forms = await cms.forms.all();
|
|
65
|
+
const counts = await cms.forms.inboxCounts(forms, principal);
|
|
66
|
+
const closed = await Promise.all(forms.map(form => cms.forms.closed(form)));
|
|
67
|
+
this.rows = forms.map((form, index) => ({
|
|
68
|
+
id: form.ref.id, title: form.ref.title || __('(no title)'), slug: form.ref.slug, fields: form.ref.inputs.length,
|
|
69
|
+
fresh: counts.get(form.ref.id)?.fresh ?? 0, kept: counts.get(form.ref.id)?.kept ?? 0, closed: closed[index] ?? '', enabled: form.enabled, published: form.published,
|
|
70
|
+
}));
|
|
71
|
+
this.selected = this.selected.filter(id => this.rows.some(row => row.id === id));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Status changes for editors, deletion for those who may delete forms. */
|
|
75
|
+
private bulkChoices(): BulkChoice[] {
|
|
76
|
+
return [
|
|
77
|
+
...(this.canEdit ? [{ key: 'on', label: __('Accept submissions') }, { key: 'off', label: __('Stop submissions') }, { key: 'publish', label: __('Publish') }, { key: 'draft', label: __('Unpublish') }] : []),
|
|
78
|
+
...(this.canDelete ? [{ key: 'delete', label: __('Delete'), confirm: __('The selected forms will be deleted. Their kept submissions stay in the inbox. This cannot be undone.') }] : []),
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Client()
|
|
83
|
+
async submitBulk() {
|
|
84
|
+
const choice = this.bulkChoices().find(entry => entry.key === this.bulk);
|
|
85
|
+
if (!choice || !this.selected.length) return;
|
|
86
|
+
if (choice.confirm) { this.pendingBulk = choice; return; }
|
|
87
|
+
await this.runBulk(choice.key);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Client()
|
|
91
|
+
async runBulk(key: string) {
|
|
92
|
+
this.pendingBulk = null;
|
|
93
|
+
await this.applyBulk(this.selected, key);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Apply a bulk action form by form; the repository checks each write against the forms' access rules. */
|
|
97
|
+
@Server()
|
|
98
|
+
async applyBulk(ids: string[], key: string) {
|
|
99
|
+
this.message = '';
|
|
100
|
+
this.error = '';
|
|
101
|
+
const patch = BULK_PATCHES[key];
|
|
102
|
+
if (key !== 'delete' && !patch) return;
|
|
103
|
+
const cms = this.c.get('cms');
|
|
104
|
+
const principal = this.c.get('principal');
|
|
105
|
+
const repository = cms.resource('cms/forms');
|
|
106
|
+
const failures: string[] = [];
|
|
107
|
+
let done = 0;
|
|
108
|
+
for (const id of [...new Set(ids)].slice(0, 100)) {
|
|
109
|
+
try {
|
|
110
|
+
const record = await repository.get(id, { principal });
|
|
111
|
+
if (!record) continue;
|
|
112
|
+
if (patch) await repository.update(id, patch, { principal, expectedRevision: record.rev }); else await repository.delete(id, { principal, expectedRevision: record.rev });
|
|
113
|
+
done++;
|
|
114
|
+
} catch (error) { failures.push(isCmsError(error) ? error.message : __('A form could not be changed.')); }
|
|
115
|
+
}
|
|
116
|
+
if (done) this.message = `${done} ${done === 1 ? __('form updated.') : __('forms updated.')}`;
|
|
117
|
+
if (failures.length) this.error = [...new Set(failures)].slice(0, 3).join(' ');
|
|
118
|
+
this.selected = [];
|
|
119
|
+
this.bulk = '';
|
|
120
|
+
await this.load();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private status(row: Row): TemplateResult {
|
|
124
|
+
return !row.published ? component(Badge, { variant: 'outline' }, __('Draft'))
|
|
125
|
+
: !row.enabled ? component(Badge, { variant: 'secondary' }, __('Off'))
|
|
126
|
+
: row.closed ? component(Badge, { variant: 'warning' }, __('Closed')) : component(Badge, { variant: 'success' }, __('Accepting'));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
render() {
|
|
130
|
+
const bulk = this.bulkChoices().length > 0;
|
|
131
|
+
const submissions = (row: Row) => `/dashboard/forms/${row.id}/submissions`;
|
|
132
|
+
return html`<div class="space-y-6">
|
|
133
|
+
${pageHeader(__('Forms'), {
|
|
134
|
+
description: __('Build forms from blocks. Place one on a page with the Form block.'),
|
|
135
|
+
titleActions: this.canCreate ? linkButton(__('New form'), '/dashboard/content/forms/new', 'primary', { size: 'sm' }) : null,
|
|
136
|
+
})}
|
|
137
|
+
${this.message && !this.error ? notice(this.message, 'success') : null}
|
|
138
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
139
|
+
${this.rows.length && bulk ? bulkBar({ id: 'forms-bulk', choices: this.bulkChoices(), value: this.bulk, count: this.selected.length,
|
|
140
|
+
choose: key => { this.bulk = key; }, apply: () => this.submitBulk() }) : null}
|
|
141
|
+
${listTable<Row>({
|
|
142
|
+
rows: this.rows, key: row => row.id, rowAttribute: 'data-form-id', empty: __('No forms yet.'),
|
|
143
|
+
...(bulk ? { selection: { selected: this.selected, label: row => row.title, change: ids => { this.selected = ids; } } } : {}),
|
|
144
|
+
columns: [
|
|
145
|
+
{ label: __('Title'), cell: row => html`<span data-form=${row.slug}>${this.canEdit ? html`<a href=${`/dashboard/content/forms/${row.id}`} class="font-medium text-foreground no-underline hover:text-primary">${row.title}</a>` : html`<span class="font-medium text-foreground">${row.title}</span>`}</span>
|
|
146
|
+
${rowActions([
|
|
147
|
+
...(this.canEdit ? [{ id: `form-${row.id}-edit`, label: __('Edit'), href: `/dashboard/content/forms/${row.id}` }] : []),
|
|
148
|
+
...(this.canHandle ? [{ id: `form-${row.id}-submissions`, label: __('Submissions'), href: submissions(row) }] : []),
|
|
149
|
+
])}` },
|
|
150
|
+
{ label: __('Slug'), cell: row => html`<code class="text-xs">${row.slug}</code>` },
|
|
151
|
+
{ label: __('Fields'), class: 'text-muted-foreground', cell: row => row.fields },
|
|
152
|
+
{ label: __('Submissions'), cell: row => this.canHandle ? html`<a href=${submissions(row)} class="text-foreground no-underline hover:text-primary">${row.kept}</a>
|
|
153
|
+
${row.fresh ? html` <a href=${`${submissions(row)}?status=new`} class="no-underline">${component(Badge, { variant: 'default' }, `${row.fresh} ${__('new')}`)}</a>` : null}` : html`<span class="text-muted-foreground">—</span>` },
|
|
154
|
+
{ label: __('Status'), cell: row => this.status(row) },
|
|
155
|
+
],
|
|
156
|
+
})}
|
|
157
|
+
${component(AlertDialog, {
|
|
158
|
+
id: 'bulk-forms-dialog',
|
|
159
|
+
open: this.pendingBulk !== null,
|
|
160
|
+
// Closed dialogs still need their labels.
|
|
161
|
+
title: this.pendingBulk ? `${this.pendingBulk.label} ${this.selected.length} ${this.selected.length === 1 ? __('form') : __('forms')}?` : __('Apply'),
|
|
162
|
+
description: this.pendingBulk?.confirm ?? '',
|
|
163
|
+
cancelLabel: __('Cancel'),
|
|
164
|
+
actionLabel: this.pendingBulk?.label || __('Apply'),
|
|
165
|
+
actionVariant: this.pendingBulk?.key === 'delete' ? 'destructive' : 'primary',
|
|
166
|
+
onAction: () => { if (this.pendingBulk) void this.runBulk(this.pendingBulk.key); },
|
|
167
|
+
onOpenChange: () => { this.pendingBulk = null; },
|
|
168
|
+
})}
|
|
169
|
+
</div>`;
|
|
170
|
+
}
|
|
171
|
+
}
|