domma-cms 1.48.0 → 1.48.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.48.1] - 2026-11-09
|
|
4
|
+
|
|
5
|
+
- Move "Show side admin menu" from Versions to Notifications for every signed-in user, including users without notification permissions. Keep each account's saved sidebar choice and the site default for new users.
|
|
6
|
+
|
|
3
7
|
## [1.48.0] - 2026-11-09
|
|
4
8
|
|
|
5
9
|
- **Making and handing over API tokens.**
|
package/admin/js/app.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{wireNotificationMenu as Q}from"./lib/topbar-notifications.js";import{installSmoothCarets as X}from"./lib/smooth-caret.js";import{viewLoaders as Z}from"./views/index.js";import{createLazyViews as ee}from"./lib/lazy-views.js";import{withPluginChrome as _}from"./lib/plugin-chrome.js";import{api as r,getUser as x,isAuthenticated as m,logout as te,sendToLogin as ae}from"./api.js";import{claimDrafts as ie}from"./lib/draft-owner.js";import{isAuthScreen as C,loginHashFor as oe}from"./lib/login-arrange.js";import{installHttpInterceptor as se}from"./http-interceptor.js";import{installResizableSlideovers as ne}from"./lib/slideover-resizable.js";import{installActivityThrobber as re}from"./lib/activity-throbber.js";import{installUpdateNotice as le,renderCmsVersion as ce}from"./lib/update-notice.js";import{renderFrameworkVersions as W,wireAccountMenu as me}from"./lib/topbar-account.js";import{refreshTopbarProject as B}from"./lib/topbar-project.js";import{isPathAllowed as pe,redirectFor as de}from"./lib/admin-scope.js";import{deliverDesktop as ue,desktopActive as he,notificationSettings as we}from"./lib/desktop-notify.js";import{avatarUrl as ge,installAccountAvatar as fe}from"./lib/avatar.js";import{installCalculator as ve}from"./lib/calculator.js";import{takeOverviewPass as be,withDashboardStrip as H}from"./lib/dashboards-strip.js";import{installHotkeys as Se}from"./lib/hotkeys-ui.js";import{applyAdminBrand as K}from"./lib/admin-brand.js";import{installRouterCatchUp as Ce}from"./lib/router-catch-up.js";import{installSidebarDrawer as Me}from"./lib/sidebar-drawer.js";$(()=>{X(document),se(),ve(),le(),re(),ne(),Me(),(async()=>{const{applyAdminTheme:e,refreshAdminTheme:i}=await import("./lib/admin-theme.js");m()?await i(r,{init:!0}):e({dommaTheme:"charcoal-dark"},{init:!0})})();let p=null,h=null,c="/",w=!1,g=null;function D(e){if(N[e])return E.toast(`${N[e]} is switched off on this site.`,{type:"info"}),"/";const[i,t]=e.split("?"),a=new URLSearchParams(t||"").get("tab");if(i==="/settings"&&["favicon","pageNavigation","breadcrumbs","motion","search"].includes(a))return`/appearance?tab=${a}`;if(e.split("?")[0]==="/my-dashboard")return"/dashboards";const o=y[e]||de(p,e);return o||((e.split("?")[0]||"/")==="/"&&c&&c!=="/"&&!be()?y[c]||c:null)}const y={},N={};R.use(async(e,i,t)=>{if(C(e.path))return t();if(!m()){ae();return}const a=D(e.path);if(a){R.navigate(a);return}t()});async function f(){try{const e=await r.get("/auth/permissions");p=e.adminScope||null,h=e.adminBrand||null,K(h),c=e.adminHome||"/",W(e.versions);const i=e.permissions||[];return w=pe(p,"/settings")&&i.some(t=>t==="settings"||t.startsWith("settings.")),g=i.some(t=>t==="notifications"||t.startsWith("notifications.")),i}catch{return p=null,c="/",h||K(null),w=!1,g=null,[]}}document.addEventListener("dm:admin-home-changed",()=>{f()});let P=null,A=!1;document.addEventListener("dm:sidebar-rebuild",()=>{if(B(r),P){A=!0;return}P=(async()=>{do{A=!1;try{await j(await f())}catch{}}while(A)})().finally(()=>{P=null})});async function j(e){const{renderAdminSidebar:i}=await import("./lib/sidebar-renderer.js");await i({mount:"#admin-sidebar",permissions:e,adminScope:p,brand:h})}M.subscribe("router:afterChange",({to:e})=>{C(e.path)&&(u&&(clearInterval(u),u=null),p=null,c="/",w=!1,g=null)});const q=[{path:"/",view:"dashboard",title:"Dashboard - Domma CMS"},{path:"/dashboards",view:"dashboards",title:"Dashboards - Domma CMS"},{path:"/my-dashboard",view:"dashboards",title:"Dashboards - Domma CMS"},{path:"/pages",view:"pages",title:"Pages - Domma CMS"},{path:"/pages/new",view:"pageEditor",title:"New Page - Domma CMS"},{path:"/pages/edit/*",view:"pageEditor",title:"Edit Page - Domma CMS"},{path:"/media",view:"media",title:"Media - Domma CMS"},{path:"/menus",view:"menus",title:"Menus - Domma CMS"},{path:"/context-menus",view:"contextMenus",title:"Context Menus - Domma CMS"},{path:"/context-menus/new",view:"contextMenuEditor",title:"New Context Menu - Domma CMS"},{path:"/context-menus/edit/:slug",view:"contextMenuEditor",title:"Edit Context Menu - Domma CMS"},{path:"/launchers",view:"launchers",title:"Launchers - Domma CMS"},{path:"/menus/new",view:"menuEditor",title:"New Menu - Domma CMS"},{path:"/menus/edit/:slug",view:"menuEditor",title:"Edit Menu - Domma CMS"},{path:"/menu-locations",view:"menuLocations",title:"Menu Locations - Domma CMS"},{path:"/navigation",view:"menusRedirect",title:"Menus - Domma CMS"},{path:"/layouts",view:"layouts",title:"Layouts - Domma CMS"},{path:"/appearance",view:"appearance",title:"Appearance - Domma CMS"},{path:"/footer",view:"footer",title:"Footer - Domma CMS"},{path:"/settings",view:"settings",title:"Settings - Domma CMS"},{path:"/theme",view:"theme",title:"Theme - Domma CMS"},{path:"/users",view:"users",title:"Users - Domma CMS"},{path:"/users/new",view:"userEditor",title:"New User - Domma CMS"},{path:"/users/edit/:id",view:"userEditor",title:"Edit User - Domma CMS"},{path:"/plugins",view:"plugins",title:"Plugins - Domma CMS"},{path:"/plugins/code/:name",view:"pluginCode",title:"Plugin Code - Domma CMS"},{path:"/documentation",view:"documentation",title:"Usage - Domma CMS"},{path:"/tutorials",view:"tutorials",title:"Tutorials - Domma CMS"},{path:"/tutorials/crud",view:"tutorialCrud",title:"Building a CRUD App - Domma CMS"},{path:"/tutorials/editor",view:"tutorialEditor",title:"The Editor - Domma CMS"},{path:"/tutorials/plugin",view:"tutorialPlugin",title:"Writing a Tool - Domma CMS"},{path:"/tutorials/forms",view:"tutorialForms",title:"Form Follow-Up - Domma CMS"},{path:"/docs/components",view:"componentsReference",title:"Components Reference - Domma CMS"},{path:"/docs/components-howto",view:"componentsHowto",title:"Components How-To - Domma CMS"},{path:"/docs/components-walkthrough",view:"componentsWalkthrough",title:"Components Walkthrough - Domma CMS"},{path:"/docs/components-rules",view:"componentsRules",title:"Components Rules - Domma CMS"},{path:"/docs/usage/pages",view:"usagePages",title:"Pages - Usage - Domma CMS"},{path:"/docs/usage/media",view:"usageMedia",title:"Media - Usage - Domma CMS"},{path:"/docs/usage/navigation",view:"usageNavigation",title:"Navigation - Usage - Domma CMS"},{path:"/docs/usage/dconfig",view:"usageDconfig",title:"DConfig - Usage - Domma CMS"},{path:"/docs/usage/shortcodes",view:"usageShortcodes",title:"Shortcodes - Usage - Domma CMS"},{path:"/docs/usage/site-settings",view:"usageSiteSettings",title:"Site Settings - Usage - Domma CMS"},{path:"/docs/usage/plugins",view:"usagePlugins",title:"Plugins - Usage - Domma CMS"},{path:"/docs/usage/users-roles",view:"usageUsersRoles",title:"Users & Roles - Usage - Domma CMS"},{path:"/docs/usage/views",view:"usageViews",title:"Views - Usage - Domma CMS"},{path:"/docs/usage/actions",view:"usageActions",title:"Actions - Usage - Domma CMS"},{path:"/docs/usage/cta-shortcode",view:"usageCtaShortcode",title:"CTA Shortcode - Usage - Domma CMS"},{path:"/docs/usage/editions",view:"usageEditions",title:"Editions & Licences - Usage - Domma CMS"},{path:"/docs/usage/collections",view:"usageCollections",title:"Collections & Forms - Usage - Domma CMS"},{path:"/docs/usage/blocks",view:"usageBlocks",title:"Blocks - Usage - Domma CMS"},{path:"/docs/usage/tools",view:"usageTools",title:"Built-in Tools - Usage - Domma CMS"},{path:"/docs/usage/dashboard",view:"usageDashboard",title:"Dashboard - Usage - Domma CMS"},{path:"/docs/usage/search-engines",view:"usageSearchEngines",title:"Search Engines & AI - Usage - Domma CMS"},{path:"/docs/usage/launchers",view:"usageLaunchers",title:"Launchers - Usage - Domma CMS"},{path:"/docs/usage/chat",view:"usageChat",title:"Chat & Knowledge - Usage - Domma CMS"},{path:"/docs/plugins",view:"pluginGuides",title:"Plugin Guides - Domma CMS"},{path:"/docs/plugins/*",view:"pluginGuide",title:"Plugin Guide - Domma CMS"},{path:"/docs/api/authentication",view:"apiRefAuthentication",title:"Authentication - API - Domma CMS"},{path:"/docs/api/pages",view:"apiRefPages",title:"Pages - API - Domma CMS"},{path:"/docs/api/settings",view:"apiRefSettings",title:"Settings - API - Domma CMS"},{path:"/docs/api/layouts",view:"apiRefLayouts",title:"Layouts - API - Domma CMS"},{path:"/docs/api/navigation",view:"apiRefNavigation",title:"Navigation - API - Domma CMS"},{path:"/docs/api/media",view:"apiRefMedia",title:"Media - API - Domma CMS"},{path:"/docs/api/users",view:"apiRefUsers",title:"Users - API - Domma CMS"},{path:"/docs/api/plugins",view:"apiRefPlugins",title:"Plugins - API - Domma CMS"},{path:"/docs/api/collections",view:"apiRefCollections",title:"Collections - API - Domma CMS"},{path:"/docs/api/views",view:"apiRefViews",title:"Views API - Domma CMS"},{path:"/docs/api/actions",view:"apiRefActions",title:"Actions API - Domma CMS"},{path:"/docs/api/forms",view:"apiRefForms",title:"Forms API - Domma CMS"},{path:"/docs/api/scaffold",view:"apiRefScaffold",title:"Scaffold API - Domma CMS"},{path:"/docs/api/external",view:"apiRefExternal",title:"External API & Tokens - Domma CMS"},{path:"/docs/api/content",view:"apiRefContent",title:"Content API - Domma CMS"},{path:"/docs/api/builder",view:"apiRefBuilder",title:"API Builder - Domma CMS"},{path:"/api-reference",view:"apiReference",title:"API Reference - Domma CMS"},{path:"/collections",view:"collections",title:"Collections - Domma CMS"},{path:"/collections/new",view:"collectionEditor",title:"New Collection - Domma CMS"},{path:"/collections/edit/:slug",view:"collectionEditor",title:"Edit Collection - Domma CMS"},{path:"/collections/:slug/entries",view:"collectionEntries",title:"Entries - Domma CMS"},{path:"/forms",view:"forms",title:"Forms - Domma CMS"},{path:"/forms/new",view:"formEditor",title:"New Form - Domma CMS"},{path:"/forms/edit/:slug",view:"formEditor",title:"Edit Form - Domma CMS"},{path:"/forms/:slug/submissions",view:"formSubmissions",title:"Submissions - Domma CMS"},{path:"/views",view:"viewsList",title:"Views - Domma CMS"},{path:"/views/new",view:"viewEditor",title:"New View - Domma CMS"},{path:"/views/edit/:slug",view:"viewEditor",title:"Edit View - Domma CMS"},{path:"/views/:slug/preview",view:"viewPreview",title:"View Preview - Domma CMS"},{path:"/actions",view:"actionsList",title:"Actions - Domma CMS"},{path:"/actions/new",view:"actionEditor",title:"New Action - Domma CMS"},{path:"/actions/edit/:slug",view:"actionEditor",title:"Edit Action - Domma CMS"},{path:"/pro/docs",view:"proDocs",title:"Pro Documentation - Domma CMS"},{path:"/blocks",view:"blocks",title:"Blocks - Domma CMS"},{path:"/blocks/new",view:"pageEditor",title:"New Block - Domma CMS"},{path:"/blocks/edit/:name",view:"pageEditor",title:"Edit Block - Domma CMS"},{path:"/components",view:"components",title:"Components - Domma CMS"},{path:"/components/new",view:"pageEditor",title:"New Component - Domma CMS"},{path:"/components/edit/:name",view:"pageEditor",title:"Edit Component - Domma CMS"},{path:"/my-profile",view:"myProfile",title:"My Profile - Domma CMS"},{path:"/roles",view:"roles",title:"Roles & Permissions - Domma CMS"},{path:"/roles/edit/:id",view:"roleEditor",title:"Edit Role - Domma CMS"},{path:"/effects",view:"effects",title:"Effects - Domma CMS"},{path:"/search",view:"search",title:"Search - Domma CMS"},{path:"/content-api",view:"contentApi",title:"Content API - Domma CMS"},{path:"/launchers/chats",view:"chats",title:"Chats - Domma CMS"},{path:"/launchers/chats/:id",view:"chats",title:"Chats - Domma CMS"},{path:"/launchers/knowledge",view:"chatKnowledge",title:"Chat Knowledge - Domma CMS"},{path:"/notes",view:"notes",title:"Notes - Domma CMS"},{path:"/todo",view:"todo",title:"Todo - Domma CMS"},{path:"/calculator",view:"calculator",title:"Calculator - Domma CMS"},{path:"/analytics",view:"analytics",title:"Analytics - Domma CMS"},{path:"/seo",view:"seo",title:"SEO - Domma CMS"},{path:"/seo/:tab",view:"seo",title:"SEO - Domma CMS"},{path:"/wordpress-import",view:"wordpressImport",title:"Import a site - Domma CMS"},{path:"/contacts",view:"contacts",title:"Contacts - Domma CMS"},{path:"/calls/new",view:"callNew",title:"Call now - Domma CMS"},{path:"/system/notifications",view:"notifications",title:"Notifications - Domma CMS"},{path:"/api-tokens",view:"apiTokens",title:"API Tokens - Domma CMS"},{path:"/api-endpoints",view:"apiEndpoints",title:"API Builder - Domma CMS"},{path:"/api-endpoints/new",view:"apiEndpointEditor",title:"New API Endpoint - Domma CMS"},{path:"/api-endpoints/edit/:id",view:"apiEndpointEditor",title:"Edit API Endpoint - Domma CMS"},{path:"/projects",view:"projects",title:"Projects - Domma CMS"},{path:"/projects/new",view:"projects",title:"New Project - Domma CMS"},{path:"/projects/edit/:slug",view:"projects",title:"Edit Project - Domma CMS"},{path:"/projects/:slug/settings",view:"projectSettings",title:"Project settings - Domma CMS"},{path:"/projects/:slug/pages",view:"pages",title:"Project pages - Domma CMS"},{path:"/projects/:slug/collections",view:"collections",title:"Project collections - Domma CMS"},{path:"/projects/:slug/forms",view:"forms",title:"Project forms - Domma CMS"},{path:"/projects/:slug/actions",view:"actionsList",title:"Project actions - Domma CMS"},{path:"/projects/:slug/menus",view:"menus",title:"Project menus - Domma CMS"},{path:"/projects/:slug/blocks",view:"blocks",title:"Project blocks - Domma CMS"},{path:"/projects/:slug/components",view:"components",title:"Project components - Domma CMS"},{path:"/projects/:slug/views",view:"viewsList",title:"Project views - Domma CMS"},{path:"/projects/:slug/roles",view:"roles",title:"Project roles - Domma CMS"},{path:"/projects/:slug/users",view:"users",title:"Project users - Domma CMS"},{path:"/projects/:slug/apis",view:"apiEndpoints",title:"Project APIs - Domma CMS"},{path:"/projects/:slug",view:"projectDetail",title:"Project - Domma CMS"},{path:"/login",view:"login",title:"Sign in - Domma CMS",onEnter:()=>{$("#admin-sidebar").hide(),$("#admin-topbar").hide()}},{path:"/reset-password",view:"login",title:"Reset Password - Domma CMS",onEnter:()=>{$("#admin-sidebar").hide(),$("#admin-topbar").hide()}}];M.subscribe("router:afterChange",async({to:e,from:i})=>{if(!C(e.path)){if($("#admin-sidebar").show(),$("#admin-topbar").show(),C(i?.path)){$("#topbar-user-name").remove(),import("./lib/admin-theme.js").then(o=>o.refreshAdminTheme(r)),await T();const t=await f(),a=D(e.path);if(a&&R.navigate(a),j(t),we.read().signInToasts)try{const o=await r.system.notifications.list().catch(()=>[]),n=(Array.isArray(o)?o:[]).filter(s=>s.unread&&["warning","critical"].includes(s.data?.severity)).slice(0,3);for(const s of n){const l=d(s.data?.title||""),L=d((s.data?.body||"").slice(0,120));E.toast(`${l} - ${L}`,{type:s.data?.severity==="critical"?"error":"warning",duration:0})}}catch{}}V()}}),M.subscribe("router:afterChange",()=>{setTimeout(()=>{$(".btn-primary, .btn-danger").length&&Domma.effects.reveal(".btn-primary, .btn-danger",{animation:"fade",stagger:40,duration:300})},50)});const z=["#field-project","#menu-project","#collection-project","#endpoint-project","#action-project","#view-project","#block-project","#component-project","#role-project",'[name="project"]','[name="ownedByProject"]'];function G(e){return/^\/(pages|menus|context-menus|collections|forms|actions|views|blocks|components|users|roles|api-endpoints)\/(new|edit\/)/.test(e)}M.subscribe("router:afterChange",({to:e})=>{const i=e?String(e.path).split("?")[0]:"";if(!e||!G(i))return;const a=new URLSearchParams(location.hash.split("?")[1]||"").get("project");if(!a||!/\/new$/.test(i))return;let o=0;const n=60,s=1500,l=()=>{o+=n;for(const L of z){const b=document.querySelector(L);if(!b)continue;if(Array.from(b.options||[]).find(Y=>Y.value===a)){b.value=a,b.dispatchEvent(new Event("change",{bubbles:!0}));return}}o<s&&setTimeout(l,n)};setTimeout(l,n)});const F="cms_card_states",k=S.get(F)||{};M.subscribe("router:afterChange",()=>{setTimeout(()=>{$("#view-container .card-collapsible").each(function(){const e=$(this).find(".card-header h2, .card-header h3").first().text().trim();e&&k[e]==="collapsed"&&$(this).addClass("card-collapsed")})},200)}),$("#view-container").on("click",".card-collapsible .card-header",function(e){if($(e.target).closest("button, a").length)return;const i=$(this).closest(".card");i.toggleClass("card-collapsed");const t=$(this).find("h2, h3").first().text().trim();t&&(k[t]=i.hasClass("card-collapsed")?"collapsed":"open",S.set(F,k))}),Se(),document.addEventListener("keydown",e=>{if(!(e.ctrlKey||e.metaKey)||e.key!=="s"||window.location.hash.startsWith("#/login")||window.location.hash.startsWith("#/reset-password"))return;const i=document.querySelector("#view-container .view-header button.btn-primary");i&&(e.preventDefault(),i.click())});const v=ee(),O=v.views,J={notes:{displayName:"Notes",icon:"edit-3"},todo:{displayName:"Todo",icon:"check-square"},calculator:{displayName:"Calculator",icon:"calculator"},analytics:{displayName:"Analytics",icon:"chart-bar"},seo:{displayName:"SEO",icon:"search"},wordpressImport:{displayName:"Import a site",icon:"download"},contacts:{displayName:"Contacts",icon:"users"},projects:{displayName:"Projects",icon:"folder"},pages:{displayName:"Pages",icon:"file-text"},media:{displayName:"Media",icon:"image"},menus:{displayName:"Site menus",icon:"menu"},contextMenus:{displayName:"Context Menus",icon:"menu"},launchers:{displayName:"Launchers",icon:"rocket"},theme:{displayName:"Theme",icon:"droplet"},collections:{displayName:"Collections",icon:"database"},forms:{displayName:"Forms",icon:"layout"},viewsList:{displayName:"Views",icon:"eye"},actionsList:{displayName:"Actions",icon:"zap"},apiEndpoints:{displayName:"API Builder",icon:"code"},blocks:{displayName:"Blocks",icon:"box"},components:{displayName:"Components",icon:"component"},notifications:{displayName:"Notifications",icon:"bell"},roles:{displayName:"Roles",icon:"shield"},users:{displayName:"Users",icon:"users"},appearance:{displayName:"Appearance",icon:"layout"},footer:{displayName:"Footer",icon:"panel-bottom"},settings:{displayName:"Site Settings",icon:"settings"},effects:{displayName:"Effects",icon:"sparkles"},layouts:{displayName:"Layouts",icon:"layout"},plugins:{displayName:"Marketplace",icon:"store"},myProfile:{displayName:"My Profile",icon:"user"},apiTokens:{displayName:"API Tokens",icon:"key"},search:{displayName:"Search",icon:"search"},contentApi:{displayName:"Content API",icon:"file-text"},chats:{displayName:"Chats",icon:"message-circle"},dashboard:{displayName:"Dashboard",icon:"home"},dashboards:{displayName:"Dashboards",icon:"home"},pageEditor:{displayName:"Pages",section:"Edit",icon:"file-text"},menuEditor:{displayName:"Site menus",section:"Edit",icon:"menu"},menuLocations:{displayName:"Site menus",section:"Locations",icon:"map-pin"},contextMenuEditor:{displayName:"Context Menus",section:"Edit",icon:"menu"},collectionEditor:{displayName:"Collections",section:"Edit",icon:"database"},collectionEntries:{displayName:"Collections",section:"Entries",icon:"database"},formEditor:{displayName:"Forms",section:"Edit",icon:"layout"},formSubmissions:{displayName:"Forms",section:"Submissions",icon:"inbox"},viewEditor:{displayName:"Views",section:"Edit",icon:"eye"},viewPreview:{displayName:"Views",section:"Preview",icon:"eye"},actionEditor:{displayName:"Actions",section:"Edit",icon:"zap"},apiEndpointEditor:{displayName:"API Builder",section:"Edit",icon:"code"},roleEditor:{displayName:"Roles",section:"Edit",icon:"shield"},userEditor:{displayName:"Users",section:"Edit",icon:"users"},projectDetail:{displayName:"Projects",section:"Overview",icon:"folder"},projectSettings:{displayName:"Projects",section:"Settings",icon:"folder"},pluginCode:{displayName:"Marketplace",section:"Code",icon:"code"},chatKnowledge:{displayName:"Chats",section:"Knowledge",icon:"book-open"}};for(const[e,i]of Object.entries(Z))v.register(e,async()=>{let t=await i();const a=J[e];return a&&(t=_(t,{plugin:e,licence:"Built in",...a})),e==="dashboard"?H(t):t});R.use(async(e,i,t)=>{try{await v.load(e.view)}catch(a){console.error("[admin] Screen failed to load",a),O[e.view]={template:'<p role="alert">This screen could not load. Reload the page to try again.</p>'}}t()});const I=[...q];async function T(){if(m())try{const e=await r.plugins.adminConfig(),i=new Set(I.map(t=>t.path));for(const t of e.routes||[])i.has(t.path)||I.push(t);for(const[t,a]of Object.entries(e.views||{})){const o=(e.meta||{})[t];v.register(t,async()=>{const s=(await import(`/plugins/${a.entry}`))[a.exportName];if(!s)throw new Error(`Missing plugin screen: ${t}`);const l=_(s,o);return t==="dashboard"?H(l):l},JSON.stringify([a,o]))}for(const[t,{route:a}]of Object.entries(e.takeovers||{}))a&&(y[`/${t}`]=a);e.mediaPicker&&(globalThis[Symbol.for("domma.media-picker")]=e.mediaPicker);for(const[t,{enabled:a,displayName:o}]of Object.entries(e.tools||{}))a===!1&&(N[`/${t}`]=o);for(const{id:t,href:a}of e.css||[])if(!document.getElementById(t)){const o=document.createElement("link");o.id=t,o.rel="stylesheet",o.href=a,document.head.appendChild(o)}}catch{}}function V(){const e=x();if(!e)return;if($("#topbar-user-name").length){B(r);return}const t={"super-admin":"Super Admin",admin:"Admin",user:"User"}[e.role]||e.role,a=ge(e);$("#topbar-user").get(0).innerHTML=`
|
|
1
|
+
import{wireNotificationMenu as Q}from"./lib/topbar-notifications.js";import{installSmoothCarets as X}from"./lib/smooth-caret.js";import{viewLoaders as Z}from"./views/index.js";import{createLazyViews as ee}from"./lib/lazy-views.js";import{withPluginChrome as _}from"./lib/plugin-chrome.js";import{api as r,getUser as x,isAuthenticated as m,logout as te,sendToLogin as ae}from"./api.js";import{claimDrafts as ie}from"./lib/draft-owner.js";import{isAuthScreen as C,loginHashFor as oe}from"./lib/login-arrange.js";import{installHttpInterceptor as se}from"./http-interceptor.js";import{installResizableSlideovers as ne}from"./lib/slideover-resizable.js";import{installActivityThrobber as re}from"./lib/activity-throbber.js";import{installUpdateNotice as le,renderCmsVersion as ce}from"./lib/update-notice.js";import{renderFrameworkVersions as W,wireAccountMenu as me}from"./lib/topbar-account.js";import{refreshTopbarProject as B}from"./lib/topbar-project.js";import{isPathAllowed as pe,redirectFor as de}from"./lib/admin-scope.js";import{deliverDesktop as ue,desktopActive as he,notificationSettings as we}from"./lib/desktop-notify.js";import{avatarUrl as ge,installAccountAvatar as fe}from"./lib/avatar.js";import{installCalculator as ve}from"./lib/calculator.js";import{takeOverviewPass as be,withDashboardStrip as H}from"./lib/dashboards-strip.js";import{installHotkeys as Se}from"./lib/hotkeys-ui.js";import{applyAdminBrand as K}from"./lib/admin-brand.js";import{installRouterCatchUp as Ce}from"./lib/router-catch-up.js";import{installSidebarDrawer as Me}from"./lib/sidebar-drawer.js";$(()=>{X(document),se(),ve(),le(),re(),ne(),Me(),(async()=>{const{applyAdminTheme:e,refreshAdminTheme:i}=await import("./lib/admin-theme.js");m()?await i(r,{init:!0}):e({dommaTheme:"charcoal-dark"},{init:!0})})();let p=null,w=null,c="/",g=!1,u=null;function D(e){if(N[e])return E.toast(`${N[e]} is switched off on this site.`,{type:"info"}),"/";const[i,t]=e.split("?"),a=new URLSearchParams(t||"").get("tab");if(i==="/settings"&&["favicon","pageNavigation","breadcrumbs","motion","search"].includes(a))return`/appearance?tab=${a}`;if(e.split("?")[0]==="/my-dashboard")return"/dashboards";const o=y[e]||de(p,e);return o||((e.split("?")[0]||"/")==="/"&&c&&c!=="/"&&!be()?y[c]||c:null)}const y={},N={};R.use(async(e,i,t)=>{if(C(e.path))return t();if(!m()){ae();return}const a=D(e.path);if(a){R.navigate(a);return}t()});async function f(){try{const e=await r.get("/auth/permissions");p=e.adminScope||null,w=e.adminBrand||null,K(w),c=e.adminHome||"/",W(e.versions);const i=e.permissions||[];return g=pe(p,"/settings")&&i.some(t=>t==="settings"||t.startsWith("settings.")),u=i.some(t=>t==="notifications"||t.startsWith("notifications.")),i}catch{return p=null,c="/",w||K(null),g=!1,u=null,[]}}document.addEventListener("dm:admin-home-changed",()=>{f()});let P=null,A=!1;document.addEventListener("dm:sidebar-rebuild",()=>{if(B(r),P){A=!0;return}P=(async()=>{do{A=!1;try{await j(await f())}catch{}}while(A)})().finally(()=>{P=null})});async function j(e){const{renderAdminSidebar:i}=await import("./lib/sidebar-renderer.js");await i({mount:"#admin-sidebar",permissions:e,adminScope:p,brand:w})}M.subscribe("router:afterChange",({to:e})=>{C(e.path)&&(h&&(clearInterval(h),h=null),p=null,c="/",g=!1,u=null)});const q=[{path:"/",view:"dashboard",title:"Dashboard - Domma CMS"},{path:"/dashboards",view:"dashboards",title:"Dashboards - Domma CMS"},{path:"/my-dashboard",view:"dashboards",title:"Dashboards - Domma CMS"},{path:"/pages",view:"pages",title:"Pages - Domma CMS"},{path:"/pages/new",view:"pageEditor",title:"New Page - Domma CMS"},{path:"/pages/edit/*",view:"pageEditor",title:"Edit Page - Domma CMS"},{path:"/media",view:"media",title:"Media - Domma CMS"},{path:"/menus",view:"menus",title:"Menus - Domma CMS"},{path:"/context-menus",view:"contextMenus",title:"Context Menus - Domma CMS"},{path:"/context-menus/new",view:"contextMenuEditor",title:"New Context Menu - Domma CMS"},{path:"/context-menus/edit/:slug",view:"contextMenuEditor",title:"Edit Context Menu - Domma CMS"},{path:"/launchers",view:"launchers",title:"Launchers - Domma CMS"},{path:"/menus/new",view:"menuEditor",title:"New Menu - Domma CMS"},{path:"/menus/edit/:slug",view:"menuEditor",title:"Edit Menu - Domma CMS"},{path:"/menu-locations",view:"menuLocations",title:"Menu Locations - Domma CMS"},{path:"/navigation",view:"menusRedirect",title:"Menus - Domma CMS"},{path:"/layouts",view:"layouts",title:"Layouts - Domma CMS"},{path:"/appearance",view:"appearance",title:"Appearance - Domma CMS"},{path:"/footer",view:"footer",title:"Footer - Domma CMS"},{path:"/settings",view:"settings",title:"Settings - Domma CMS"},{path:"/theme",view:"theme",title:"Theme - Domma CMS"},{path:"/users",view:"users",title:"Users - Domma CMS"},{path:"/users/new",view:"userEditor",title:"New User - Domma CMS"},{path:"/users/edit/:id",view:"userEditor",title:"Edit User - Domma CMS"},{path:"/plugins",view:"plugins",title:"Plugins - Domma CMS"},{path:"/plugins/code/:name",view:"pluginCode",title:"Plugin Code - Domma CMS"},{path:"/documentation",view:"documentation",title:"Usage - Domma CMS"},{path:"/tutorials",view:"tutorials",title:"Tutorials - Domma CMS"},{path:"/tutorials/crud",view:"tutorialCrud",title:"Building a CRUD App - Domma CMS"},{path:"/tutorials/editor",view:"tutorialEditor",title:"The Editor - Domma CMS"},{path:"/tutorials/plugin",view:"tutorialPlugin",title:"Writing a Tool - Domma CMS"},{path:"/tutorials/forms",view:"tutorialForms",title:"Form Follow-Up - Domma CMS"},{path:"/docs/components",view:"componentsReference",title:"Components Reference - Domma CMS"},{path:"/docs/components-howto",view:"componentsHowto",title:"Components How-To - Domma CMS"},{path:"/docs/components-walkthrough",view:"componentsWalkthrough",title:"Components Walkthrough - Domma CMS"},{path:"/docs/components-rules",view:"componentsRules",title:"Components Rules - Domma CMS"},{path:"/docs/usage/pages",view:"usagePages",title:"Pages - Usage - Domma CMS"},{path:"/docs/usage/media",view:"usageMedia",title:"Media - Usage - Domma CMS"},{path:"/docs/usage/navigation",view:"usageNavigation",title:"Navigation - Usage - Domma CMS"},{path:"/docs/usage/dconfig",view:"usageDconfig",title:"DConfig - Usage - Domma CMS"},{path:"/docs/usage/shortcodes",view:"usageShortcodes",title:"Shortcodes - Usage - Domma CMS"},{path:"/docs/usage/site-settings",view:"usageSiteSettings",title:"Site Settings - Usage - Domma CMS"},{path:"/docs/usage/plugins",view:"usagePlugins",title:"Plugins - Usage - Domma CMS"},{path:"/docs/usage/users-roles",view:"usageUsersRoles",title:"Users & Roles - Usage - Domma CMS"},{path:"/docs/usage/views",view:"usageViews",title:"Views - Usage - Domma CMS"},{path:"/docs/usage/actions",view:"usageActions",title:"Actions - Usage - Domma CMS"},{path:"/docs/usage/cta-shortcode",view:"usageCtaShortcode",title:"CTA Shortcode - Usage - Domma CMS"},{path:"/docs/usage/editions",view:"usageEditions",title:"Editions & Licences - Usage - Domma CMS"},{path:"/docs/usage/collections",view:"usageCollections",title:"Collections & Forms - Usage - Domma CMS"},{path:"/docs/usage/blocks",view:"usageBlocks",title:"Blocks - Usage - Domma CMS"},{path:"/docs/usage/tools",view:"usageTools",title:"Built-in Tools - Usage - Domma CMS"},{path:"/docs/usage/dashboard",view:"usageDashboard",title:"Dashboard - Usage - Domma CMS"},{path:"/docs/usage/search-engines",view:"usageSearchEngines",title:"Search Engines & AI - Usage - Domma CMS"},{path:"/docs/usage/launchers",view:"usageLaunchers",title:"Launchers - Usage - Domma CMS"},{path:"/docs/usage/chat",view:"usageChat",title:"Chat & Knowledge - Usage - Domma CMS"},{path:"/docs/plugins",view:"pluginGuides",title:"Plugin Guides - Domma CMS"},{path:"/docs/plugins/*",view:"pluginGuide",title:"Plugin Guide - Domma CMS"},{path:"/docs/api/authentication",view:"apiRefAuthentication",title:"Authentication - API - Domma CMS"},{path:"/docs/api/pages",view:"apiRefPages",title:"Pages - API - Domma CMS"},{path:"/docs/api/settings",view:"apiRefSettings",title:"Settings - API - Domma CMS"},{path:"/docs/api/layouts",view:"apiRefLayouts",title:"Layouts - API - Domma CMS"},{path:"/docs/api/navigation",view:"apiRefNavigation",title:"Navigation - API - Domma CMS"},{path:"/docs/api/media",view:"apiRefMedia",title:"Media - API - Domma CMS"},{path:"/docs/api/users",view:"apiRefUsers",title:"Users - API - Domma CMS"},{path:"/docs/api/plugins",view:"apiRefPlugins",title:"Plugins - API - Domma CMS"},{path:"/docs/api/collections",view:"apiRefCollections",title:"Collections - API - Domma CMS"},{path:"/docs/api/views",view:"apiRefViews",title:"Views API - Domma CMS"},{path:"/docs/api/actions",view:"apiRefActions",title:"Actions API - Domma CMS"},{path:"/docs/api/forms",view:"apiRefForms",title:"Forms API - Domma CMS"},{path:"/docs/api/scaffold",view:"apiRefScaffold",title:"Scaffold API - Domma CMS"},{path:"/docs/api/external",view:"apiRefExternal",title:"External API & Tokens - Domma CMS"},{path:"/docs/api/content",view:"apiRefContent",title:"Content API - Domma CMS"},{path:"/docs/api/builder",view:"apiRefBuilder",title:"API Builder - Domma CMS"},{path:"/api-reference",view:"apiReference",title:"API Reference - Domma CMS"},{path:"/collections",view:"collections",title:"Collections - Domma CMS"},{path:"/collections/new",view:"collectionEditor",title:"New Collection - Domma CMS"},{path:"/collections/edit/:slug",view:"collectionEditor",title:"Edit Collection - Domma CMS"},{path:"/collections/:slug/entries",view:"collectionEntries",title:"Entries - Domma CMS"},{path:"/forms",view:"forms",title:"Forms - Domma CMS"},{path:"/forms/new",view:"formEditor",title:"New Form - Domma CMS"},{path:"/forms/edit/:slug",view:"formEditor",title:"Edit Form - Domma CMS"},{path:"/forms/:slug/submissions",view:"formSubmissions",title:"Submissions - Domma CMS"},{path:"/views",view:"viewsList",title:"Views - Domma CMS"},{path:"/views/new",view:"viewEditor",title:"New View - Domma CMS"},{path:"/views/edit/:slug",view:"viewEditor",title:"Edit View - Domma CMS"},{path:"/views/:slug/preview",view:"viewPreview",title:"View Preview - Domma CMS"},{path:"/actions",view:"actionsList",title:"Actions - Domma CMS"},{path:"/actions/new",view:"actionEditor",title:"New Action - Domma CMS"},{path:"/actions/edit/:slug",view:"actionEditor",title:"Edit Action - Domma CMS"},{path:"/pro/docs",view:"proDocs",title:"Pro Documentation - Domma CMS"},{path:"/blocks",view:"blocks",title:"Blocks - Domma CMS"},{path:"/blocks/new",view:"pageEditor",title:"New Block - Domma CMS"},{path:"/blocks/edit/:name",view:"pageEditor",title:"Edit Block - Domma CMS"},{path:"/components",view:"components",title:"Components - Domma CMS"},{path:"/components/new",view:"pageEditor",title:"New Component - Domma CMS"},{path:"/components/edit/:name",view:"pageEditor",title:"Edit Component - Domma CMS"},{path:"/my-profile",view:"myProfile",title:"My Profile - Domma CMS"},{path:"/roles",view:"roles",title:"Roles & Permissions - Domma CMS"},{path:"/roles/edit/:id",view:"roleEditor",title:"Edit Role - Domma CMS"},{path:"/effects",view:"effects",title:"Effects - Domma CMS"},{path:"/search",view:"search",title:"Search - Domma CMS"},{path:"/content-api",view:"contentApi",title:"Content API - Domma CMS"},{path:"/launchers/chats",view:"chats",title:"Chats - Domma CMS"},{path:"/launchers/chats/:id",view:"chats",title:"Chats - Domma CMS"},{path:"/launchers/knowledge",view:"chatKnowledge",title:"Chat Knowledge - Domma CMS"},{path:"/notes",view:"notes",title:"Notes - Domma CMS"},{path:"/todo",view:"todo",title:"Todo - Domma CMS"},{path:"/calculator",view:"calculator",title:"Calculator - Domma CMS"},{path:"/analytics",view:"analytics",title:"Analytics - Domma CMS"},{path:"/seo",view:"seo",title:"SEO - Domma CMS"},{path:"/seo/:tab",view:"seo",title:"SEO - Domma CMS"},{path:"/wordpress-import",view:"wordpressImport",title:"Import a site - Domma CMS"},{path:"/contacts",view:"contacts",title:"Contacts - Domma CMS"},{path:"/calls/new",view:"callNew",title:"Call now - Domma CMS"},{path:"/system/notifications",view:"notifications",title:"Notifications - Domma CMS"},{path:"/api-tokens",view:"apiTokens",title:"API Tokens - Domma CMS"},{path:"/api-endpoints",view:"apiEndpoints",title:"API Builder - Domma CMS"},{path:"/api-endpoints/new",view:"apiEndpointEditor",title:"New API Endpoint - Domma CMS"},{path:"/api-endpoints/edit/:id",view:"apiEndpointEditor",title:"Edit API Endpoint - Domma CMS"},{path:"/projects",view:"projects",title:"Projects - Domma CMS"},{path:"/projects/new",view:"projects",title:"New Project - Domma CMS"},{path:"/projects/edit/:slug",view:"projects",title:"Edit Project - Domma CMS"},{path:"/projects/:slug/settings",view:"projectSettings",title:"Project settings - Domma CMS"},{path:"/projects/:slug/pages",view:"pages",title:"Project pages - Domma CMS"},{path:"/projects/:slug/collections",view:"collections",title:"Project collections - Domma CMS"},{path:"/projects/:slug/forms",view:"forms",title:"Project forms - Domma CMS"},{path:"/projects/:slug/actions",view:"actionsList",title:"Project actions - Domma CMS"},{path:"/projects/:slug/menus",view:"menus",title:"Project menus - Domma CMS"},{path:"/projects/:slug/blocks",view:"blocks",title:"Project blocks - Domma CMS"},{path:"/projects/:slug/components",view:"components",title:"Project components - Domma CMS"},{path:"/projects/:slug/views",view:"viewsList",title:"Project views - Domma CMS"},{path:"/projects/:slug/roles",view:"roles",title:"Project roles - Domma CMS"},{path:"/projects/:slug/users",view:"users",title:"Project users - Domma CMS"},{path:"/projects/:slug/apis",view:"apiEndpoints",title:"Project APIs - Domma CMS"},{path:"/projects/:slug",view:"projectDetail",title:"Project - Domma CMS"},{path:"/login",view:"login",title:"Sign in - Domma CMS",onEnter:()=>{$("#admin-sidebar").hide(),$("#admin-topbar").hide()}},{path:"/reset-password",view:"login",title:"Reset Password - Domma CMS",onEnter:()=>{$("#admin-sidebar").hide(),$("#admin-topbar").hide()}}];M.subscribe("router:afterChange",async({to:e,from:i})=>{if(!C(e.path)){if($("#admin-sidebar").show(),$("#admin-topbar").show(),C(i?.path)){$("#topbar-user-name").remove(),import("./lib/admin-theme.js").then(o=>o.refreshAdminTheme(r)),await T();const t=await f(),a=D(e.path);if(a&&R.navigate(a),j(t),we.read().signInToasts)try{const o=await r.system.notifications.list().catch(()=>[]),n=(Array.isArray(o)?o:[]).filter(s=>s.unread&&["warning","critical"].includes(s.data?.severity)).slice(0,3);for(const s of n){const l=d(s.data?.title||""),L=d((s.data?.body||"").slice(0,120));E.toast(`${l} - ${L}`,{type:s.data?.severity==="critical"?"error":"warning",duration:0})}}catch{}}V()}}),M.subscribe("router:afterChange",()=>{setTimeout(()=>{$(".btn-primary, .btn-danger").length&&Domma.effects.reveal(".btn-primary, .btn-danger",{animation:"fade",stagger:40,duration:300})},50)});const z=["#field-project","#menu-project","#collection-project","#endpoint-project","#action-project","#view-project","#block-project","#component-project","#role-project",'[name="project"]','[name="ownedByProject"]'];function G(e){return/^\/(pages|menus|context-menus|collections|forms|actions|views|blocks|components|users|roles|api-endpoints)\/(new|edit\/)/.test(e)}M.subscribe("router:afterChange",({to:e})=>{const i=e?String(e.path).split("?")[0]:"";if(!e||!G(i))return;const a=new URLSearchParams(location.hash.split("?")[1]||"").get("project");if(!a||!/\/new$/.test(i))return;let o=0;const n=60,s=1500,l=()=>{o+=n;for(const L of z){const b=document.querySelector(L);if(!b)continue;if(Array.from(b.options||[]).find(Y=>Y.value===a)){b.value=a,b.dispatchEvent(new Event("change",{bubbles:!0}));return}}o<s&&setTimeout(l,n)};setTimeout(l,n)});const F="cms_card_states",k=S.get(F)||{};M.subscribe("router:afterChange",()=>{setTimeout(()=>{$("#view-container .card-collapsible").each(function(){const e=$(this).find(".card-header h2, .card-header h3").first().text().trim();e&&k[e]==="collapsed"&&$(this).addClass("card-collapsed")})},200)}),$("#view-container").on("click",".card-collapsible .card-header",function(e){if($(e.target).closest("button, a").length)return;const i=$(this).closest(".card");i.toggleClass("card-collapsed");const t=$(this).find("h2, h3").first().text().trim();t&&(k[t]=i.hasClass("card-collapsed")?"collapsed":"open",S.set(F,k))}),Se(),document.addEventListener("keydown",e=>{if(!(e.ctrlKey||e.metaKey)||e.key!=="s"||window.location.hash.startsWith("#/login")||window.location.hash.startsWith("#/reset-password"))return;const i=document.querySelector("#view-container .view-header button.btn-primary");i&&(e.preventDefault(),i.click())});const v=ee(),O=v.views,J={notes:{displayName:"Notes",icon:"edit-3"},todo:{displayName:"Todo",icon:"check-square"},calculator:{displayName:"Calculator",icon:"calculator"},analytics:{displayName:"Analytics",icon:"chart-bar"},seo:{displayName:"SEO",icon:"search"},wordpressImport:{displayName:"Import a site",icon:"download"},contacts:{displayName:"Contacts",icon:"users"},projects:{displayName:"Projects",icon:"folder"},pages:{displayName:"Pages",icon:"file-text"},media:{displayName:"Media",icon:"image"},menus:{displayName:"Site menus",icon:"menu"},contextMenus:{displayName:"Context Menus",icon:"menu"},launchers:{displayName:"Launchers",icon:"rocket"},theme:{displayName:"Theme",icon:"droplet"},collections:{displayName:"Collections",icon:"database"},forms:{displayName:"Forms",icon:"layout"},viewsList:{displayName:"Views",icon:"eye"},actionsList:{displayName:"Actions",icon:"zap"},apiEndpoints:{displayName:"API Builder",icon:"code"},blocks:{displayName:"Blocks",icon:"box"},components:{displayName:"Components",icon:"component"},notifications:{displayName:"Notifications",icon:"bell"},roles:{displayName:"Roles",icon:"shield"},users:{displayName:"Users",icon:"users"},appearance:{displayName:"Appearance",icon:"layout"},footer:{displayName:"Footer",icon:"panel-bottom"},settings:{displayName:"Site Settings",icon:"settings"},effects:{displayName:"Effects",icon:"sparkles"},layouts:{displayName:"Layouts",icon:"layout"},plugins:{displayName:"Marketplace",icon:"store"},myProfile:{displayName:"My Profile",icon:"user"},apiTokens:{displayName:"API Tokens",icon:"key"},search:{displayName:"Search",icon:"search"},contentApi:{displayName:"Content API",icon:"file-text"},chats:{displayName:"Chats",icon:"message-circle"},dashboard:{displayName:"Dashboard",icon:"home"},dashboards:{displayName:"Dashboards",icon:"home"},pageEditor:{displayName:"Pages",section:"Edit",icon:"file-text"},menuEditor:{displayName:"Site menus",section:"Edit",icon:"menu"},menuLocations:{displayName:"Site menus",section:"Locations",icon:"map-pin"},contextMenuEditor:{displayName:"Context Menus",section:"Edit",icon:"menu"},collectionEditor:{displayName:"Collections",section:"Edit",icon:"database"},collectionEntries:{displayName:"Collections",section:"Entries",icon:"database"},formEditor:{displayName:"Forms",section:"Edit",icon:"layout"},formSubmissions:{displayName:"Forms",section:"Submissions",icon:"inbox"},viewEditor:{displayName:"Views",section:"Edit",icon:"eye"},viewPreview:{displayName:"Views",section:"Preview",icon:"eye"},actionEditor:{displayName:"Actions",section:"Edit",icon:"zap"},apiEndpointEditor:{displayName:"API Builder",section:"Edit",icon:"code"},roleEditor:{displayName:"Roles",section:"Edit",icon:"shield"},userEditor:{displayName:"Users",section:"Edit",icon:"users"},projectDetail:{displayName:"Projects",section:"Overview",icon:"folder"},projectSettings:{displayName:"Projects",section:"Settings",icon:"folder"},pluginCode:{displayName:"Marketplace",section:"Code",icon:"code"},chatKnowledge:{displayName:"Chats",section:"Knowledge",icon:"book-open"}};for(const[e,i]of Object.entries(Z))v.register(e,async()=>{let t=await i();const a=J[e];return a&&(t=_(t,{plugin:e,licence:"Built in",...a})),e==="dashboard"?H(t):t});R.use(async(e,i,t)=>{try{await v.load(e.view)}catch(a){console.error("[admin] Screen failed to load",a),O[e.view]={template:'<p role="alert">This screen could not load. Reload the page to try again.</p>'}}t()});const I=[...q];async function T(){if(m())try{const e=await r.plugins.adminConfig(),i=new Set(I.map(t=>t.path));for(const t of e.routes||[])i.has(t.path)||I.push(t);for(const[t,a]of Object.entries(e.views||{})){const o=(e.meta||{})[t];v.register(t,async()=>{const s=(await import(`/plugins/${a.entry}`))[a.exportName];if(!s)throw new Error(`Missing plugin screen: ${t}`);const l=_(s,o);return t==="dashboard"?H(l):l},JSON.stringify([a,o]))}for(const[t,{route:a}]of Object.entries(e.takeovers||{}))a&&(y[`/${t}`]=a);e.mediaPicker&&(globalThis[Symbol.for("domma.media-picker")]=e.mediaPicker);for(const[t,{enabled:a,displayName:o}]of Object.entries(e.tools||{}))a===!1&&(N[`/${t}`]=o);for(const{id:t,href:a}of e.css||[])if(!document.getElementById(t)){const o=document.createElement("link");o.id=t,o.rel="stylesheet",o.href=a,document.head.appendChild(o)}}catch{}}function V(){const e=x();if(!e)return;if($("#topbar-user-name").length){B(r);return}const t={"super-admin":"Super Admin",admin:"Admin",user:"User"}[e.role]||e.role,a=ge(e);$("#topbar-user").get(0).innerHTML=`
|
|
2
2
|
<a id="topbar-project" class="topbar-action-link topbar-project" hidden>
|
|
3
3
|
<span data-icon="folder"></span>
|
|
4
4
|
<span id="topbar-project-name" class="topbar-project-name"></span>
|
|
5
5
|
</a>
|
|
6
6
|
<div id="topbar-versions-menu" class="topbar-account">
|
|
7
|
-
<button type="button" class="topbar-action-link" aria-label="Versions
|
|
7
|
+
<button type="button" class="topbar-action-link" aria-label="Versions" aria-expanded="false" aria-controls="topbar-versions-panel">
|
|
8
8
|
<span data-icon="layers"></span><span class="topbar-action-label">Versions</span><span data-icon="chevron-down"></span>
|
|
9
9
|
</button>
|
|
10
10
|
<div id="topbar-versions-panel" class="topbar-account-menu topbar-versions-panel" hidden>
|
|
@@ -13,18 +13,19 @@ import{wireNotificationMenu as Q}from"./lib/topbar-notifications.js";import{inst
|
|
|
13
13
|
<span class="topbar-version-item" hidden>Domma JS <span id="topbar-js-version" class="topbar-version-badge"></span></span>
|
|
14
14
|
<span class="topbar-version-item" hidden>Domma CMS <span id="topbar-cms-version" class="topbar-version-badge"></span></span>
|
|
15
15
|
</div>
|
|
16
|
-
<label class="topbar-sidebar-choice"><input type="checkbox" id="topbar-show-sidebar"> Show side admin menu</label>
|
|
17
16
|
</div>
|
|
18
17
|
</div>
|
|
19
18
|
`,$("#topbar-actions").get(0).innerHTML=`
|
|
20
19
|
<div id="topbar-notifications" class="topbar-account">
|
|
21
|
-
<button type="button" id="topbar-bell" class="topbar-action-link" aria-label="Notifications" aria-expanded="false" aria-controls="topbar-notifications-menu"
|
|
20
|
+
<button type="button" id="topbar-bell" class="topbar-action-link" aria-label="Notifications" aria-expanded="false" aria-controls="topbar-notifications-menu">
|
|
22
21
|
<span data-icon="bell"></span>
|
|
23
22
|
<span class="topbar-action-label">Notifications</span>
|
|
24
23
|
<span id="topbar-bell-badge" class="topbar-bell-badge" hidden></span>
|
|
25
24
|
<span data-icon="chevron-down"></span>
|
|
26
25
|
</button>
|
|
27
|
-
<div id="topbar-notifications-menu" class="topbar-account-menu topbar-notifications-menu" aria-label="Notifications" hidden
|
|
26
|
+
<div id="topbar-notifications-menu" class="topbar-account-menu topbar-notifications-menu" aria-label="Notifications" hidden>
|
|
27
|
+
<label class="topbar-sidebar-choice"><input type="checkbox" id="topbar-show-sidebar"> Show side admin menu</label>
|
|
28
|
+
</div>
|
|
28
29
|
</div>
|
|
29
30
|
<div id="topbar-account" class="topbar-account">
|
|
30
31
|
<button type="button" class="topbar-action-link" aria-label="Account menu" aria-expanded="false" aria-controls="topbar-account-menu">
|
|
@@ -50,4 +51,4 @@ import{wireNotificationMenu as Q}from"./lib/topbar-notifications.js";import{inst
|
|
|
50
51
|
</a>
|
|
51
52
|
</div>
|
|
52
53
|
</div>
|
|
53
|
-
`;const o=$("#topbar-
|
|
54
|
+
`;const o=$("#topbar-settings").get(0);o&&(o.hidden=!g),$("#topbar-logout-btn").on("click",n=>{n.preventDefault(),te()}),Domma.icons.scan("#admin-topbar"),E.tooltip("#topbar-actions [data-tooltip]",{placement:"bottom"}),me(e),Q({refreshBadge:U,canRead:()=>u!==!1}),fe(e),W(),ce(),B(r),U(),h||(h=setInterval(U,6e4))}function d(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}let h=null;async function U(){if(!(!m()||u===!1))try{const{count:e}=await r.system.notifications.unreadCount(),i=$("#topbar-bell-badge");e>0?i.text(e>99?"99+":String(e)).removeAttr("hidden"):i.attr("hidden","").text(""),e>0&&he()&&ue(await r.system.notifications.list().catch(()=>[]))}catch{}}(async()=>{if(!m()&&!window.location.hash.startsWith("#/reset-password"))window.location.hash.startsWith("#/login")||(window.location.hash=oe(window.location.hash));else{ie(x()?.id);const a=x(),[o]=await Promise.all([a?f():Promise.resolve([]),T()]);if(a){const n=(window.location.hash||"#/").slice(1)||"/",s=D(n);s&&(window.location.hash=`#${s}`),j(o).catch(l=>console.error("[admin] Sidebar failed to load",l)),V()}}const e=R._extractParams.bind(R);R._extractParams=function(a,o){const n=o.indexOf("?");if(n!==-1&&(o=o.slice(0,n)),a.endsWith("/*")){const s=a.slice(0,-2);return o.startsWith(s+"/")?{}:null}return e(a,o)};const i=R._renderNotFound.bind(R);let t="";R._renderNotFound=async function(a){return m()&&t!==a&&(t=a,await T(),R._matchRoute(a).route)?(t="",R._handleRouteChange()):(t="",m()&&$("#admin-sidebar").get(0)?.style.display==="none"?(E.toast("That link goes nowhere - here is your home page.",{type:"warning"}),R.navigate("/")):i(a))},Ce(R),R.init({container:"#view-container",routes:I,views:O,default:"/",transitions:{enter:"fadeIn",leave:"fadeOut",duration:150}})})()});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{api as
|
|
2
|
-
${
|
|
1
|
+
import{api as S,apiRequest as C}from"../api.js";import{sidebarCount as L}from"./tool-kit.js";import{severityOf as q}from"./notifications-arrange.js";import{wireNotificationCacheMenu as D}from"./topbar-cache.js";const x=[["critical","Critical","alert-circle","danger"],["warning","Warnings","alert-triangle","warn"],["info","Information","info","info"],["success","Success","check-circle","ok"]];export function notificationGroups(y=[]){return x.map(([m,i,d,l])=>{const e=y.filter(r=>q(r)===m);return{type:m,label:i,icon:d,tone:l,total:e.length,unread:e.filter(r=>r.unread).length}})}let h;export function wireNotificationMenu({refreshBadge:y,canRead:m=()=>!0}){h?.abort(),h=new AbortController;const{signal:i}=h,d=document.getElementById("topbar-notifications");if(!d)return;const l=d.querySelector("#topbar-bell"),e=d.querySelector("#topbar-notifications-menu"),r=document.createElement("div");r.dataset.notificationItems="";const w=e.querySelector(".topbar-sidebar-choice");e.replaceChildren(r,...w?[w]:[]),D();let p=0,f=!1;const u=()=>{p++,e.hidden=!0,l.setAttribute("aria-expanded","false")},b=t=>{const n=document.createElement("p");n.className="nt-menu-status",n.setAttribute("role","status"),n.textContent=t,r.replaceChildren(n)},A=t=>{const n=r.contains(document.activeElement)?document.activeElement:null,o=n?.dataset.dismiss,s=n?.getAttribute("href"),c=n?.hasAttribute("data-read-all"),$=notificationGroups(t);r.innerHTML=`<div class="nt-menu-heading" aria-live="polite">Notifications <span>${$.reduce((a,k)=>a+k.unread,0)} unread</span></div>
|
|
2
|
+
${$.map(a=>`<div class="nt-menu-row">
|
|
3
3
|
<a class="nt-menu-type" href="#/system/notifications?type=${a.type}">
|
|
4
4
|
<span class="nt-menu-icon is-${a.tone}"><span data-icon="${a.icon}"></span></span>
|
|
5
5
|
<span>${a.label}<small>${a.unread} unread / ${a.total} total</small></span>
|
|
6
6
|
</a>
|
|
7
|
-
<button type="button" class="nt-menu-dismiss" data-dismiss="${a.type}" data-count="${a.total}" aria-label="Dismiss ${a.total} ${a.label.toLowerCase()} notifications" ${!a.total||
|
|
7
|
+
<button type="button" class="nt-menu-dismiss" data-dismiss="${a.type}" data-count="${a.total}" aria-label="Dismiss ${a.total} ${a.label.toLowerCase()} notifications" ${!a.total||f?"disabled":""}>Dismiss</button>
|
|
8
8
|
</div>`).join("")}
|
|
9
9
|
${t.length?"":`<p class="nt-menu-status">No notifications - you're all caught up.</p>`}
|
|
10
10
|
<div class="nt-menu-footer"><a href="#/system/notifications?type=all">View all notifications</a>
|
|
11
|
-
<button type="button" data-read-all ${
|
|
11
|
+
<button type="button" data-read-all ${f||!t.some(a=>a.unread)?"disabled":""}>Mark all as read</button></div>`,Domma.icons.scan(e),o?(e.querySelector(`[data-dismiss="${o}"]:not(:disabled)`)||e.querySelector(`a[href$="type=${o}"]`))?.focus():s?[...e.querySelectorAll("a")].find(a=>a.getAttribute("href")===s)?.focus():c&&(e.querySelector("[data-read-all]:not(:disabled)")||e.querySelector(".nt-menu-footer a"))?.focus()},v=async()=>{if(!m()){b("Notifications are unavailable for this account.");return}const t=++p;try{const n=await S.system.notifications.list();if(i.aborted||t!==p||e.hidden)return;A(Array.isArray(n)?n:[])}catch{!i.aborted&&t===p&&!e.hidden&&b("Could not load notifications. Close and reopen to try again.")}},g=async t=>{document.dispatchEvent(new CustomEvent("dm:topbar-menu-open",{detail:{owner:d}})),e.hidden=!1,l.setAttribute("aria-expanded","true"),b("Loading notifications..."),await v(),t&&!e.hidden&&e.querySelector("a, input:not(:disabled), button:not(:disabled)")?.focus()};l.addEventListener("click",()=>e.hidden?g(!1):u(),{signal:i}),l.addEventListener("keydown",t=>{t.key==="ArrowDown"&&(t.preventDefault(),g(!0))},{signal:i}),e.addEventListener("click",async t=>{const n=t.target.closest("a");if(n){const c=new URLSearchParams(n.hash.split("?")[1]||"").get("type");document.dispatchEvent(new CustomEvent("dm:notifications-filter",{detail:{type:c}})),u();return}const o=t.target.closest("button");if(!o||o.disabled||f||!o.hasAttribute("data-dismiss")&&!o.hasAttribute("data-read-all"))return;const s=o.dataset.dismiss;f=!0;try{if(s==="critical"&&!await E.confirm(`Dismiss all ${o.dataset.count} critical notifications? They are hidden for you only.`))return;r.querySelectorAll("button").forEach(c=>{c.disabled=!0}),await C(`/system/notifications/${s?"dismiss-all":"read-all"}`,{method:"POST",...s?{body:JSON.stringify({severity:s})}:{}}),document.dispatchEvent(new CustomEvent("dm:notifications-changed")),L("#/system/notifications"),await y()}catch(c){E.toast(`Could not update notifications: ${c.message||c}`,{type:"error"})}finally{f=!1,!i.aborted&&!e.hidden&&await v()}},{signal:i}),e.addEventListener("keydown",t=>{const n=[...e.querySelectorAll("a, input:not(:disabled), button:not(:disabled)")].filter(c=>!c.closest("[hidden]")),o=n.indexOf(document.activeElement);if(o<0)return;let s;t.key==="ArrowDown"&&(s=(o+1)%n.length),t.key==="ArrowUp"&&(s=(o-1+n.length)%n.length),t.key==="Home"&&(s=0),t.key==="End"&&(s=n.length-1),s!==void 0&&(t.preventDefault(),n[s].focus())},{signal:i}),document.addEventListener("click",t=>{d.contains(t.target)||u()},{signal:i}),document.addEventListener("focusin",t=>{d.contains(t.target)||u()},{signal:i}),document.addEventListener("dm:topbar-menu-open",t=>{t.detail.owner!==d&&u()},{signal:i}),document.addEventListener("keydown",t=>{!t.defaultPrevented&&t.key==="Escape"&&!e.hidden&&(u(),l.focus(),t.preventDefault())},{signal:i}),window.addEventListener("hashchange",u,{signal:i})}
|
|
Binary file
|