@nocobase/portal-template-default 1.0.16 → 1.0.17

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.
Files changed (150) hide show
  1. package/AGENTS.md +8 -0
  2. package/README.MD +4 -0
  3. package/dist/assets/{LineDraw-vPRTWiQ5.js → LineDraw-BBB5hwuJ.js} +1 -1
  4. package/dist/assets/{SymbolDraw-DOl_Tss3.js → SymbolDraw-CKS3uUb_.js} +1 -1
  5. package/dist/assets/{VisualMapping-j08W3KBm.js → VisualMapping-BCwaW3TD.js} +1 -1
  6. package/dist/assets/auth-method-demo-BdCCvEEz.js +1 -0
  7. package/dist/assets/{auto-login-provider-Bukw7zEe.js → auto-login-provider-DO5Il6Dp.js} +2 -2
  8. package/dist/assets/auto-login-provider-TQ08B6-i.js +1 -0
  9. package/dist/assets/auto-redirect-provider-ButXp0A3.js +1 -0
  10. package/dist/assets/auto-redirect-provider-DnGGP2Vn.js +1 -0
  11. package/dist/assets/auto-redirect-provider-ja-vFPaF.js +1 -0
  12. package/dist/assets/calendar-C7xnRgOT.js +1 -0
  13. package/dist/assets/{cas-sign-in-button-BQn3Mttx.js → cas-sign-in-button-BZCa4lR6.js} +1 -1
  14. package/dist/assets/{components-BT5mL9gW.js → components-_g-GjQeV.js} +3 -3
  15. package/dist/assets/{configuration-gate-BJoadoA6.js → configuration-gate-B4XVz7tS.js} +1 -1
  16. package/dist/assets/{createClipPathFromCoordSys-m8IbnJ1z.js → createClipPathFromCoordSys-z9Kmh-tu.js} +1 -1
  17. package/dist/assets/createSeriesDataSimply-CPqysF0K.js +1 -0
  18. package/dist/assets/{customGraphicKeyframeAnimation-CYLPurwK.js → customGraphicKeyframeAnimation-DMU5crAu.js} +1 -1
  19. package/dist/assets/demo-BPlae2bp.js +1 -0
  20. package/dist/assets/demo-Bj_Y0RrW.js +1 -0
  21. package/dist/assets/demo-CKPAQOib.js +1 -0
  22. package/dist/assets/demo-CXRTPvIx.js +1 -0
  23. package/dist/assets/demo-DJuVDu1n.js +1 -0
  24. package/dist/assets/demo-DUmWU7ik.js +1 -0
  25. package/dist/assets/demo-NhIzFRE1.js +1 -0
  26. package/dist/assets/{dingtalk-sign-in-button-DSluFaP9.js → dingtalk-sign-in-button-DMPgE5kT.js} +1 -1
  27. package/dist/assets/{echarts-preview-mRXoEciY.js → echarts-preview-R96Pbqmz.js} +1 -1
  28. package/dist/assets/{echarts-runtime-CvLr4Slh.js → echarts-runtime-Ce_z2eX_.js} +3 -3
  29. package/dist/assets/{echarts-runtime-advanced-BC1tvfQ0.js → echarts-runtime-advanced-Dr80KHJR.js} +1 -1
  30. package/dist/assets/{echarts-runtime-common-DhNaV5B8.js → echarts-runtime-common-DB95Yfc1.js} +1 -1
  31. package/dist/assets/{echarts-runtime-components-BiioS8t1.js → echarts-runtime-components-DCJEaTJk.js} +1 -1
  32. package/dist/assets/{echarts-runtime-hierarchy-CAWqYvFh.js → echarts-runtime-hierarchy-CezgZs9O.js} +1 -1
  33. package/dist/assets/{floating-RVbHvIiD.js → floating-O9WmiDXk.js} +2 -2
  34. package/dist/assets/index-BBKV6O5d.css +1 -0
  35. package/dist/assets/{index-Dw20Lzpp.js → index-CPzehPGe.js} +3 -3
  36. package/dist/assets/index-Cc6awvdg.js +1064 -0
  37. package/dist/assets/index-ChA0z9ke.js +38 -0
  38. package/dist/assets/{index-BysibBZu.js → index-DgB7uTMs.js} +2 -2
  39. package/dist/assets/{index-C-tdHirk.js → index-DroUAK80.js} +1 -1
  40. package/dist/assets/index-WKvygTBp.js +59 -0
  41. package/dist/assets/{labelHelper-DbITmOUW.js → labelHelper-Dk5jkiD-.js} +1 -1
  42. package/dist/assets/ldap-sign-in-form-CKN4l7qM.js +1 -0
  43. package/dist/assets/{oidc-sign-in-button-Cgpa8Qzj.js → oidc-sign-in-button-BIRonrpC.js} +1 -1
  44. package/dist/assets/{page-context-AU6RU0Qi.js → page-context-DAiW_dId.js} +4 -4
  45. package/dist/assets/prompt-card-rGZqpqkF.js +1 -0
  46. package/dist/assets/prompt-output-B4h3uLWf.js +1 -0
  47. package/dist/assets/saml-sign-in-button-B4ugaLIb.js +1 -0
  48. package/dist/assets/{sectorHelper-C6L782Ue.js → sectorHelper-BuxrrJrA.js} +1 -1
  49. package/dist/assets/shortcut-BhKXxJLs.js +47 -0
  50. package/dist/assets/{sms-sign-in-form-Bo2WLZuP.js → sms-sign-in-form-DKpxRDdZ.js} +1 -1
  51. package/dist/assets/{static.browser-CoPxsICt.js → static.browser-kzzpH0Xt.js} +1 -1
  52. package/dist/assets/switch-BdVxPIVU.js +1 -0
  53. package/dist/assets/{tool-cards-ipgJ_3Ec.js → tool-cards-CpczIke-.js} +3 -3
  54. package/dist/assets/{use-authenticator-sign-in-BzFeh7qe.js → use-authenticator-sign-in-CIj210ry.js} +1 -1
  55. package/dist/assets/use-dingtalk-sign-in-BW4kkXD3.js +1 -0
  56. package/dist/assets/{use-wecom-sign-in-PPIMLvGa.js → use-wecom-sign-in-dIqMtcN9.js} +1 -1
  57. package/dist/assets/{wecom-sign-in-button-rUq9RW8R.js → wecom-sign-in-button-Dn_2zDab.js} +1 -1
  58. package/dist/index.html +2 -2
  59. package/dist/index.raw.html +2 -2
  60. package/package.json +9 -1
  61. package/src/App.tsx +5 -2
  62. package/src/app/extension.ts +2 -0
  63. package/src/app/extensions.tsx +18 -6
  64. package/src/app/route-access-guard.tsx +22 -0
  65. package/src/app/route-runtime.ts +173 -0
  66. package/src/app/routes.tsx +2 -2
  67. package/src/components/app-shell/header.tsx +56 -1
  68. package/src/components/app-shell/sidebar.tsx +14 -2
  69. package/src/extensions/nocobase-acl/README.md +28 -14
  70. package/src/extensions/nocobase-acl/demo/index.tsx +87 -15
  71. package/src/extensions/nocobase-acl/demo/prompt-generator.tsx +1 -0
  72. package/src/extensions/nocobase-mail/README.md +74 -0
  73. package/src/extensions/nocobase-mail/components/index.ts +79 -0
  74. package/src/extensions/nocobase-mail/components/mail-api.ts +423 -0
  75. package/src/extensions/nocobase-mail/components/mail-attachment-list.tsx +67 -0
  76. package/src/extensions/nocobase-mail/components/mail-compose-attachments.tsx +166 -0
  77. package/src/extensions/nocobase-mail/components/mail-compose.tsx +1071 -0
  78. package/src/extensions/nocobase-mail/components/mail-detail.tsx +653 -0
  79. package/src/extensions/nocobase-mail/components/mail-draft-autosave.ts +26 -0
  80. package/src/extensions/nocobase-mail/components/mail-empty.tsx +48 -0
  81. package/src/extensions/nocobase-mail/components/mail-filters.tsx +277 -0
  82. package/src/extensions/nocobase-mail/components/mail-inbox.tsx +544 -0
  83. package/src/extensions/nocobase-mail/components/mail-inline-images.ts +69 -0
  84. package/src/extensions/nocobase-mail/components/mail-label-badge.tsx +25 -0
  85. package/src/extensions/nocobase-mail/components/mail-label-manager.tsx +271 -0
  86. package/src/extensions/nocobase-mail/components/mail-labels-editor.tsx +267 -0
  87. package/src/extensions/nocobase-mail/components/mail-mass-tracking.tsx +271 -0
  88. package/src/extensions/nocobase-mail/components/mail-note-editor.tsx +99 -0
  89. package/src/extensions/nocobase-mail/components/mail-recipient-input.tsx +260 -0
  90. package/src/extensions/nocobase-mail/components/mail-reply-quote.ts +28 -0
  91. package/src/extensions/nocobase-mail/components/mail-rich-editor.tsx +287 -0
  92. package/src/extensions/nocobase-mail/components/mail-send-actions.tsx +238 -0
  93. package/src/extensions/nocobase-mail/components/mail-senders.ts +61 -0
  94. package/src/extensions/nocobase-mail/components/mail-settings-drawer.tsx +708 -0
  95. package/src/extensions/nocobase-mail/components/mail-showcase-layout.tsx +64 -0
  96. package/src/extensions/nocobase-mail/components/mail-signature-manager.tsx +258 -0
  97. package/src/extensions/nocobase-mail/components/mail-signatures.ts +25 -0
  98. package/src/extensions/nocobase-mail/components/mail-table.tsx +476 -0
  99. package/src/extensions/nocobase-mail/components/mail-template-manager.tsx +204 -0
  100. package/src/extensions/nocobase-mail/components/mail-toolbar.tsx +155 -0
  101. package/src/extensions/nocobase-mail/components/mail-unread.tsx +111 -0
  102. package/src/extensions/nocobase-mail/components/types.ts +297 -0
  103. package/src/extensions/nocobase-mail/components/use-mail-compose.tsx +262 -0
  104. package/src/extensions/nocobase-mail/components/use-mail-mass-messages.ts +54 -0
  105. package/src/extensions/nocobase-mail/components/use-mail-messages.ts +113 -0
  106. package/src/extensions/nocobase-mail/components/use-mail-signatures.ts +122 -0
  107. package/src/extensions/nocobase-mail/components/use-mail-templates.ts +54 -0
  108. package/src/extensions/nocobase-mail/extension.tsx +105 -0
  109. package/src/extensions/nocobase-mail/index.ts +1 -0
  110. package/src/extensions/nocobase-mail/mail-demo-pages.tsx +503 -0
  111. package/src/extensions/nocobase-mail/mail-pages.tsx +201 -0
  112. package/src/extensions/nocobase-mail/tests/mail-quote-html-regression.mjs +51 -0
  113. package/src/extensions/nocobase-mail/tests/mail-regression.mjs +649 -0
  114. package/src/extensions/nocobase-users-example/app-routes.tsx +121 -0
  115. package/src/extensions/nocobase-users-example/extension.tsx +2 -100
  116. package/src/extensions/nocobase-users-example/index.ts +1 -0
  117. package/src/lib/nocobase/acl/menu.ts +17 -3
  118. package/src/lib/nocobase/acl/types.ts +4 -0
  119. package/src/locales/en-US.ts +2 -1
  120. package/src/locales/zh-CN.ts +2 -1
  121. package/src/providers/runtime-config.ts +18 -0
  122. package/src/routes.tsx +10 -0
  123. package/src/vite-env.d.ts +3 -0
  124. package/vite.config.ts +8 -0
  125. package/dist/assets/auth-method-demo-B2qcpY8z.js +0 -1
  126. package/dist/assets/auto-login-provider-BMtzvdxG.js +0 -1
  127. package/dist/assets/auto-redirect-provider-C6GNPg5r.js +0 -1
  128. package/dist/assets/auto-redirect-provider-D5c6kN2R.js +0 -1
  129. package/dist/assets/auto-redirect-provider-iTzGEDpU.js +0 -1
  130. package/dist/assets/calendar-Dv2RNnsr.js +0 -1
  131. package/dist/assets/card-C9Hpeq1c.js +0 -1
  132. package/dist/assets/createSeriesDataSimply-DKUV5b5e.js +0 -1
  133. package/dist/assets/demo-BWGOwqtJ.js +0 -1
  134. package/dist/assets/demo-BWbcvkya.js +0 -1
  135. package/dist/assets/demo-DIASSPgn.js +0 -1
  136. package/dist/assets/demo-DuZ6asUU.js +0 -1
  137. package/dist/assets/demo-Dxcy4bDE.js +0 -1
  138. package/dist/assets/demo-YpEC76uw.js +0 -1
  139. package/dist/assets/demo-wzkoR8T2.js +0 -1
  140. package/dist/assets/index-CBZbj45X.js +0 -58
  141. package/dist/assets/index-CgkdZ6Oc.js +0 -686
  142. package/dist/assets/index-NH3aqqQz.css +0 -1
  143. package/dist/assets/index-hSBzW-VA.js +0 -43
  144. package/dist/assets/ldap-sign-in-form-BOMNDTkK.js +0 -1
  145. package/dist/assets/prompt-card-FWugRgi-.js +0 -1
  146. package/dist/assets/prompt-output-DMTuTNab.js +0 -1
  147. package/dist/assets/saml-sign-in-button-qt8bMeoQ.js +0 -1
  148. package/dist/assets/shortcut-Bu7jT_-w.js +0 -47
  149. package/dist/assets/switch-DQkkIE7G.js +0 -1
  150. package/dist/assets/use-dingtalk-sign-in-mrq6K5Yx.js +0 -1
