@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,53 @@
|
|
|
1
|
+
import { Cossack, Page, State, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Card, CardBody } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { linkButton, notice, pageHeader } from '#app/cms/ui';
|
|
5
|
+
import { requireNetworkAdmin } from '#app/cms/guards';
|
|
6
|
+
import { network } from '#app/cms/network-ui';
|
|
7
|
+
|
|
8
|
+
/** The network at a glance: its sites, accounts and pending upgrades. */
|
|
9
|
+
@Page({ transport: 'http', middlewares: [requireNetworkAdmin()] })
|
|
10
|
+
export default class NetworkHome extends Cossack {
|
|
11
|
+
@State() name = '';
|
|
12
|
+
@State() sites = { active: 0, archived: 0, deleted: 0 };
|
|
13
|
+
@State() accounts = 0;
|
|
14
|
+
@State() admins = 0;
|
|
15
|
+
@State() canAdd = false;
|
|
16
|
+
|
|
17
|
+
head(): HeadValue {
|
|
18
|
+
return { title: 'Network' };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async init() {
|
|
22
|
+
const net = network(this.c);
|
|
23
|
+
this.name = (await net.settings()).name;
|
|
24
|
+
const [active, archived, deleted] = await Promise.all((['active', 'archived', 'deleted'] as const).map(async status => (await net.sites.list({ status, limit: 1 })).total));
|
|
25
|
+
// The main site counts as an active site.
|
|
26
|
+
this.sites = { active: active + 1, archived, deleted };
|
|
27
|
+
this.accounts = await net.main.accounts.count();
|
|
28
|
+
this.admins = (await net.main.accounts.list({ networkAdmins: true, limit: 1 })).total;
|
|
29
|
+
this.canAdd = net.canAddSites;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
render() {
|
|
33
|
+
const stat = (label: string, value: number, href: string) => component(Card, {}, component(CardBody, { class: 'space-y-1' }, html`
|
|
34
|
+
<p class="text-sm text-muted-foreground">${label}</p>
|
|
35
|
+
<a href=${href} class="text-2xl font-semibold text-foreground no-underline">${value}</a>`));
|
|
36
|
+
return html`<div class="max-w-5xl space-y-6">
|
|
37
|
+
${pageHeader(this.name || __('Network'), { description: __('Every site in this network, and the accounts that sign in to them.'), actions: this.canAdd ? linkButton(__('Add site'), '/dashboard/network/sites/new') : null })}
|
|
38
|
+
${this.canAdd ? null : notice(__('Sites need their own databases: files beside the main one on Node, or ROMEDB_SITES_URL and ROMEDB_SITES_TOKEN (a RomeDB organization). Until then the network is this site only.'))}
|
|
39
|
+
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
|
40
|
+
${stat(__('Active sites'), this.sites.active, '/dashboard/network/sites')}
|
|
41
|
+
${stat(__('Archived or deleted'), this.sites.archived + this.sites.deleted, '/dashboard/network/sites?status=archived')}
|
|
42
|
+
${stat(__('Accounts'), this.accounts, '/dashboard/network/users')}
|
|
43
|
+
${stat(__('Network admins'), this.admins, '/dashboard/network/users?admins=1')}
|
|
44
|
+
</div>
|
|
45
|
+
<ul class="space-y-1 text-sm">
|
|
46
|
+
<li><a class="text-primary" href="/dashboard/network/plugins">${__('Plugins')}</a> — ${__('plugins active on every site, available to each site, or hidden.')}</li>
|
|
47
|
+
<li><a class="text-primary" href="/dashboard/network/themes">${__('Themes')}</a> — ${__('the themes sites may choose.')}</li>
|
|
48
|
+
<li><a class="text-primary" href="/dashboard/network/updates">${__('Updates')}</a> — ${__('sites with schema steps to apply after a deploy.')}</li>
|
|
49
|
+
<li><a class="text-primary" href="/dashboard/settings#settings-network">${__('Settings')}</a> — ${__('the network name, the address new sites start at, and turning the network off.')}</li>
|
|
50
|
+
</ul>
|
|
51
|
+
</div>`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Cossack, Page, State, flash, flashed, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Badge, Card, CardBody } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { isCmsError, isSameOriginPost } from '@cossackframework/cms';
|
|
5
|
+
import type { NetworkPluginState } from '@cossackframework/cms/server';
|
|
6
|
+
import { artwork, notice, pageHeader, unrestrictedConfirm, unrestrictedNotice } from '#app/cms/ui';
|
|
7
|
+
import { requireNetworkAdmin } from '#app/cms/guards';
|
|
8
|
+
import { network } from '#app/cms/network-ui';
|
|
9
|
+
import { actionButton } from '#app/cms/network-view';
|
|
10
|
+
|
|
11
|
+
interface NetworkPluginRow {
|
|
12
|
+
name: string;
|
|
13
|
+
version: string;
|
|
14
|
+
description: string;
|
|
15
|
+
logo: string | null;
|
|
16
|
+
state: NetworkPluginState;
|
|
17
|
+
/** Asks for unrestricted access: a danger notice, and an approval of its own. */
|
|
18
|
+
unrestricted: boolean;
|
|
19
|
+
/** What the manifest requests. */
|
|
20
|
+
requests: string[];
|
|
21
|
+
/** Requested since a network admin approved it; only for a network-active plugin. */
|
|
22
|
+
unapproved: string[];
|
|
23
|
+
problem: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const STATES: Record<NetworkPluginState, { label: string; variant: 'success' | 'secondary' | 'outline' }> = {
|
|
27
|
+
network: { label: 'Network active', variant: 'success' },
|
|
28
|
+
available: { label: 'Available', variant: 'secondary' },
|
|
29
|
+
hidden: { label: 'Hidden', variant: 'outline' },
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Network → Plugins: one state per plugin for every site. Network active plugins run on every
|
|
34
|
+
* site with the grants approved here; available ones are each site's choice; hidden ones are
|
|
35
|
+
* not offered. Themes are under Network → Themes.
|
|
36
|
+
*/
|
|
37
|
+
@Page({ transport: 'http', middlewares: [requireNetworkAdmin()] })
|
|
38
|
+
export default class NetworkPlugins extends Cossack {
|
|
39
|
+
@State() plugins: NetworkPluginRow[] = [];
|
|
40
|
+
@State() message = '';
|
|
41
|
+
@State() error = '';
|
|
42
|
+
|
|
43
|
+
head(): HeadValue {
|
|
44
|
+
return { title: 'Network plugins' };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async init() {
|
|
48
|
+
const status = await network(this.c).main.status();
|
|
49
|
+
this.plugins = status.plugins.filter(plugin => !plugin.themeOnly).map(plugin => ({
|
|
50
|
+
name: plugin.name, version: plugin.version, description: plugin.description, logo: plugin.logo, state: plugin.network, unrestricted: plugin.unrestricted, requests: [...plugin.requests],
|
|
51
|
+
unapproved: plugin.network === 'network' ? [...plugin.missing] : [],
|
|
52
|
+
problem: plugin.reason?.startsWith('Invalid manifest') ? plugin.reason : '',
|
|
53
|
+
}));
|
|
54
|
+
this.message = flashed<string>('network.message') ?? '';
|
|
55
|
+
this.error = flashed<string>('network.error') ?? '';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async post() {
|
|
59
|
+
if (!isSameOriginPost(this.c.req.raw)) return this.c.text('Forbidden', 403);
|
|
60
|
+
const form = await this.c.req.formData();
|
|
61
|
+
const name = String(form.get('plugin') ?? '');
|
|
62
|
+
const state = (['network', 'available', 'hidden'] as const).find(entry => entry === form.get('action'));
|
|
63
|
+
try {
|
|
64
|
+
if (!state) throw new Error('Choose a state.');
|
|
65
|
+
const status = await network(this.c).setPluginState(name, state, { principal: this.c.get('principal'), unrestricted: form.get('accept-unrestricted') === name });
|
|
66
|
+
flash('network.message', state === 'network' ? `${name}: ${status.active ? __('active on every site.') : status.reason ?? ''}` : `${name}: ${__(STATES[state].label).toLowerCase()}.`);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
flash('network.error', isCmsError(error) ? error.message : `${name} could not be changed.`);
|
|
69
|
+
}
|
|
70
|
+
return this.redirect('/dashboard/network/plugins');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
render() {
|
|
74
|
+
const th = 'px-3 py-2 font-medium';
|
|
75
|
+
return html`<div class="max-w-5xl space-y-6">
|
|
76
|
+
${pageHeader(__('Network plugins'), { description: __('Plugin code ships with the application. Choose for every site whether a plugin runs everywhere, is each site\'s choice, or stays hidden.') })}
|
|
77
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
78
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
79
|
+
${this.plugins.filter(plugin => plugin.unrestricted && (plugin.state !== 'network' || plugin.unapproved.length)).map(plugin => unrestrictedNotice(plugin.name,
|
|
80
|
+
unrestrictedConfirm({ name: 'accept-unrestricted', value: plugin.name }, { name: 'action', value: 'network', label: __('Network activate with unrestricted access') }, { plugin: plugin.name })))}
|
|
81
|
+
${this.plugins.length ? component(Card, {}, component(CardBody, { class: 'p-0' }, html`<div class="overflow-x-auto"><table class="w-full text-sm">
|
|
82
|
+
<thead><tr class="border-b border-border text-left text-xs uppercase tracking-wide text-muted-foreground">
|
|
83
|
+
<th class=${th}>${__('Plugin')}</th><th class=${th}>${__('Requests')}</th><th class=${th}>${__('State')}</th><th class=${`${th} text-right`}>${__('Actions')}</th>
|
|
84
|
+
</tr></thead>
|
|
85
|
+
<tbody>${this.plugins.map(plugin => html`<tr data-plugin=${plugin.name} data-state=${plugin.state} class="border-b border-border last:border-0 align-top">
|
|
86
|
+
<td class="px-3 py-3"><div class="flex min-w-[12rem] items-center gap-3">
|
|
87
|
+
${artwork('logo', plugin.logo, plugin.name, plugin.name)}
|
|
88
|
+
<div class="min-w-0">
|
|
89
|
+
<p class="truncate font-semibold text-foreground">${plugin.name}</p>
|
|
90
|
+
<p class="text-xs text-muted-foreground">${__('version')} ${plugin.version}</p>
|
|
91
|
+
${plugin.description ? html`<p class="mt-1 text-xs text-muted-foreground">${plugin.description}</p>` : null}
|
|
92
|
+
</div>
|
|
93
|
+
</div></td>
|
|
94
|
+
<td class="px-3 py-3 text-xs text-muted-foreground">
|
|
95
|
+
${plugin.requests.join(', ')}
|
|
96
|
+
${plugin.unapproved.length ? html`<p class="mt-1 text-warning-text">${__('Not approved yet')}: ${plugin.unapproved.join(', ')}</p>` : null}
|
|
97
|
+
${plugin.problem ? html`<p class="mt-1 text-destructive">${plugin.problem}</p>` : null}
|
|
98
|
+
</td>
|
|
99
|
+
<td class="px-3 py-3">${component(Badge, { variant: STATES[plugin.state].variant }, __(STATES[plugin.state].label))}
|
|
100
|
+
${plugin.unrestricted ? html`<div class="mt-1">${component(Badge, { variant: 'destructive' }, __('Unrestricted'))}</div>` : null}</td>
|
|
101
|
+
<td class="px-3 py-3"><div class="flex flex-wrap justify-end gap-2">
|
|
102
|
+
${!plugin.unrestricted && (plugin.state !== 'network' || plugin.unapproved.length) ? actionButton('network', plugin.state === 'network' ? __('Approve and keep active') : __('Network activate'), { plugin: plugin.name }) : null}
|
|
103
|
+
${plugin.state !== 'available' ? actionButton('available', plugin.state === 'network' ? __('Network deactivate') : __('Make available'), { plugin: plugin.name }) : null}
|
|
104
|
+
${plugin.state !== 'hidden' ? actionButton('hidden', __('Hide'), { plugin: plugin.name }, { danger: true }) : null}
|
|
105
|
+
</div></td>
|
|
106
|
+
</tr>`)}</tbody></table></div>`)) : html`<p class="text-sm text-muted-foreground">${__('No plugins. Render one with')} <code>cossack add plugin</code>.</p>`}
|
|
107
|
+
<p class="text-xs text-muted-foreground">${__('Network activate approves everything the plugin requests, for every site; an upgrade that requests more waits here. Each site migrates it when it next loads. Network deactivate leaves it to each site again, with the site\'s own grant.')}</p>
|
|
108
|
+
</div>`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { Client, Cossack, Page, State, flash, flashed, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Badge, Card, CardBody, CardHeader, NativeSelect, Button } from '@cossackframework/ui';
|
|
3
|
+
import { html, component, type TemplateResult } from '@cossackframework/renderer';
|
|
4
|
+
import { isCmsError, isSameOriginPost } from '@cossackframework/cms';
|
|
5
|
+
import { networkSite, siteImportState, type SiteDomain, type SiteStatus } from '@cossackframework/cms/server';
|
|
6
|
+
import { notice, pageHeader, shortDate } from '#app/cms/ui';
|
|
7
|
+
import { requireNetworkAdmin } from '#app/cms/guards';
|
|
8
|
+
import { network, siteLinks } from '#app/cms/network-ui';
|
|
9
|
+
import { actionButton, field, siteStatus, submitButton } from '#app/cms/network-view';
|
|
10
|
+
import { listTable } from '#app/dashboard/list-table';
|
|
11
|
+
import { importRequest, importSummary, sendsExport } from '#app/cms/site-import';
|
|
12
|
+
import { sendExport } from '#app/cms/import.client';
|
|
13
|
+
|
|
14
|
+
/** `movable`: the account can change kind here, a network account only when it belongs to this site alone and does not run the network. */
|
|
15
|
+
interface Member { id: string; name: string; email: string; roles: string; account: 'site' | 'network'; movable: boolean }
|
|
16
|
+
|
|
17
|
+
/** One site: its name, domains (with the check that makes one primary), members and state. */
|
|
18
|
+
@Page({ transport: 'http', middlewares: [requireNetworkAdmin()] })
|
|
19
|
+
export default class NetworkSite extends Cossack {
|
|
20
|
+
/** A site export arrives as the request body and is read as a stream, so it may be large. */
|
|
21
|
+
static maxBodyBytes = 4 * 1024 * 1024 * 1024;
|
|
22
|
+
|
|
23
|
+
@State() id = '';
|
|
24
|
+
@State() name = '';
|
|
25
|
+
@State() status: SiteStatus = 'active';
|
|
26
|
+
@State() createdAt = 0;
|
|
27
|
+
@State() domains: SiteDomain[] = [];
|
|
28
|
+
@State() members: Member[] = [];
|
|
29
|
+
@State() roles: { id: string; name: string }[] = [];
|
|
30
|
+
@State() home = '';
|
|
31
|
+
@State() dashboard = '';
|
|
32
|
+
/** The site's export request: who asked and when, and the approval while it lasts. */
|
|
33
|
+
@State() exportRequest: { by: string; at: number; approvedAt: number | null; expiresAt: number | null } | null = null;
|
|
34
|
+
/** Whether an export can be imported: into a new site, or again after an import stopped. */
|
|
35
|
+
@State() importState: 'new' | 'stopped' | 'running' | 'used' = 'used';
|
|
36
|
+
@State() importing = false;
|
|
37
|
+
@State() importError = '';
|
|
38
|
+
@State() message = '';
|
|
39
|
+
@State() error = '';
|
|
40
|
+
|
|
41
|
+
head(): HeadValue {
|
|
42
|
+
return { title: this.name || 'Site' };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async init() {
|
|
46
|
+
const net = network(this.c);
|
|
47
|
+
const record = await net.sites.get(this.c.req.param('id') ?? '');
|
|
48
|
+
if (!record) { this.error = __('There is no such site.'); this.c.status(404); return; }
|
|
49
|
+
Object.assign(this, { id: record.id, name: record.name, status: record.status, createdAt: record.createdAt, domains: [...record.domains] }, siteLinks(this.c, networkSite(record)));
|
|
50
|
+
if (record.status !== 'creating') {
|
|
51
|
+
const host = net.hostOf(networkSite(record));
|
|
52
|
+
const users = (await host.users.list({ limit: 100 })).items;
|
|
53
|
+
const network = users.filter(user => user.account === 'network').map(user => user.id);
|
|
54
|
+
const [sites, admins] = await Promise.all([net.main.accounts.memberships(network), net.main.accounts.list({ networkAdmins: true, limit: 100 })]);
|
|
55
|
+
const runsNetwork = new Set(admins.items.map(account => account.id));
|
|
56
|
+
this.members = users.map(user => ({
|
|
57
|
+
id: user.id, name: user.name, email: user.email, roles: user.assignments.map(role => role.name).join(', ') || __('No role'), account: user.account,
|
|
58
|
+
movable: user.account === 'site' || (!runsNetwork.has(user.id) && (sites.get(user.id) ?? []).every(site => site === record.id)),
|
|
59
|
+
}));
|
|
60
|
+
this.roles = (await host.users.roles()).map(role => ({ id: role.id, name: role.name }));
|
|
61
|
+
this.importState = await siteImportState(host);
|
|
62
|
+
}
|
|
63
|
+
const request = (await net.exportRequests()).get(record.id);
|
|
64
|
+
if (request) {
|
|
65
|
+
const account = await net.main.accounts.get(request.requestedBy);
|
|
66
|
+
this.exportRequest = { by: account ? `${account.name} (${account.email})` : request.requestedBy, at: request.requestedAt, approvedAt: request.approvedAt, expiresAt: request.expiresAt };
|
|
67
|
+
}
|
|
68
|
+
this.message = flashed<string>('network.message') ?? '';
|
|
69
|
+
this.error = flashed<string>('network.error') ?? '';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async post() {
|
|
73
|
+
if (!isSameOriginPost(this.c.req.raw)) return this.c.text('Forbidden', 403);
|
|
74
|
+
const id = this.c.req.param('id') ?? '';
|
|
75
|
+
// An export sent as the request body; everything else is a form.
|
|
76
|
+
if (sendsExport(this.c)) return this.importSite(id, true);
|
|
77
|
+
const form = await this.c.req.formData();
|
|
78
|
+
const value = (name: string) => String(form.get(name) ?? '').trim();
|
|
79
|
+
const net = network(this.c);
|
|
80
|
+
const principal = this.c.get('principal');
|
|
81
|
+
try {
|
|
82
|
+
const record = await net.sites.get(id);
|
|
83
|
+
if (!record) throw new Error(__('There is no such site.'));
|
|
84
|
+
const action = value('action');
|
|
85
|
+
if (action === 'rename') {
|
|
86
|
+
await net.sites.update(id, { name: value('name') });
|
|
87
|
+
net.invalidate();
|
|
88
|
+
flash('network.message', __('Saved.'));
|
|
89
|
+
} else if (action === 'add-domain') {
|
|
90
|
+
await net.addDomain(id, value('host'), { principal });
|
|
91
|
+
flash('network.message', __('Added. Point its DNS at this network, then check it to make it the primary domain.'));
|
|
92
|
+
} else if (action === 'check-domain') {
|
|
93
|
+
flash(await net.checkDomain(id, value('host'), { principal }) ? 'network.message' : 'network.error',
|
|
94
|
+
await net.sites.get(id).then(site => site?.domains.find(domain => domain.host === value('host'))?.primary) ? `${value('host')} ${__('is now the primary domain.')}` : `${value('host')} ${__('does not answer for this site yet. Waiting for DNS.')}`);
|
|
95
|
+
} else if (action === 'remove-domain') {
|
|
96
|
+
await net.removeDomain(id, value('host'), { principal });
|
|
97
|
+
flash('network.message', __('Removed.'));
|
|
98
|
+
} else if (action === 'add-member') {
|
|
99
|
+
const account = await net.main.accounts.findByEmail(value('email'));
|
|
100
|
+
if (!account) throw new Error(__('No network account has that email.'));
|
|
101
|
+
const host = net.hostOf(networkSite(record));
|
|
102
|
+
await host.users.addMember(account.id);
|
|
103
|
+
await host.users.setRoles(account.id, value('role') ? [value('role')] : []);
|
|
104
|
+
flash('network.message', `${account.name} ${__('is a member now.')}`);
|
|
105
|
+
} else if (action === 'convert-member') {
|
|
106
|
+
const to = value('to') === 'site' ? 'site' : 'network';
|
|
107
|
+
const user = await net.hostOf(networkSite(record)).users.convert(value('account'), to);
|
|
108
|
+
flash('network.message', `${user.name} ${to === 'site' ? __('has a site account now.') : __('has a network account now.')}`);
|
|
109
|
+
} else if (action === 'import') {
|
|
110
|
+
return this.importSite(id, false);
|
|
111
|
+
} else if (action === 'remove-member') {
|
|
112
|
+
await net.hostOf(networkSite(record)).users.delete(value('account'));
|
|
113
|
+
flash('network.message', __('Removed from the site.'));
|
|
114
|
+
} else if (action === 'approve-export' || action === 'decline-export') {
|
|
115
|
+
await net.answerExport(id, action === 'approve-export', { principal });
|
|
116
|
+
flash('network.message', action === 'approve-export' ? __('Approved. The site can download its export under Tools → Export for 7 days.') : __('Declined.'));
|
|
117
|
+
} else if (action === 'archive' || action === 'restore' || action === 'delete') {
|
|
118
|
+
const site = await net.setSiteStatus(id, action === 'archive' ? 'archived' : action === 'delete' ? 'deleted' : 'active', { principal });
|
|
119
|
+
flash('network.message', action === 'delete' ? `${site.name} ${__('is deleted. It can be restored for 30 days.')}` : `${site.name} ${action === 'archive' ? __('is archived.') : __('is active.')}`);
|
|
120
|
+
}
|
|
121
|
+
} catch (error) {
|
|
122
|
+
flash('network.error', isCmsError(error) || error instanceof Error ? (error as Error).message : __('The site could not be changed.'));
|
|
123
|
+
}
|
|
124
|
+
return this.redirect(`/dashboard/network/sites/${id}`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Fill the site from an export: in the request body, or a form's file. */
|
|
128
|
+
private async importSite(id: string, raw: boolean) {
|
|
129
|
+
const net = network(this.c);
|
|
130
|
+
try {
|
|
131
|
+
const record = await net.sites.get(id);
|
|
132
|
+
if (!record || record.status === 'creating') throw new Error(__('There is no such site.'));
|
|
133
|
+
flash('network.message', importSummary(await importRequest(this.c, net.hostOf(networkSite(record)))));
|
|
134
|
+
return raw ? this.c.json({ next: `/dashboard/network/sites/${id}` }) : this.redirect(`/dashboard/network/sites/${id}`);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
const message = isCmsError(error) || error instanceof Error ? (error as Error).message : __('The export could not be imported.');
|
|
137
|
+
if (raw) return this.c.json({ error: message }, 400);
|
|
138
|
+
flash('network.error', message);
|
|
139
|
+
return this.redirect(`/dashboard/network/sites/${id}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Send the export as the request body, so a large file is read as a stream. */
|
|
144
|
+
@Client()
|
|
145
|
+
async upload(event: SubmitEvent) {
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
const form = event.currentTarget as HTMLFormElement;
|
|
148
|
+
this.importing = true;
|
|
149
|
+
this.importError = '';
|
|
150
|
+
const result = await sendExport(form);
|
|
151
|
+
if (result.next) { location.assign(result.next); return; }
|
|
152
|
+
this.importing = false;
|
|
153
|
+
this.importError = result.error ?? '';
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
render() {
|
|
157
|
+
if (!this.id) return html`<div class="max-w-3xl space-y-4">${notice(this.error, 'error')}<a href="/dashboard/network/sites" class="text-sm text-primary">← ${__('Sites')}</a></div>`;
|
|
158
|
+
const live = this.status === 'active' || this.status === 'archived';
|
|
159
|
+
const card = (title: string, body: TemplateResult, description = '') => component(Card, {}, html`
|
|
160
|
+
${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${title}</h2>${description ? html`<p class="mt-1 text-sm text-muted-foreground">${description}</p>` : null}`)}
|
|
161
|
+
${component(CardBody, { class: 'space-y-4' }, body)}`);
|
|
162
|
+
return html`<div class="max-w-4xl space-y-6">
|
|
163
|
+
${pageHeader(this.name, {
|
|
164
|
+
titleActions: siteStatus(this.status),
|
|
165
|
+
description: `${this.domains.find(domain => domain.primary)?.host ?? ''}${this.createdAt ? ` · ${__('Created')} ${shortDate(this.createdAt)}` : ''}`,
|
|
166
|
+
actions: html`<div class="flex flex-wrap items-center gap-3 text-sm">
|
|
167
|
+
<a href="/dashboard/network/sites" class="text-muted-foreground hover:text-foreground">← ${__('Sites')}</a>
|
|
168
|
+
${live ? html`<a class="text-primary" href=${this.dashboard}>${__('Dashboard')}</a><a class="text-primary" href=${this.home}>${__('Visit')}</a>` : null}
|
|
169
|
+
</div>`,
|
|
170
|
+
})}
|
|
171
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
172
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
173
|
+
${card(__('Details'), html`<form method="post" class="flex max-w-xl items-end gap-3">
|
|
174
|
+
<input type="hidden" name="action" value="rename">
|
|
175
|
+
<div class="flex-1">${field('name', __('Name'), { value: this.name, required: true })}</div>
|
|
176
|
+
${submitButton(__('Save'))}
|
|
177
|
+
</form>`)}
|
|
178
|
+
${card(__('Domains'), html`
|
|
179
|
+
<ul class="divide-y divide-border rounded-lg border border-border">${this.domains.map(domain => html`<li class="flex flex-wrap items-center justify-between gap-2 px-3 py-2 text-sm" data-domain=${domain.host}>
|
|
180
|
+
<span><span class="font-medium text-foreground">${domain.host}</span>
|
|
181
|
+
<span class="ml-2 text-xs text-muted-foreground">${domain.primary ? __('Primary') : domain.verifiedAt ? __('Alias, redirects to the primary domain') : __('Waiting for DNS')}</span></span>
|
|
182
|
+
<span class="flex gap-1.5">${domain.primary ? null : html`${actionButton('check-domain', __('Check and make primary'), { host: domain.host })}${actionButton('remove-domain', __('Remove'), { host: domain.host }, { danger: true })}`}</span>
|
|
183
|
+
</li>`)}</ul>
|
|
184
|
+
<form method="post" class="flex max-w-xl items-end gap-3">
|
|
185
|
+
<input type="hidden" name="action" value="add-domain">
|
|
186
|
+
<div class="flex-1">${field('host', __('Add a domain'), { placeholder: 'www.example.org', required: true })}</div>
|
|
187
|
+
${submitButton(__('Add'))}
|
|
188
|
+
</form>`, __('The primary domain serves the site; the others redirect to it.'))}
|
|
189
|
+
${this.status === 'creating' ? null : html`<section class="space-y-3">
|
|
190
|
+
<h2 class="text-base font-semibold text-foreground">${__('Members')}</h2>
|
|
191
|
+
${listTable<Member>({
|
|
192
|
+
rows: this.members, key: member => member.id, rowAttribute: 'data-member', empty: __('This site has no members.'),
|
|
193
|
+
columns: [
|
|
194
|
+
// Site accounts are the site's own: the network lists only its accounts.
|
|
195
|
+
{ label: __('Member'), cell: member => html`${member.account === 'network' ? html`<a href=${`/dashboard/network/users/${member.id}`} class="font-medium text-foreground no-underline hover:text-primary">${member.name}</a>`
|
|
196
|
+
: html`<span class="font-medium text-foreground">${member.name}</span> ${component(Badge, { variant: 'outline' }, __('Site account'))}`}
|
|
197
|
+
<span class="block text-xs text-muted-foreground">${member.email}</span>` },
|
|
198
|
+
{ label: __('Roles'), class: 'text-muted-foreground', cell: member => member.roles },
|
|
199
|
+
{ label: '', class: 'text-right', cell: member => html`<span class="inline-flex flex-wrap justify-end gap-1.5">
|
|
200
|
+
${member.movable ? actionButton('convert-member', member.account === 'site' ? __('Make a network account') : __('Make a site account'), { account: member.id, to: member.account === 'site' ? 'network' : 'site' }) : null}
|
|
201
|
+
${actionButton('remove-member', __('Remove from site'), { account: member.id }, { danger: true })}</span>` },
|
|
202
|
+
],
|
|
203
|
+
})}
|
|
204
|
+
<form method="post" class="max-w-xl space-y-1.5">
|
|
205
|
+
<input type="hidden" name="action" value="add-member">
|
|
206
|
+
<div class="flex flex-wrap items-end gap-3">
|
|
207
|
+
<div class="flex-1">${field('email', __('Add a network account'), { type: 'email', required: true })}</div>
|
|
208
|
+
${component(NativeSelect, { name: 'role', inline: true, 'aria-label': __('Role') }, html`
|
|
209
|
+
<option value="">${__('No role')}</option>
|
|
210
|
+
${this.roles.map(role => html`<option value=${role.id} ?selected=${role.id === 'editor'}>${role.name}</option>`)}`)}
|
|
211
|
+
${submitButton(__('Add'))}
|
|
212
|
+
</div>
|
|
213
|
+
<p class="text-xs text-muted-foreground">${__('Site accounts are added on the site, under Users.')}</p>
|
|
214
|
+
</form>
|
|
215
|
+
<p class="text-xs text-muted-foreground">${__('A network account signs in on the network and can join other sites; a site account signs in on this site only. Changing the kind keeps the member\'s roles, password and authenticator app. Their sessions end, and their passkeys are removed: passkeys work only on the address they were made on.')}</p>
|
|
216
|
+
</section>`}
|
|
217
|
+
${this.status !== 'creating' && (this.importState === 'new' || this.importState === 'stopped') ? card(__('Import an export'), html`
|
|
218
|
+
${this.importState === 'stopped' ? html`<p class="text-sm text-foreground" data-import-stopped>${__('An import into this site stopped partway. Import the export again to start over.')}</p>` : null}
|
|
219
|
+
${this.importError ? notice(this.importError, 'error') : null}
|
|
220
|
+
<form method="post" enctype="multipart/form-data" class="flex max-w-xl flex-wrap items-end gap-3" data-site-import @submit=${(event: SubmitEvent) => this.upload(event)}>
|
|
221
|
+
<input type="hidden" name="action" value="import">
|
|
222
|
+
<input name="file" type="file" required accept=".json,application/json" aria-label=${__('Export file')} class="block flex-1 text-sm text-foreground">
|
|
223
|
+
${component(Button, { type: 'submit', disabled: this.importing }, this.importing ? __('Importing…') : __('Import'))}
|
|
224
|
+
</form>`, __('Fill this new site from another site\'s JSON export: its content, settings, roles and members. Network accounts among the members stay network accounts; the others get site accounts and set their passwords with Forgot password. Media files are not in exports: copy them to this site\'s storage.')) : null}
|
|
225
|
+
${this.status === 'creating' ? null : card(__('Database export'), html`
|
|
226
|
+
${this.exportRequest ? html`<p class="text-sm text-foreground" data-export-request>${this.exportRequest.approvedAt
|
|
227
|
+
? `${__('Approved')} ${shortDate(this.exportRequest.approvedAt)}: ${__('the site can download its export until')} ${shortDate(this.exportRequest.expiresAt)}.`
|
|
228
|
+
: `${this.exportRequest.by} ${__('requested an export on')} ${shortDate(this.exportRequest.at)}.`}</p>
|
|
229
|
+
${this.exportRequest.approvedAt ? null : html`<div class="flex flex-wrap gap-2">${actionButton('approve-export', __('Approve'))}${actionButton('decline-export', __('Decline'), {}, { danger: true })}</div>`}` : null}
|
|
230
|
+
<div class="flex flex-wrap gap-2">
|
|
231
|
+
<a href=${`/api/cms/network/sites/${this.id}/export`} download class="inline-flex w-fit items-center justify-center rounded-md border border-border px-3 py-1.5 text-sm font-medium text-foreground no-underline hover:bg-muted">${__('Download export')}</a>
|
|
232
|
+
<a href=${`/api/cms/network/sites/${this.id}/export?format=romedb`} download data-database-file class="inline-flex w-fit items-center justify-center rounded-md border border-border px-3 py-1.5 text-sm font-medium text-foreground no-underline hover:bg-muted">${__('Download database file')}</a>
|
|
233
|
+
</div>`,
|
|
234
|
+
__('The JSON export leaves out sessions, passwords, second factors, application passwords and webhook secrets. The database file is a .romedb file that a new install opens directly: it keeps the site\'s own accounts with their password hashes, without sessions, webhooks or pending work. Media files are in neither.'))}
|
|
235
|
+
${this.status === 'creating' ? null : card(__('Site state'), html`<div class="flex flex-wrap gap-2">
|
|
236
|
+
${this.status === 'active' ? actionButton('archive', __('Archive'), {}) : null}
|
|
237
|
+
${this.status === 'archived' || this.status === 'deleted' ? actionButton('restore', __('Restore'), {}) : null}
|
|
238
|
+
${live ? actionButton('delete', __('Delete'), {}, { danger: true }) : null}
|
|
239
|
+
</div>`, this.status === 'deleted' ? __('Deleted: its database and media go for good 30 days after deletion. Restore it before then.')
|
|
240
|
+
: __('Archived sites show visitors "This site is archived"; members keep their dashboard. A deleted site can be restored for 30 days.'))}
|
|
241
|
+
</div>`;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Client, Cossack, Page, Server, State, flashed, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { AlertDialog } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { isCmsError, MAIN_SITE } from '@cossackframework/cms';
|
|
5
|
+
import { networkSite, type SiteStatus } from '@cossackframework/cms/server';
|
|
6
|
+
import { linkButton, notice, pageHeader, shortDate } from '#app/cms/ui';
|
|
7
|
+
import { requireNetworkAdmin } from '#app/cms/guards';
|
|
8
|
+
import { network, siteIconUrl, siteLinks } from '#app/cms/network-ui';
|
|
9
|
+
import { siteIcon, siteStatus } from '#app/cms/network-view';
|
|
10
|
+
import { listFilters, listFooter, listTable, rowActions } from '#app/dashboard/list-table';
|
|
11
|
+
|
|
12
|
+
const PAGE_SIZE = 20;
|
|
13
|
+
const STATUSES = ['active', 'archived', 'deleted', 'creating'] as const;
|
|
14
|
+
const STATUS_LABELS: Record<string, string> = { '': 'All', active: 'Active', archived: 'Archived', deleted: 'Deleted', creating: 'Being created' };
|
|
15
|
+
|
|
16
|
+
interface SiteRow { id: string; name: string; host: string; status: SiteStatus; members: number; createdAt: number | null; home: string; dashboard: string; icon: string; exportRequested: boolean }
|
|
17
|
+
|
|
18
|
+
/** Network → Sites: every site as a list table, the main site first, with its address, members and state. */
|
|
19
|
+
@Page({ transport: 'http', middlewares: [requireNetworkAdmin()] })
|
|
20
|
+
export default class NetworkSites extends Cossack {
|
|
21
|
+
@State() rows: SiteRow[] = [];
|
|
22
|
+
@State() total = 0;
|
|
23
|
+
@State() pages = 1;
|
|
24
|
+
@State() page = 1;
|
|
25
|
+
@State() search = '';
|
|
26
|
+
@State() status = '';
|
|
27
|
+
/** The status links above the list, with how many sites each has. */
|
|
28
|
+
@State() counts: { key: string; count: number }[] = [];
|
|
29
|
+
@State() canAdd = false;
|
|
30
|
+
@State() message = '';
|
|
31
|
+
@State() error = '';
|
|
32
|
+
/** The site waiting for the delete confirmation. */
|
|
33
|
+
@State() pendingDelete: SiteRow | null = null;
|
|
34
|
+
|
|
35
|
+
head(): HeadValue {
|
|
36
|
+
return { title: 'Sites' };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async init() {
|
|
40
|
+
const query = this.c.req.query();
|
|
41
|
+
this.search = query.q?.trim() ?? '';
|
|
42
|
+
this.status = (STATUSES as readonly string[]).includes(query.status ?? '') ? query.status! : '';
|
|
43
|
+
const page = Number(query.page);
|
|
44
|
+
this.page = page >= 1 ? Math.floor(page) : 1;
|
|
45
|
+
this.canAdd = network(this.c).canAddSites;
|
|
46
|
+
this.message = flashed<string>('network.message') ?? '';
|
|
47
|
+
await this.load();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The page of sites and the counts by status. The main site, which has no registry row, leads All and Active. */
|
|
51
|
+
private async load() {
|
|
52
|
+
const net = network(this.c);
|
|
53
|
+
const search = this.search ? { search: this.search } : {};
|
|
54
|
+
const [totals, memberships, mainName, networkIcon, requests] = await Promise.all([
|
|
55
|
+
Promise.all(STATUSES.map(status => net.sites.list({ ...search, status, limit: 1 }).then(found => found.total))),
|
|
56
|
+
// Network accounts by site, for sites whose database is not open: being created or deleted.
|
|
57
|
+
net.main.accounts.memberCounts(),
|
|
58
|
+
net.main.settings.get('general.siteTitle').then(title => title || __('Main site'), () => __('Main site')),
|
|
59
|
+
// The main site's icon is the network's, for sites without one.
|
|
60
|
+
siteIconUrl(this.c, net.main, { host: null }),
|
|
61
|
+
net.exportRequests(),
|
|
62
|
+
]);
|
|
63
|
+
const withMain = !this.search || mainName.toLowerCase().includes(this.search.toLowerCase()) ? 1 : 0;
|
|
64
|
+
const byStatus = new Map(STATUSES.map((status, index) => [status, totals[index]!]));
|
|
65
|
+
this.counts = [
|
|
66
|
+
{ key: '', count: totals.reduce((sum, count) => sum + count, withMain) },
|
|
67
|
+
...STATUSES.map(status => ({ key: status, count: byStatus.get(status)! + (status === 'active' ? withMain : 0) })).filter(entry => entry.key !== 'creating' || entry.count),
|
|
68
|
+
];
|
|
69
|
+
const found = await net.sites.list({ ...search, ...(this.status ? { status: this.status as SiteStatus } : {}), limit: PAGE_SIZE, offset: (this.page - 1) * PAGE_SIZE });
|
|
70
|
+
const leadsWithMain = withMain && this.page === 1 && (!this.status || this.status === 'active');
|
|
71
|
+
const main: SiteRow[] = leadsWithMain ? [{ id: MAIN_SITE, name: mainName, host: new URL(siteLinks(this.c, { host: null }).home, this.c.req.url).host, status: 'active', members: await net.main.users.count().catch(() => memberships.get(MAIN_SITE) ?? 0), createdAt: null, icon: networkIcon, exportRequested: false, ...siteLinks(this.c, { host: null }) }] : [];
|
|
72
|
+
this.rows = [...main, ...await Promise.all(found.items.map(async site => {
|
|
73
|
+
const host = site.domains.find(domain => domain.primary)?.host ?? '';
|
|
74
|
+
// Sites being created or deleted have no settings to read; open ones count site accounts too.
|
|
75
|
+
const open = site.status === 'active' || site.status === 'archived' ? net.hostOf(networkSite(site)) : null;
|
|
76
|
+
const own = open ? await siteIconUrl(this.c, open, { host }) : '';
|
|
77
|
+
const members = open ? await open.users.count().catch(() => memberships.get(site.id) ?? 0) : memberships.get(site.id) ?? 0;
|
|
78
|
+
return { id: site.id, name: site.name, host, status: site.status, members, createdAt: site.createdAt, icon: own || networkIcon,
|
|
79
|
+
exportRequested: requests.get(site.id)?.approvedAt === null, ...siteLinks(this.c, { host }) };
|
|
80
|
+
}))];
|
|
81
|
+
this.total = found.total + (this.status === '' || this.status === 'active' ? withMain : 0);
|
|
82
|
+
this.pages = Math.max(1, Math.ceil(found.total / PAGE_SIZE));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Archive, restore or delete a site. A deleted site can be restored for 30 days. */
|
|
86
|
+
@Server()
|
|
87
|
+
async change(id: string, action: 'archive' | 'restore' | 'delete') {
|
|
88
|
+
this.message = '';
|
|
89
|
+
this.error = '';
|
|
90
|
+
try {
|
|
91
|
+
const site = await network(this.c).setSiteStatus(id, action === 'archive' ? 'archived' : action === 'delete' ? 'deleted' : 'active', { principal: this.c.get('principal') });
|
|
92
|
+
this.message = action === 'delete' ? `${site.name} ${__('is deleted. It can be restored for 30 days.')}` : `${site.name} ${action === 'archive' ? __('is archived.') : __('is active.')}`;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
this.error = isCmsError(error) ? error.message : __('The site could not be changed.');
|
|
95
|
+
}
|
|
96
|
+
await this.load();
|
|
97
|
+
if (this.page > this.pages) { this.page = this.pages; await this.load(); }
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@Client()
|
|
101
|
+
async act(row: SiteRow, action: 'archive' | 'restore') {
|
|
102
|
+
await this.change(row.id, action);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@Client()
|
|
106
|
+
requestDelete(row: SiteRow) {
|
|
107
|
+
this.pendingDelete = row;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@Client()
|
|
111
|
+
async confirmDelete() {
|
|
112
|
+
const row = this.pendingDelete;
|
|
113
|
+
this.pendingDelete = null;
|
|
114
|
+
if (row) await this.change(row.id, 'delete');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The list's address with the current search and status. */
|
|
118
|
+
private href(options: { status?: string; page?: number } = {}): string {
|
|
119
|
+
const params = new URLSearchParams();
|
|
120
|
+
const status = options.status ?? this.status;
|
|
121
|
+
if (this.search) params.set('q', this.search);
|
|
122
|
+
if (status) params.set('status', status);
|
|
123
|
+
if ((options.page ?? 1) > 1) params.set('page', String(options.page));
|
|
124
|
+
const query = params.toString();
|
|
125
|
+
return query ? `/dashboard/network/sites?${query}` : '/dashboard/network/sites';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
render() {
|
|
129
|
+
const actions = (row: SiteRow) => rowActions([
|
|
130
|
+
...(row.id === MAIN_SITE ? [] : [{ id: `site-${row.id}-edit`, label: __('Edit'), href: `/dashboard/network/sites/${row.id}` }]),
|
|
131
|
+
...(row.status === 'active' || row.status === 'archived' ? [
|
|
132
|
+
{ id: `site-${row.id}-dashboard`, label: __('Dashboard'), href: row.dashboard },
|
|
133
|
+
{ id: `site-${row.id}-visit`, label: __('Visit'), href: row.home },
|
|
134
|
+
] : []),
|
|
135
|
+
...(row.id === MAIN_SITE ? [] : [
|
|
136
|
+
...(row.status === 'active' ? [{ id: `site-${row.id}-archive`, label: __('Archive'), run: () => this.act(row, 'archive') }] : []),
|
|
137
|
+
...(row.status === 'archived' || row.status === 'deleted' ? [{ id: `site-${row.id}-restore`, label: __('Restore'), run: () => this.act(row, 'restore') }] : []),
|
|
138
|
+
...(row.status === 'active' || row.status === 'archived' ? [{ id: `site-${row.id}-delete`, label: __('Delete'), danger: true, run: () => this.requestDelete(row) }] : []),
|
|
139
|
+
]),
|
|
140
|
+
]);
|
|
141
|
+
return html`<div class="space-y-6">
|
|
142
|
+
${pageHeader(__('Sites'), {
|
|
143
|
+
description: __('The main site is the network itself; every other site has its own database.'),
|
|
144
|
+
titleActions: this.canAdd ? linkButton(__('Add site'), '/dashboard/network/sites/new', 'primary', { size: 'sm' }) : null,
|
|
145
|
+
})}
|
|
146
|
+
${this.message && !this.error ? notice(this.message, 'success') : null}
|
|
147
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
148
|
+
${this.canAdd ? null : notice(__('This network cannot add sites yet: give it a provider for site databases (see Settings → Network).'))}
|
|
149
|
+
<div class="space-y-3">
|
|
150
|
+
<nav aria-label=${__('Filter by status')} class="flex flex-wrap gap-x-3 gap-y-1 text-sm">
|
|
151
|
+
${this.counts.map((tab, index) => html`${index ? html`<span class="text-muted-foreground" aria-hidden="true">|</span>` : null}
|
|
152
|
+
<a href=${this.href({ status: tab.key })} class=${tab.key === this.status ? 'font-semibold text-foreground no-underline' : 'text-primary no-underline hover:underline'}
|
|
153
|
+
aria-current=${tab.key === this.status ? 'page' : 'false'}>${__(STATUS_LABELS[tab.key]!)} <span class="text-muted-foreground">(${tab.count})</span></a>`)}
|
|
154
|
+
</nav>
|
|
155
|
+
${listFilters({ action: '/dashboard/network/sites', hidden: { status: this.status }, search: { name: 'q', value: this.search, placeholder: __('Search names and domains') } })}
|
|
156
|
+
</div>
|
|
157
|
+
${listTable<SiteRow>({
|
|
158
|
+
rows: this.rows, key: row => row.id, rowAttribute: 'data-site', empty: this.search || this.status ? __('No sites match.') : __('No sites besides the main one yet.'),
|
|
159
|
+
columns: [
|
|
160
|
+
{ label: __('Site'), cell: row => html`<div class="flex items-start gap-3">${siteIcon(row.icon)}<div class="min-w-0">
|
|
161
|
+
${row.id === MAIN_SITE ? html`<span class="font-medium text-foreground">${row.name}</span> <span class="text-xs text-muted-foreground">(${__('main site')})</span>`
|
|
162
|
+
: html`<a href=${`/dashboard/network/sites/${row.id}`} class="font-medium text-foreground no-underline hover:text-primary">${row.name}</a>`}
|
|
163
|
+
<span class="block text-xs text-muted-foreground">${row.host}</span>
|
|
164
|
+
${actions(row)}
|
|
165
|
+
</div></div>` },
|
|
166
|
+
{ label: __('Members'), class: 'text-right text-muted-foreground', cell: row => row.members },
|
|
167
|
+
{ label: __('Status'), cell: row => html`<div class="flex flex-wrap items-center gap-1">${siteStatus(row.status)}
|
|
168
|
+
${row.exportRequested ? html`<a href=${`/dashboard/network/sites/${row.id}`} class="rounded-full bg-amber-500/10 px-2 py-0.5 text-xs font-medium text-amber-700 no-underline dark:text-amber-300">${__('Export requested')}</a>` : null}</div>` },
|
|
169
|
+
{ label: __('Created'), class: 'text-muted-foreground', cell: row => row.createdAt === null ? '—' : shortDate(row.createdAt) },
|
|
170
|
+
],
|
|
171
|
+
})}
|
|
172
|
+
${listFooter({ total: this.total, page: this.page, totalPages: this.pages, href: page => this.href({ page }) })}
|
|
173
|
+
${component(AlertDialog, {
|
|
174
|
+
id: 'delete-site-dialog',
|
|
175
|
+
open: this.pendingDelete !== null,
|
|
176
|
+
title: __('Delete site?'),
|
|
177
|
+
description: this.pendingDelete ? `${this.pendingDelete.name} ${__('stops answering at once. Its database and media are deleted for good after 30 days; until then it can be restored.')}` : '',
|
|
178
|
+
cancelLabel: __('Cancel'),
|
|
179
|
+
actionLabel: __('Delete'),
|
|
180
|
+
actionVariant: 'destructive',
|
|
181
|
+
onAction: () => this.confirmDelete(),
|
|
182
|
+
onOpenChange: () => { this.pendingDelete = null; },
|
|
183
|
+
})}
|
|
184
|
+
</div>`;
|
|
185
|
+
}
|
|
186
|
+
}
|