@@ -1 +0,0 @@
1
- import{j as t}from"./index-CgkdZ6Oc.js";import{A as o}from"./auth-method-demo-B2qcpY8z.js";import e from"./ldap-sign-in-form-BOMNDTkK.js";import"./card-C9Hpeq1c.js";import"./use-authenticator-sign-in-BzFeh7qe.js";const r={name:"company-ldap",authType:"LDAP",title:"Company directory",options:{autoSignup:!0}};function s(){return t.jsx(o,{authType:"LDAP",methodName:"LDAP directory",description:"Use the familiar account and password form while sending credentials through the selected LDAP authenticator.",children:t.jsx(e,{authenticator:r,onSignIn:()=>{}})})}export{s as LdapAuthDemoPage};
@@ -1 +0,0 @@
1
- import{j as t}from"./index-CgkdZ6Oc.js";import{A as i}from"./auth-method-demo-B2qcpY8z.js";import n from"./dingtalk-sign-in-button-DSluFaP9.js";import"./card-C9Hpeq1c.js";import"./use-dingtalk-sign-in-mrq6K5Yx.js";const o={name:"company-dingtalk",authType:"dingtalk",title:"Sign in via DingTalk"};function p(){return t.jsx(i,{authType:"dingtalk",methodName:"DingTalk",description:"Provide DingTalk OAuth login and support internal micro-app automatic login through DingTalk JSAPI.",children:t.jsx(n,{authenticator:o,onSignIn:()=>{}})})}export{p as DingtalkAuthDemoPage};
@@ -1 +0,0 @@
1
- import{j as e}from"./index-CgkdZ6Oc.js";import{A as o}from"./auth-method-demo-B2qcpY8z.js";import i from"./sms-sign-in-form-Bo2WLZuP.js";import"./card-C9Hpeq1c.js";import"./use-authenticator-sign-in-BzFeh7qe.js";const n={name:"company-sms",authType:"SMS",title:"SMS verification code",options:{autoSignup:!0,verifier:"login-sms"}};function p(){return e.jsx(o,{authType:"SMS",methodName:"SMS verification code",description:"Collect a phone number and one-time code while keeping delivery and sign-in bound to the configured verifier.",children:e.jsx(i,{authenticator:n,onSendCode:()=>{},onSignIn:()=>{}})})}export{p as SmsAuthDemoPage};
@@ -1,58 +0,0 @@
1
- import{t as U,v as T,j as e,A as G,b as A,w as X,l as Y,m as Z,n as B,o as w,p as ee,q as v,x as se,C as te,k as D,I as k,T as re,B as W,y as ie,z as c,U as q,D as u,P as ne,E as ae,F as oe,G as le}from"./index-CgkdZ6Oc.js";import{C as m,a as h,b as p,c as P,d as x}from"./card-C9Hpeq1c.js";import{P as de}from"./prompt-output-DMTuTNab.js";/**
2
- * @license lucide-react v0.487.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const ce=[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]],L=U("layout-panel-top",ce);/**
7
- * @license lucide-react v0.487.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const me=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],V=U("lock-keyhole",me);/**
12
- * @license lucide-react v0.487.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const ue=[["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}]],he=U("user-round-cog",ue),O=s=>({resource:s.resource,action:s.action,id:s.id,field:s.field,dataSourceKey:s.dataSourceKey});function pe({children:s,anyOf:t,allOf:r,roles:i,fallback:a=e.jsx(G,{})}){const n=T(),o=!(t!=null&&t.length)||t.some(g=>n(O(g))),f=!(r!=null&&r.length)||r.every(g=>n(O(g)));return n({roles:i})&&o&&f?s:a}function z({children:s,resource:t,action:r,id:i,dataSourceKey:a,fallback:n="hidden"}){return T()({resource:t,action:r,id:i,dataSourceKey:a})?s:n==="hidden"?null:n==="forbidden"?e.jsx(G,{className:"min-h-40"}):n}function C({children:s,resource:t,action:r,field:i,dataSourceKey:a,fallback:n=null}){return T()({resource:t,action:r,field:i,dataSourceKey:a})?s:n}function d({children:s,roles:t,permissions:r={},recordPermissions:i=[]}){const a=A.useMemo(()=>{const n=Array.from(new Set(Object.keys(r).map(l=>l.slice(0,l.lastIndexOf(":"))))),o={status:"ready",permissions:{currentRole:t.length>1?"__union__":t[0],roles:t,roleMode:t.length>1?"allow-use-union":"default",resources:n,actions:r,actionAlias:{list:"list",get:"get",create:"create",update:"update",destroy:"destroy"},snippets:[]}},f=new Map(i.map(l=>[`${l.dataSourceKey??"main"}:${l.resource}:${l.action}:${l.id}`,l.allowed]));return{getState:()=>o,subscribe:()=>()=>{},load:async()=>o,retry:async()=>o,clear:()=>{},recordPermissions:{getState:()=>f,subscribe:()=>()=>{},getPermission:({dataSourceKey:l="main",resource:g,action:J,id:Q})=>f.get(`${l}:${g}:${J}:${Q}`)}}},[r,i,t]);return e.jsx(X,{store:a,children:s})}const xe=[["roles","RoleConstraint","undefined","Checks the current effective roles with anyOf, allOf, and noneOf."],["resource / action","string","undefined","Checks a NocoBase resource action. When roles are also present, both checks must pass."],["id / field","BaseKey / string","undefined","Optionally narrows the decision to one record or field."],["fallback","ReactNode","null","Renders when the access request is denied."]],fe=[["anyOf","AclPermission[]","undefined","Allows the page when any listed permission is available."],["allOf","AclPermission[]","undefined","Requires every listed permission before rendering the page."],["roles","RoleConstraint","undefined","Requires the current effective roles to match anyOf, allOf, and noneOf constraints."],["fallback","ReactNode","AccessDenied","Replaces the complete page when its permission test fails."],["children","ReactNode","required","The protected page content."]],ge=[["resource","string","required","NocoBase collection or ACL resource name."],["action","string","required","Resource action such as list, show, create, edit, or delete."],["id","BaseKey","undefined","Optional record ID for record-scoped permission checks."],["dataSourceKey","string","undefined","Selects a non-main NocoBase data source."],["fallback",'"hidden" | "forbidden" | ReactNode','"hidden"',"Hides the region or replaces it with a local denied state."],["children","ReactNode","required","The protected page region."]],je=[["resource","string","required","NocoBase collection containing the field."],["action","string","required","The action whose field whitelist should be checked."],["field","string","required","Exact NocoBase field name."],["dataSourceKey","string","undefined","Selects a non-main NocoBase data source."],["fallback","ReactNode","null","Optional read-only replacement for a denied field."],["children","ReactNode","required","The protected field or field group."]],be=[["AclStoreProvider","{ store, children }","required","Connects React ACL hooks and components to the application aclStore. The Starter mounts it at the application root."],["useGetRoles","() => QueryResult<string[]>","-","Returns the current effective ACL role names, including all participating roles in union mode."]];function ye(){return e.jsxs("section",{className:"space-y-5 border-t pt-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Permission boundaries"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:"Components behind the patterns"}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:"Use the smallest boundary that matches the intended user experience: complete page, independent region, or individual field."})]}),e.jsxs("div",{className:"space-y-7",children:[e.jsx(j,{title:"CanAccess",description:"The Starter access boundary for role-only, resource-only, or combined permission checks.",rows:xe}),e.jsx(j,{title:"AclPage",description:"Protects a complete route or business page. This corresponds to the Page permission pattern above.",rows:fe}),e.jsx(j,{title:"AclRegion",description:"Protects one independent area inside a larger page. This corresponds to the Region permission pattern.",rows:ge}),e.jsx(j,{title:"AclField",description:"Protects one field or field group. This corresponds to the Field permission pattern.",rows:je}),e.jsx(j,{title:"ACL context APIs",description:"Read the active role context from the application ACL store. Demo previews use an isolated in-memory store with the same evaluator.",rows:be})]})]})}function j({title:s,description:t,rows:r}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:s}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t})]}),e.jsx(m,{className:"gap-0 overflow-hidden py-0",children:e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(B,{children:[e.jsx(w,{children:"Prop"}),e.jsx(w,{children:"Type"}),e.jsx(w,{children:"Default"}),e.jsx(w,{children:"Description"})]})}),e.jsx(ee,{children:r.map(([i,a,n,o])=>e.jsxs(B,{children:[e.jsx(v,{className:"font-mono text-xs font-medium",children:i}),e.jsx(v,{className:"font-mono text-xs text-muted-foreground",children:a}),e.jsx(v,{className:"font-mono text-xs text-muted-foreground",children:n}),e.jsx(v,{className:"min-w-72 whitespace-normal text-muted-foreground",children:o})]},i))})]})})]})}function we({config:s}){const[t,r]=A.useState(s.defaultScene),[i,a]=A.useState(s.defaultTarget),n=A.useMemo(()=>`Build a complete NocoBase ACL scene in the NocoBase Admin Starter.
17
-
18
- Business scene
19
- - Page or feature: ${t}
20
- - Permission target: ${i}
21
- - Use realistic fixed sample content so the permission behavior is visible immediately.
22
- - Build the complete page section and user flow, not an isolated ACL snippet.
23
-
24
- ACL scenario
25
- ${s.requirements}
26
-
27
- Implementation contract
28
- - Use the Starter's built-in NocoBase accessControlProvider and ACL store.
29
- - NocoBase roles:check is the source of truth. Do not create a second permission store. Use configured role names only when the requirement explicitly includes a role constraint.
30
- - Import the Starter CanAccess from @/components/access-control/can-access. Use it with AclPage, AclRegion, and AclField for permission presentation. Do not copy their checks into local booleans or role comparisons.
31
- - Use useGetRoles only when UI needs to display or pass through the current effective ACL roles; it is not a replacement permission evaluator.
32
- - Keep backend ACL enforcement in place; frontend checks only control presentation and navigation.
33
- - Import reusable components from the installed local entry point at @/extensions/nocobase-acl when page composition is needed.
34
- - Resource actions use the application names list, show, create, edit, and delete. Let the Starter map them to NocoBase list/get/create/update/destroy.
35
- - Preserve dataSourceKey when the collection belongs to a non-main data source.
36
- - Show an understandable forbidden or hidden state where appropriate.
37
- - Deliver complete React component code, resource metadata, route integration, and the visible sample UI.`,[s.requirements,t,i]);return e.jsxs("details",{className:"group rounded-xl border bg-muted/15",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium marker:hidden",children:[e.jsx(se,{className:"size-4 text-primary"}),"Prompt generator",e.jsx("span",{className:"ml-auto text-xs font-normal text-muted-foreground",children:s.title}),e.jsx(te,{className:"size-4 text-muted-foreground transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"grid items-start gap-5 border-t p-4 xl:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs(m,{className:"gap-0 py-0",children:[e.jsxs(h,{className:"border-b py-4",children:[e.jsx(p,{className:"text-base",children:"Scenario settings"}),e.jsx(P,{children:s.description})]}),e.jsxs(x,{className:"space-y-5 py-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:`${s.title}-scene`,children:"Business scene"}),e.jsx(k,{id:`${s.title}-scene`,value:t,onChange:o=>r(o.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:`${s.title}-target`,children:"Permission target"}),e.jsx(re,{id:`${s.title}-target`,value:i,onChange:o=>a(o.target.value),className:"min-h-24"})]})]})]}),e.jsx(de,{description:"Updates as you change the business scene and permission target.",prompt:n})]})]})}function b({eyebrow:s,title:t,description:r,children:i,prompt:a}){return e.jsxs("section",{className:"space-y-5 border-t pt-8",children:[e.jsxs("div",{children:[e.jsx(W,{variant:"outline",children:s}),e.jsx("h2",{className:"mt-3 text-2xl font-semibold tracking-[-0.025em]",children:t}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-muted-foreground",children:r})]}),i,e.jsx(we,{config:a})]})}const R=[{id:1,name:"Alex Johnson",username:"alex",email:"alex@example.com",phone:"+1 202 555 0148",role:"Administrator"},{id:2,name:"Jamie Chen",username:"jamie",email:"jamie@example.com",phone:"+1 202 555 0186",role:"Member"},{id:3,name:"Morgan Lee",username:"morgan",email:"morgan@example.com",phone:"+1 202 555 0162",role:"Member"}],$={anyOf:["admin"]},ve={"users:list":{},"departments:list":{}},Ne={"users:list":{}},Ae={"users:get":{},"users:create":{},"users:update":{},"users:destroy":{}},ke={"users:get":{},"users:update":{},"users:destroy":{}},Pe=R.flatMap(s=>[{resource:"users",action:"update",id:s.id,allowed:!1},{resource:"users",action:"destroy",id:s.id,allowed:!1}]),Re={"users:update":{fields:["nickname","email","phone"]}},Ce={"users:update":{fields:["nickname"]}};function qe(){return e.jsxs("div",{className:"space-y-10 pb-12",children:[e.jsxs("header",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-[-0.025em] sm:text-3xl",children:"Permission patterns"}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:"Compare the authorized and restricted outcomes of navigation, pages, regions, record actions, and form fields using the same fixed data."})]}),e.jsx(b,{eyebrow:"Navigation permission",title:"Role-restricted routes disappear from navigation",description:"A route outside the current effective role is removed from the sidebar and its direct URL is guarded. Other accessible navigation remains unchanged.",prompt:{title:"Resource navigation",description:"Generate application resources, sidebar behavior, and guarded routes backed by NocoBase collections.",defaultScene:"User and role administration",defaultTarget:"Allow administrators to open Users, but remove it from navigation and block its direct URL for other roles.",requirements:`- Put role constraints on the route resource through meta.acl.roles using anyOf, allOf, or noneOf.
38
- - Use meta.acl.type = "authenticated" when the route itself is role-controlled and its inner regions perform collection checks.
39
- - Let the Starter filter inaccessible sidebar items and choose the first accessible default route.
40
- - Wrap list, create, show, and edit routes with the Starter CanAccess and provide an AccessDenied fallback.
41
- - Mark non-collection utility pages as authenticated, snippet, route, or acl: false instead of treating them as collections.
42
- - If a parent route is denied but an accessible child remains, navigation must continue to the child route.`},children:e.jsx(y,{allowedTitle:"Users permission granted",deniedTitle:"Users permission denied",allowed:e.jsx(d,{roles:["admin"],children:e.jsx(E,{})}),denied:e.jsx(d,{roles:["member"],children:e.jsx(E,{})})})}),e.jsx(b,{eyebrow:"Page permission",title:"A complete page is either available or replaced",description:"Page-level permission is useful when the whole route has one business purpose. Denial produces an understandable destination instead of a blank screen.",prompt:{title:"Page permission",description:"Generate a complete page whose availability depends on NocoBase permissions.",defaultScene:"User directory and account administration page",defaultTarget:"Allow administrators and user managers to render the complete page.",requirements:`- Wrap the complete business page with AclPage.
43
- - Use the AclPage roles prop with anyOf, allOf, or noneOf for page-level role access.
44
- - Keep anyOf and allOf for resource permissions when the page also needs collection access.
45
- - Provide a useful page-level fallback instead of rendering an empty screen.
46
- - Keep each inner data region independently protected when the page combines multiple collections.`},children:e.jsx(y,{allowedTitle:"Page allowed",deniedTitle:"Page denied",allowed:e.jsx(d,{roles:["user-manager"],children:e.jsx(F,{})}),denied:e.jsx(d,{roles:["member"],children:e.jsx(F,{})})})}),e.jsx(b,{eyebrow:"Region permission",title:"Only the protected region changes",description:"On a page with multiple resources, denying Departments hides only that panel and must not affect the Users table.",prompt:{title:"Region permission",description:"Generate a multi-resource page where each region follows its own collection ACL.",defaultScene:"Organization management dashboard",defaultTarget:"Keep Users visible while hiding the denied Departments panel.",requirements:`- Keep the outer page visible when its page-level permission is satisfied.
47
- - Wrap every collection-backed panel in its own AclRegion.
48
- - Enable each data query only when the corresponding list permission is allowed.
49
- - Use fallback="hidden" so denied regions do not reveal unavailable resources or placeholders.
50
- - Never use permission for one collection to hide unrelated tables or controls.`},children:e.jsx(y,{allowedTitle:"Both regions allowed",deniedTitle:"Departments resource hidden",allowed:e.jsx(d,{roles:["member"],permissions:ve,children:e.jsx(I,{})}),denied:e.jsx(d,{roles:["member"],permissions:Ne,children:e.jsx(I,{})})})}),e.jsx(b,{eyebrow:"Action and record permission",title:"Only unavailable actions are removed",description:"Collection permission controls global actions such as Create. Record ACL metadata controls Edit and Delete for each individual row.",prompt:{title:"Action permission",description:"Generate a data table whose toolbar and row actions respond to collection and record scopes.",defaultScene:"User administration table",defaultTarget:"Allow all actions for one user record and show a view-only row when update and delete are denied.",requirements:`- Use the Starter dataProvider so X-With-ACL-Meta captures NocoBase allowedActions from list, get, and getMany responses.
51
- - Use the built-in Create, Show, Edit, and Delete buttons; do not manually compare user IDs or role names.
52
- - Collection-level denial hides the action everywhere.
53
- - Record-level allowedActions must hide or disable only the affected row action.
54
- - Keep 403 responses authenticated and let NocoBase perform the final action validation.`},children:e.jsx(y,{allowedTitle:"Create and row actions allowed",deniedTitle:"Create, Update, and Delete denied",allowed:e.jsx(d,{roles:["admin"],permissions:Ae,children:e.jsx(K,{})}),denied:e.jsx(d,{roles:["viewer"],permissions:ke,recordPermissions:Pe,children:e.jsx(K,{})})})}),e.jsx(b,{eyebrow:"Field permission",title:"A form can mix editable, read-only, and hidden fields",description:"Field ACL does not have to hide the complete form. Only protected inputs change, while permitted fields remain usable.",prompt:{title:"Field permission",description:"Generate a form or detail page whose individual fields follow NocoBase field ACL.",defaultScene:"User profile edit form",defaultTarget:"Allow nickname editing, make email read-only, and hide phone when those fields are denied.",requirements:`- Wrap each protected field or field group with AclField.
55
- - Pass the collection resource, application action, and exact field name.
56
- - Choose whether a denied field is hidden, replaced by read-only output, or shown with a custom fallback.
57
- - Do not infer field access from the overall edit permission.
58
- - Submit only values the current UI is allowed to edit; NocoBase still performs final field validation.`},children:e.jsx(y,{allowedTitle:"All fields editable",deniedTitle:"Email read-only and phone hidden",allowed:e.jsx(d,{roles:["admin"],permissions:Re,children:e.jsx(M,{})}),denied:e.jsx(d,{roles:["member"],permissions:Ce,children:e.jsx(M,{})})})}),e.jsx(ye,{})]})}function y({allowedTitle:s,deniedTitle:t,allowed:r,denied:i}){return e.jsxs("div",{className:"grid items-start gap-5 xl:grid-cols-2",children:[e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-emerald-700 dark:text-emerald-400",children:[e.jsx(ie,{className:"size-4"}),s]}),r]}),e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-amber-700 dark:text-amber-400",children:[e.jsx(V,{className:"size-4"}),t]}),i]})]})}function E(){return e.jsxs("div",{className:"grid min-h-48 grid-cols-[150px_minmax(0,1fr)] overflow-hidden rounded-xl border bg-background",children:[e.jsxs("aside",{className:"border-r bg-muted/35 p-3",children:[e.jsx("div",{className:"mb-3 text-xs font-semibold text-muted-foreground",children:"Workspace"}),e.jsx(S,{icon:e.jsx(L,{}),label:"Dashboard"}),e.jsx(c,{roles:$,children:e.jsx(S,{icon:e.jsx(q,{}),label:"Users",active:!0})}),e.jsx(S,{icon:e.jsx(he,{}),label:"Roles"})]}),e.jsx("div",{className:"flex items-center justify-center p-5 text-center",children:e.jsx(c,{roles:$,fallback:e.jsxs("div",{children:[e.jsx(L,{className:"mx-auto size-7 text-muted-foreground"}),e.jsx("div",{className:"mt-2 font-medium",children:"Dashboard"}),e.jsx("div",{className:"mt-1 max-w-48 text-xs text-muted-foreground",children:"Users is absent from navigation and its direct route is guarded."})]}),children:e.jsxs("div",{children:[e.jsx(q,{className:"mx-auto size-7 text-primary"}),e.jsx("div",{className:"mt-2 font-medium",children:"Users"}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Route is available"})]})})})]})}function S({icon:s,label:t,active:r=!1}){return e.jsxs("div",{className:`mb-1 flex items-center gap-2 rounded-md px-2 py-2 text-xs ${r?"bg-primary text-primary-foreground":"text-muted-foreground"}`,children:[e.jsx("span",{className:"[&_svg]:size-3.5",children:s}),t]})}function F(){return e.jsx(pe,{roles:{anyOf:["admin","user-manager"]},fallback:e.jsx(Ue,{}),children:e.jsx(Se,{})})}function Se(){return e.jsxs(m,{children:[e.jsxs(h,{children:[e.jsx(p,{children:"User directory"}),e.jsx(P,{children:"3 users"})]}),e.jsx(x,{children:e.jsx(H,{})})]})}function Ue(){return e.jsx("div",{className:"flex min-h-64 items-center justify-center rounded-xl border border-dashed bg-background p-6 text-center",children:e.jsxs("div",{children:[e.jsx(V,{className:"mx-auto size-8 text-muted-foreground"}),e.jsx("div",{className:"mt-3 font-medium",children:"You cannot open this page"}),e.jsx("p",{className:"mx-auto mt-1 max-w-xs text-sm text-muted-foreground",children:"Ask an administrator for access to the user directory or return to an available page."}),e.jsx(u,{className:"mt-4",variant:"outline",size:"sm",children:"Return to dashboard"})]})})}function I(){return e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border bg-background p-3 md:flex-row",children:[e.jsx(z,{resource:"users",action:"list",children:e.jsxs(m,{size:"sm",className:"min-w-0 flex-1",children:[e.jsx(h,{children:e.jsx(p,{children:"Users"})}),e.jsx(x,{children:e.jsx(H,{limit:2})})]})}),e.jsx(z,{resource:"departments",action:"list",children:e.jsxs(m,{size:"sm",className:"md:w-56",children:[e.jsx(h,{children:e.jsx(p,{children:"Departments"})}),e.jsxs(x,{className:"space-y-2",children:[e.jsx(_,{title:"Engineering",name:"engineering"}),e.jsx(_,{title:"Operations",name:"operations"})]})]})})]})}function K(){return e.jsxs(m,{children:[e.jsxs(h,{className:"flex-row items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(p,{children:"Users"}),e.jsx(P,{children:"Record actions"})]}),e.jsx(c,{resource:"users",action:"create",children:e.jsxs(u,{size:"sm",children:[e.jsx(ne,{})," New user"]})})]}),e.jsx(x,{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[420px] text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-3 font-medium",children:"User"}),e.jsx("th",{className:"pb-3 font-medium",children:"Role"}),e.jsx("th",{className:"pb-3 text-right font-medium",children:"Actions"})]})}),e.jsx("tbody",{children:R.slice(0,2).map(s=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsx("td",{className:"py-3 font-medium",children:s.name}),e.jsx("td",{className:"py-3 text-muted-foreground",children:s.role}),e.jsx("td",{className:"py-3",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(c,{resource:"users",action:"show",id:s.id,children:e.jsx(u,{variant:"ghost",size:"icon-sm","aria-label":"View user",children:e.jsx(ae,{})})}),e.jsx(c,{resource:"users",action:"edit",id:s.id,children:e.jsx(u,{variant:"ghost",size:"icon-sm","aria-label":"Edit user",children:e.jsx(oe,{})})}),e.jsx(c,{resource:"users",action:"delete",id:s.id,children:e.jsx(u,{variant:"ghost",size:"icon-sm","aria-label":"Delete user",children:e.jsx(le,{})})})]})})]},s.id))})]})})]})}function M(){const s=R[1];return e.jsxs(m,{children:[e.jsxs(h,{children:[e.jsx(p,{children:"Edit profile"}),e.jsx(P,{children:s.name})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsx(C,{resource:"users",action:"edit",field:"nickname",children:e.jsx(N,{label:"Nickname",children:e.jsx(k,{defaultValue:s.name})})}),e.jsx(C,{resource:"users",action:"edit",field:"email",fallback:e.jsx(N,{label:"Email",children:e.jsxs("div",{className:"rounded-md border bg-muted/45 px-3 py-2 text-sm text-muted-foreground",children:[s.email,e.jsx(W,{className:"ml-2",variant:"outline",children:"Read only"})]})}),children:e.jsx(N,{label:"Email",children:e.jsx(k,{defaultValue:s.email})})}),e.jsx(C,{resource:"users",action:"edit",field:"phone",children:e.jsx(N,{label:"Phone",children:e.jsx(k,{defaultValue:s.phone})})}),e.jsx(c,{resource:"users",action:"edit",children:e.jsx(u,{size:"sm",children:"Save changes"})})]})]})}function N({label:s,children:t}){return e.jsxs("label",{className:"block space-y-2",children:[e.jsx("span",{className:"text-xs font-medium",children:s}),t]})}function H({limit:s=3}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[360px] text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-3 font-medium",children:"User"}),e.jsx("th",{className:"pb-3 font-medium",children:"Email"})]})}),e.jsx("tbody",{children:R.slice(0,s).map(t=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsxs("td",{className:"py-3",children:[e.jsx("div",{className:"font-medium",children:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.username})]}),e.jsx("td",{className:"py-3 text-muted-foreground",children:t.email})]},t.id))})]})})}function _({title:s,name:t}){return e.jsxs("div",{className:"rounded-lg border px-3 py-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s}),e.jsx("div",{className:"mt-0.5 font-mono text-xs text-muted-foreground",children:t})]})}export{qe as AclPatternsPage};