@mohsinonxrm/pptb-commandbar-studio 0.6.1 → 0.7.0-beta.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 +99 -4
- package/README.md +24 -1
- package/SECURITY.md +5 -2
- package/dist/assets/BulkPublishModal-CF7sSmBT.js +29 -0
- package/dist/assets/CommandEditorPanel-1tDOtoTt.js +1 -0
- package/dist/assets/CommandPalette-BBM1PJH0.js +1 -0
- package/dist/assets/{ConflictDrawer-DxQ_jd-x.js → ConflictDrawer-CjObt6DP.js} +1 -1
- package/dist/assets/{CrmParameterEditor-BdmP65mF.js → CrmParameterEditor-CQD0gNNH.js} +1 -1
- package/dist/assets/{DiffViewer-BZuqvP4f.js → DiffViewer-Dfu_9b4v.js} +2 -2
- package/dist/assets/{HideInsteadOfDeleteModal-BYHCTZrG.js → HideInsteadOfDeleteModal-C64qc-fw.js} +1 -1
- package/dist/assets/IconPickerModal-D6hQ_Aqx.js +1 -0
- package/dist/assets/ImportXmlModal-DXwUce5n.js +1 -0
- package/dist/assets/{LocalizationEditor-tmniX5PC.js → LocalizationEditor-DXqbD2ZN.js} +1 -1
- package/dist/assets/{MonacoEditor-Bbg9u2FW.js → MonacoEditor-CBUJNFgC.js} +2 -2
- package/dist/assets/NewButtonModal-B_ugATAS.js +1 -0
- package/dist/assets/NewGroupModal-Dvg8CSJr.js +1 -0
- package/dist/assets/NewTabModal-CjMNMXb5.js +1 -0
- package/dist/assets/{RuleEditorPanel-BkNwBgaP.js → RuleEditorPanel-B5or3M9d.js} +1 -1
- package/dist/assets/ScalingEditorPanel-CzQtkicj.js +1 -0
- package/dist/assets/TabDisplayRulesPanel-BqzSpzqp.js +1 -0
- package/dist/assets/{UrlComposerModal-BlVXHKRM.js → UrlComposerModal-BDP57HQn.js} +1 -1
- package/dist/assets/WebResourceBrowser-BK_G_Q_c.js +1 -0
- package/dist/assets/XmlDrawer-C4lJ7_MF.js +2 -0
- package/dist/assets/codicon-DF1abBS2.ttf +0 -0
- package/dist/assets/{css.worker-DBVD8oXr.js → css.worker-C_6RgliQ.js} +37 -33
- package/dist/assets/cssMode-yNaVDuBb.js +1 -0
- package/dist/assets/{dnd-fsSwRnQv.js → dnd-BmqIZ1-i.js} +1 -1
- package/dist/assets/editor.worker-D1TDBLlL.js +30 -0
- package/dist/assets/{fluent-icons-DxKNRZ1A.js → fluent-icons-DUgjkNjy.js} +1 -1
- package/dist/assets/{fluent-ui-D7EtYwEg.js → fluent-ui-Dde22_ZN.js} +2 -2
- package/dist/assets/{freemarker2-DDn-Wpd6.js → freemarker2-CzWSO7cF.js} +3 -3
- package/dist/assets/{handlebars-Ck_SjSJx.js → handlebars-BpG2O9CH.js} +1 -1
- package/dist/assets/{html-BaJUqhKx.js → html-Bm7ESfBq.js} +1 -1
- package/dist/assets/{html.worker-CwpTb9lJ.js → html.worker-CLyYFd_g.js} +53 -49
- package/dist/assets/htmlMode--CmpAV7s.js +1 -0
- package/dist/assets/index-CL8TmfXp.js +139 -0
- package/dist/assets/{javascript-2UlV1Qbm.js → javascript-DYy3TIq5.js} +1 -1
- package/dist/assets/json.worker-BggoxaER.js +62 -0
- package/dist/assets/{jsonMode-BmSpB9yr.js → jsonMode-DwsyQ3o1.js} +4 -4
- package/dist/assets/{liquid-CE2reFvH.js → liquid-qkuWCPaY.js} +1 -1
- package/dist/assets/{lspLanguageFeatures-BvbzEddk.js → lspLanguageFeatures-Cgd9CNvq.js} +1 -1
- package/dist/assets/{mdx-BvcZv3tC.js → mdx-CtHfOclF.js} +1 -1
- package/dist/assets/monaco-BIO15LCS.js +1005 -0
- package/dist/assets/monaco-DdLsZAcA.css +1 -0
- package/dist/assets/{python-MTPSN2vk.js → python-CazlH6B-.js} +1 -1
- package/dist/assets/{razor-Ccq_CgR8.js → razor-BfGfB6aB.js} +1 -1
- package/dist/assets/{server.browser-C3R9jebn.js → server.browser-xEJRzS2D.js} +1 -1
- package/dist/assets/{ts.worker-BH9nVgjN.js → ts.worker-BrLZGe_E.js} +225 -221
- package/dist/assets/{tsMode-2cv3qhqp.js → tsMode-BZv6gTt6.js} +3 -3
- package/dist/assets/{typescript-BD6t7JEG.js → typescript-BgDL1fzP.js} +1 -1
- package/dist/assets/useReplaceWebResourceConfirm-Dx7RdpEN.js +1 -0
- package/dist/assets/workers-BZ4mXA5s.js +1 -0
- package/dist/assets/{xml-DJGPA7j9.js → xml-Cl6spsD4.js} +1 -1
- package/dist/assets/xmlValidator-DvDaU5OO.js +3 -0
- package/dist/assets/{yaml-Cpl0dvFM.js → yaml-El-x4GhS.js} +1 -1
- package/dist/icons/icon.svg +7 -4
- package/dist/index.html +6 -6
- package/package.json +3 -3
- package/dist/assets/BulkPublishModal-DqX2QmUD.js +0 -29
- package/dist/assets/CommandEditorPanel-DidGBtFC.js +0 -1
- package/dist/assets/CommandPalette-AuDfsF8l.js +0 -1
- package/dist/assets/IconPickerModal-Bw0C7KwV.js +0 -1
- package/dist/assets/ImportXmlModal-B8NgiUDZ.js +0 -1
- package/dist/assets/NewButtonModal-BVvlbCv4.js +0 -1
- package/dist/assets/NewGroupModal-CgQy-uo4.js +0 -1
- package/dist/assets/NewTabModal-B_2-kwAx.js +0 -1
- package/dist/assets/ScalingEditorPanel-ezMkzvG1.js +0 -1
- package/dist/assets/TabDisplayRulesPanel-trzExQ1T.js +0 -1
- package/dist/assets/WebResourceBrowser-DaPOZQ5X.js +0 -1
- package/dist/assets/XmlDrawer-BI6Wy6kL.js +0 -2
- package/dist/assets/codicon-ngg6Pgfi.ttf +0 -0
- package/dist/assets/cssMode-DdC7kBk-.js +0 -1
- package/dist/assets/editor.worker-1APKdqmi.js +0 -26
- package/dist/assets/htmlMode-CnYhJfhG.js +0 -1
- package/dist/assets/index-Bu7BlRFk.js +0 -139
- package/dist/assets/json.worker-BoL8UZqY.js +0 -58
- package/dist/assets/monaco-Bx8A1Vm1.js +0 -918
- package/dist/assets/monaco-Dprb6f6S.css +0 -1
- package/dist/assets/webResourceService-CvyHBu7T.js +0 -1
- package/dist/assets/xmlValidator-D7JG-eNC.js +0 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./monaco-
|
|
2
|
-
import{a as l,R as f,_ as h}from"./monaco-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./monaco-BIO15LCS.js","./monaco-DdLsZAcA.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as l,R as f,_ as h}from"./monaco-BIO15LCS.js";import{y as t}from"./fluent-icons-DUgjkNjy.js";import{a as u}from"./index-CL8TmfXp.js";import{a5 as x}from"./fluent-ui-Dde22_ZN.js";const _=f.lazy(()=>h(()=>import("./monaco-BIO15LCS.js").then(o=>o.i),__vite__mapDeps([0,1]),import.meta.url)),v=({language:o,value:r,onChange:a,readOnly:s=!1,height:i="100%",options:m={},onMount:n})=>{const d=u(e=>e.themeMode)==="dark"?"vs-dark":"vs",c={readOnly:s,minimap:{enabled:!1},wordWrap:o==="xml"?"on":"off",scrollBeyondLastLine:!1,automaticLayout:!0,...m},p=e=>{a&&e!==void 0&&a(e)};return t.jsx(l.Suspense,{fallback:t.jsx(x,{size:"medium",label:"Loading editor…"}),children:t.jsx(_,{height:i,language:o,value:r,theme:d,options:c,onChange:p,onMount:n})})};export{v as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e}from"./fluent-icons-DUgjkNjy.js";import{a as S}from"./monaco-BIO15LCS.js";import{a as B,u as i,a8 as b,W as m,c as O,a9 as G,M as K}from"./index-CL8TmfXp.js";import{D as M,i as _,j as q,k as z,l as U,F as C,I as W,S as Y,b as $,m as H,d as I}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const tt=()=>{const n=B(t=>t.newButtonGroupId),l=B(t=>t.closeNewButton),v=i(t=>t.createButton),w=i(t=>t.upsertCommand),y=i(t=>t.batch),N=b(t=>t.selectButtonInContext),D=m(t=>t.publisherPrefix),E=m(t=>t.activeSolution),s=b(t=>t.location),k=b(t=>t.tabId),R=m(t=>t.activeEntity),T=n!==null,[r,p]=S.useState("New Button"),[x,h]=S.useState("button"),F=()=>{if(!n||!s)return;const t=E?.publisherPrefix?.trim()||D?.trim()||"new",a=R?.logicalName??"global",c=i.getState().ribbons,L=i.getState().commands,f=new Set(L.map(o=>o.id));for(const o of Object.values(c))for(const d of o.tabs)for(const P of d.groups)for(const A of O(P))f.add(A.id);const{id:g,commandId:j}=G(t,a,s,r,f),u=c[s].tabs.find(o=>o.groups.some(d=>d.id===n))?.id??k;if(!c[s].tabs.some(o=>o.id===u)){K.getState().logError("canvas",`Could not add the button: group ${n} was not found.`),l();return}y(()=>{v({location:s,tabId:u,groupId:n,button:{id:g,label:r,kind:x,templateAlias:"o1",commandId:j,hidden:!1,oob:!1,custom:!0,managed:!1}}),w({id:j,enableRules:[],displayRules:[],actions:[]})}),N(s,u,n,g),p("New Button"),h("button"),l()};return e.jsx(M,{open:T,onOpenChange:()=>l(),children:e.jsxs(_,{children:[e.jsx(q,{children:"New button"}),e.jsxs(z,{children:[e.jsxs(U,{children:[e.jsx(C,{label:"Label",required:!0,children:e.jsx(W,{value:r,onChange:(t,a)=>p(a.value),autoFocus:!0})}),e.jsx(C,{label:"Kind",children:e.jsxs(Y,{value:x,onChange:(t,a)=>h(a.value),children:[e.jsx("option",{value:"button",children:"Button"}),e.jsx("option",{value:"flyout",children:"Flyout anchor"}),e.jsx("option",{value:"splitButton",children:"Split button"})]})}),e.jsx($,{size:200,style:{display:"block",marginTop:"8px"},children:"A command definition will be created automatically. You can edit it in the Command Editor."})]}),e.jsxs(H,{children:[e.jsx(I,{appearance:"secondary",onClick:l,children:"Cancel"}),e.jsx(I,{appearance:"primary",onClick:F,disabled:!r.trim(),children:"Create button"})]})]})]})})};export{tt as NewButtonModal,tt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e}from"./fluent-icons-DUgjkNjy.js";import{a as u}from"./monaco-BIO15LCS.js";import{a as p,u as g,a8 as d}from"./index-CL8TmfXp.js";import{D as y,i as v,j as w,k as G,l as C,F as x,I as F,S as L,b as S,m as f,d as h}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const O=()=>{const b=p(o=>o.newGroupOpen),a=p(o=>o.closeNewGroup),j=g(o=>o.createGroup),s=d(o=>o.location),n=d(o=>o.tabId),[t,r]=u.useState("New Group"),[i,c]=u.useState("Flexible2"),m=()=>{!s||!n||(j({location:s,tabId:n,group:{label:t,template:i,buttons:[]}}),r("New Group"),c("Flexible2"),a())};return e.jsx(y,{open:b,onOpenChange:()=>a(),children:e.jsxs(v,{children:[e.jsx(w,{children:"New group"}),e.jsxs(G,{children:[e.jsxs(C,{children:[e.jsx(x,{label:"Label",required:!0,children:e.jsx(F,{value:t,onChange:(o,l)=>r(l.value),autoFocus:!0})}),e.jsx(x,{label:"Group template",children:e.jsxs(L,{value:i,onChange:(o,l)=>c(l.value),children:[e.jsx("option",{value:"Flexible2",children:"Flexible2 (recommended)"}),e.jsx("option",{value:"Flexible",children:"Flexible"}),e.jsx("option",{value:"Layout2",children:"Layout2"}),e.jsx("option",{value:"Layout3",children:"Layout3"}),e.jsx("option",{value:"Layout4",children:"Layout4"})]})}),e.jsx(S,{size:200,style:{display:"block",marginTop:"8px"},children:"The group template defines how buttons scale when the ribbon is resized."})]}),e.jsxs(f,{children:[e.jsx(h,{appearance:"secondary",onClick:a,children:"Cancel"}),e.jsx(h,{appearance:"primary",onClick:m,disabled:!t.trim(),children:"Create group"})]})]})]})})};export{O as NewGroupModal,O as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e,h as B,z as F}from"./fluent-icons-DUgjkNjy.js";import{a as S,R as E}from"./monaco-BIO15LCS.js";import{a8 as _,u as c,W as N,a as C,aa as O,ab as L,ac as $,ad as H}from"./index-CL8TmfXp.js";import{D as G,i as U,k as W,j as q,aa as P,d as p,l as X,M as D,f as I,b as d,F as v,I as w,t as s,m as Y}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const Z={HomepageGrid:"home grid",Form:"form",SubGrid:"sub-grid",Application:""},J=F({surface:{width:"480px",maxWidth:"95vw"},body:{display:"flex",flexDirection:"column",gap:s.spacingHorizontalM},hint:{fontFamily:s.fontFamilyMonospace,fontSize:s.fontSizeBase100,color:s.colorNeutralForeground3,backgroundColor:s.colorNeutralBackground3,padding:`${s.spacingHorizontalXS} ${s.spacingHorizontalS}`,borderRadius:s.borderRadiusMedium}}),se=()=>{const b=J(),[t,h]=S.useState("New Tab"),[g,x]=S.useState(""),o=_(a=>a.location),R=c(a=>a.createTab),u=c(a=>a.ribbons),m=c(a=>a.baseline),j=c(a=>a.layers),z=N(a=>a.activeEntity);N(a=>a.publisherPrefix);const A=C(a=>a.newTabOpen),l=C(a=>a.closeNewTab),y=E.useMemo(()=>O({baseline:m,layers:j},u),[m,j,u]),M=o==="Application"?"global":z?.logicalName??u[o].entityLogicalName,T=L(M,`${o}.${t}`,"Tab",y),n=g.trim(),r=n?$(n)??(/[^a-zA-Z0-9._]/.test(n)?"Use letters, digits, dots and underscores only":y.has(n)?"This ID is already used":null):null,f=n||T,k=()=>{r||(R(o,{id:f,label:t,tabDisplayRules:[],groups:[]}),h("New Tab"),x(""),l())};return e.jsx(G,{open:A,onOpenChange:(a,i)=>!i.open&&l(),children:e.jsx(U,{className:b.surface,children:e.jsxs(W,{children:[e.jsx(q,{action:e.jsx(p,{appearance:"subtle",icon:e.jsx(B,{}),onClick:l,"aria-label":"Close"}),children:e.jsx(P,{children:"Add Tab"})}),e.jsxs(X,{className:b.body,children:[e.jsx(D,{intent:"info",children:e.jsx(I,{children:e.jsx(d,{size:200,children:o==="Application"?"A tab is shown only where a Tab Display Rule allows it. Add one in Tab rules before publishing.":`The tab gets a Tab Display Rule for this table's ${Z[o]}. You can change it in Tab rules.`})})}),e.jsx(D,{intent:"info",children:e.jsx(I,{children:e.jsx(d,{size:200,children:H})})}),e.jsx(v,{label:"Tab label",required:!0,children:e.jsx(w,{value:t,onChange:(a,i)=>h(i.value),placeholder:"My Tab"})}),e.jsx(v,{label:"Tab ID",hint:"Leave blank to auto-generate from label",validationState:r?"error":"none",validationMessage:r??void 0,children:e.jsx(w,{value:g,onChange:(a,i)=>x(i.value),placeholder:T})}),e.jsxs("div",{children:[e.jsx(d,{size:100,style:{color:s.colorNeutralForeground3},children:"Generated ID:"}),e.jsx("div",{className:b.hint,children:f})]}),e.jsxs(d,{size:200,style:{color:s.colorNeutralForeground3},children:["Location: ",e.jsx("strong",{children:o})]})]}),e.jsxs(Y,{children:[e.jsx(p,{appearance:"secondary",onClick:l,children:"Cancel"}),e.jsx(p,{appearance:"primary",disabled:!t.trim()||!!r,onClick:k,children:"Create tab"})]})]})})})};export{se as NewTabModal,se as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e,y as L,h as X,cq as K}from"./fluent-icons-DxKNRZ1A.js";import{a as I,R as te}from"./monaco-Bx8A1Vm1.js";import{a as _,u as $}from"./index-Bu7BlRFk.js";import{R as se,i as oe,a as V}from"./ruleKinds-B9hACGaq.js";import{T as E,t as o,I as y,B as O,c as q,F as s,S as h,am as w,P as Q,b as Y,d as J,ah as ce,ai as ue,aj as de,ak as pe,M as he,e as me,a7 as H}from"./fluent-ui-D7EtYwEg.js";import{C as xe}from"./CrmParameterEditor-BdmP65mF.js";import{f as Z,D as ye,c as ve,S as je,v as ge,g as Re,C as be}from"./dnd-fsSwRnQv.js";import"./crmParameters-rgfZhhzN.js";const fe=L({root:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS},search:{marginBottom:o.spacingVerticalXS},group:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXXS},groupLabel:{color:o.colorNeutralForeground3,paddingTop:o.spacingVerticalXS},kindButton:{justifyContent:"flex-start",textAlign:"left"}});function Ce(l){switch(l){case"CommandClientTypeRule":return{kind:l,type:"Refresh"};case"CrmClientTypeRule":return{kind:l,type:"Web"};case"FormStateRule":return{kind:l,state:"Existing"};case"FormTypeRule":return{kind:l,type:"Main"};case"SelectionCountRule":return{kind:l,minimum:1};case"EntityRule":return{kind:l};case"CustomRule":return{kind:l,library:"$webresource:",functionName:""};case"ValueRule":return{kind:l,field:"",value:""};case"SkuRule":return{kind:l,sku:"Online"};case"OrRule":return{kind:l,groups:[[{kind:"FormStateRule",state:"Existing"}],[{kind:"FormStateRule",state:"Create"}]]};case"FeatureControlRule":return{kind:l,featureControlBit:"",expectedValue:!0};case"OrganizationSettingRule":return{kind:l,setting:"IsSharepointEnabled"};case"EntityPrivilegeRule":return{kind:l,privilegeType:"Read",privilegeDepth:"Basic"};case"EntityPropertyRule":return{kind:l,propertyName:"IsCustomizable",propertyValue:!0};case"RecordPrivilegeRule":return{kind:l,privilegeType:"Read"};case"RelationshipTypeRule":return{kind:l,appliesTo:"SelectedEntity"};case"MiscellaneousPrivilegeRule":return{kind:l,privilegeName:"ExportToExcel"};case"FormEntityContextRule":return{kind:l,entityName:""};case"PageRule":return{kind:l,address:""};case"CrmOfflineAccessStateRule":return{kind:l,state:"Online"};case"CrmOutlookClientTypeRule":return{kind:l,type:"CrmForOutlook"};case"CrmOutlookClientVersionRule":return{kind:l,major:15,minor:0,build:0,revision:0};case"DeviceTypeRule":return{kind:l,type:"Web"};case"OptionSetRule":return{kind:l,optionSet:"",stateCode:"",objectTypeCode:""};case"OutlookItemTrackingRule":return{kind:l,trackedInCrm:!0};case"OutlookRenderTypeRule":return{kind:l,type:"Web"};case"OutlookVersionRule":return{kind:l,version:"2010"};case"HideForTabletExperienceRule":return{kind:l};case"ReferencingAttributeRequiredRule":return{kind:l};default:return{kind:l}}}const ee=({onSelect:l,container:t,insideOr:d=!1})=>{const p=fe(),[c,f]=I.useState(""),R=se.map(x=>({...x,kinds:x.kinds.filter(m=>{if(t&&!oe(m,t,d)||d&&m==="OrRule")return!1;const C=V[m]??m;return!c||C.toLowerCase().includes(c.toLowerCase())||m.toLowerCase().includes(c.toLowerCase())})})).filter(x=>x.kinds.length>0);return e.jsxs("div",{className:p.root,children:[e.jsx(E,{size:100,style:{color:o.colorNeutralForeground3},children:"Quick action rules are OOB references and should be bound by ID (for example, Mscrm.ShowOnQuickAction), not created as custom step kinds."}),e.jsx(y,{className:p.search,placeholder:"Search rule kinds…",value:c,onChange:(x,m)=>f(m.value)}),R.map(x=>e.jsxs("div",{className:p.group,children:[e.jsx(E,{size:100,weight:"semibold",className:p.groupLabel,children:x.label}),x.kinds.map(m=>e.jsx(O,{appearance:"subtle",className:p.kindButton,onClick:()=>l(Ce(m)),children:V[m]??m},m))]},x.label))]})},Se=L({step:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS,padding:o.spacingVerticalS,border:`1px solid ${o.colorNeutralStroke2}`,borderRadius:o.borderRadiusMedium,backgroundColor:o.colorNeutralBackground2},header:{display:"flex",alignItems:"center",justifyContent:"space-between"},kindBadge:{flexShrink:0},fields:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS},row:{display:"flex",gap:o.spacingHorizontalS,alignItems:"flex-end",flexWrap:"wrap"},nested:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS,paddingLeft:o.spacingHorizontalM,borderLeft:`2px solid ${o.colorBrandStroke2}`},nestedToolbar:{display:"flex",alignItems:"center",gap:o.spacingHorizontalXS},pickerSurface:{minWidth:"300px",maxHeight:"50vh",overflowY:"auto",padding:o.spacingVerticalS}}),G=["Create","Read","Write","Delete","Assign","Share","Append","AppendTo"],W=["None","Basic","Local","Deep","Global"],Ee=["DuplicateDetectionEnabled","GridFiltersEnabled","HasStateCode","IsConnectionsEnabled","MailMergeEnabled","WorksWithQueue","HasActivities","IsActivity","HasNotes","IsCustomizable","IsActivityParty","HasEmailAddresses","IsChildEntity","IsImportable","IsEnabledForCharts","IsBusinessProcessEnabled","HasFeedback","IsBPFEntity"],Te=["ExportToExcel","MailMerge","GoOffline","OfflineSynchronize","PublishReports"],le=({step:l,onChange:t,onRemove:d,container:p})=>{const c=Se(),[f,R]=te.useState(null),x=l.kind!=="OrRule"&&l.kind!=="RawRule",m=x?l.invertResult:void 0,C=x?l.default:void 0,r=a=>{t({...l,...a})},k=a=>{if(!a.trim())return;const n=parseInt(a,10);return Number.isNaN(n)?void 0:n},A=()=>{switch(l.kind){case"CommandClientTypeRule":return e.jsx(s,{label:"Type",children:e.jsxs(h,{value:l.type,onChange:(a,n)=>r({type:n.value}),children:[e.jsx("option",{value:"Refresh",children:"Refresh (Unified Interface / modern web)"}),e.jsx("option",{value:"Modern",children:"Modern (Dynamics 365 for tablets)"}),e.jsx("option",{value:"Legacy",children:"Legacy (classic ribbon + Outlook list views)"})]})});case"CrmClientTypeRule":return e.jsx(s,{label:"Type",children:e.jsxs(h,{value:l.type,onChange:(a,n)=>r({type:n.value}),children:[e.jsx("option",{value:"Web",children:"Web"}),e.jsx("option",{value:"Outlook",children:"Outlook"})]})});case"FormStateRule":return e.jsx(s,{label:"State",children:e.jsx(h,{value:l.state,onChange:(a,n)=>r({state:n.value}),children:["Create","Existing","ReadOnly","Disabled","BulkEdit"].map(a=>e.jsx("option",{value:a,children:a},a))})});case"FormTypeRule":return e.jsx(s,{label:"Type",children:e.jsx(h,{value:l.type,onChange:(a,n)=>r({type:n.value}),children:["Main","Preview","AppointmentBook","Dashboard","Quick","QuickCreate","Card","MainInteractionCentric"].map(a=>e.jsx("option",{value:a,children:a},a))})});case"SelectionCountRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Minimum",children:e.jsx(y,{value:String(l.minimum??""),onChange:(a,n)=>r({minimum:n.value?parseInt(n.value):void 0}),style:{width:"80px"}})}),e.jsx(s,{label:"Maximum",children:e.jsx(y,{type:"number",value:String(l.maximum??""),onChange:(a,n)=>r({maximum:n.value?parseInt(n.value):void 0}),style:{width:"80px"}})}),e.jsx(s,{label:"Applies To",children:e.jsxs(h,{value:l.appliesTo??"",onChange:(a,n)=>r({appliesTo:n.value}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"PrimaryEntity",children:"PrimaryEntity"}),e.jsx("option",{value:"SelectedEntity",children:"SelectedEntity"})]})})]});case"EntityRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Entity name",children:e.jsx(y,{value:l.entityName??"",onChange:(a,n)=>r({entityName:n.value||void 0})})}),e.jsx(s,{label:"Applies To",children:e.jsxs(h,{value:l.appliesTo??"",onChange:(a,n)=>r({appliesTo:n.value}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"PrimaryEntity",children:"PrimaryEntity"}),e.jsx("option",{value:"SelectedEntity",children:"SelectedEntity"})]})}),e.jsx(s,{label:"Context",children:e.jsxs(h,{value:l.context??"",onChange:(a,n)=>r({context:n.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"Form",children:"Form"}),e.jsx("option",{value:"HomePageGrid",children:"HomePageGrid"}),e.jsx("option",{value:"SubGridStandard",children:"SubGridStandard"}),e.jsx("option",{value:"SubGridAssociated",children:"SubGridAssociated"})]})})]});case"FormEntityContextRule":return e.jsx(s,{label:"Entity name",children:e.jsx(y,{value:l.entityName,onChange:(a,n)=>r({entityName:n.value})})});case"CustomRule":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Library ($webresource:)",children:e.jsx(y,{value:l.library,onChange:(a,n)=>r({library:n.value}),placeholder:"$webresource:..."})}),e.jsx(s,{label:"Function name",children:e.jsx(y,{value:l.functionName,onChange:(a,n)=>r({functionName:n.value})})})]}),e.jsx(s,{label:"Parameters",children:e.jsx(xe,{params:l.params??[],onChange:a=>r({params:a.length?a:void 0})})}),e.jsx(E,{size:100,style:{color:o.colorNeutralForeground3},children:"Async support: on Unified Interface, custom rules can return Promise<boolean>; unresolved promises default to false after 10 seconds."})]});case"CrmOfflineAccessStateRule":return e.jsx(s,{label:"State",children:e.jsxs(h,{value:l.state,onChange:(a,n)=>r({state:n.value}),children:[e.jsx("option",{value:"Online",children:"Online"}),e.jsx("option",{value:"Offline",children:"Offline"})]})});case"CrmOutlookClientTypeRule":return e.jsx(s,{label:"Type",children:e.jsxs(h,{value:l.type,onChange:(a,n)=>r({type:n.value}),children:[e.jsx("option",{value:"CrmForOutlook",children:"CrmForOutlook"}),e.jsx("option",{value:"CrmForOutlookOfflineAccess",children:"CrmForOutlookOfflineAccess"})]})});case"CrmOutlookClientVersionRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Major",children:e.jsx(y,{type:"number",value:String(l.major),onChange:(a,n)=>r({major:k(n.value)??l.major}),style:{width:"84px"}})}),e.jsx(s,{label:"Minor",children:e.jsx(y,{type:"number",value:String(l.minor??""),onChange:(a,n)=>r({minor:k(n.value)}),style:{width:"84px"}})}),e.jsx(s,{label:"Build",children:e.jsx(y,{type:"number",value:String(l.build??""),onChange:(a,n)=>r({build:k(n.value)}),style:{width:"84px"}})}),e.jsx(s,{label:"Revision",children:e.jsx(y,{type:"number",value:String(l.revision??""),onChange:(a,n)=>r({revision:k(n.value)}),style:{width:"84px"}})})]});case"DeviceTypeRule":return e.jsx(s,{label:"Device type",children:e.jsxs(h,{value:l.type,onChange:(a,n)=>r({type:n.value}),children:[e.jsx("option",{value:"None",children:"None"}),e.jsx("option",{value:"Phone",children:"Phone"}),e.jsx("option",{value:"Tablet",children:"Tablet"}),e.jsx("option",{value:"Web",children:"Web"}),e.jsx("option",{value:"Outlook",children:"Outlook"}),e.jsx("option",{value:"InteractionCentric",children:"InteractionCentric"})]})});case"EntityPrivilegeRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Entity (optional)",children:e.jsx(y,{value:l.entityName??"",onChange:(a,n)=>r({entityName:n.value||void 0})})}),e.jsx(s,{label:"Applies To",children:e.jsxs(h,{value:l.appliesTo??"",onChange:(a,n)=>r({appliesTo:n.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"PrimaryEntity",children:"PrimaryEntity"}),e.jsx("option",{value:"SelectedEntity",children:"SelectedEntity"})]})}),e.jsx(s,{label:"Privilege",children:e.jsx(h,{value:l.privilegeType,onChange:(a,n)=>r({privilegeType:n.value}),children:G.map(a=>e.jsx("option",{value:a,children:a},a))})}),e.jsx(s,{label:"Depth",children:e.jsx(h,{value:l.privilegeDepth,onChange:(a,n)=>r({privilegeDepth:n.value}),children:W.map(a=>e.jsx("option",{value:a,children:a},a))})})]});case"EntityPropertyRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Entity (optional)",children:e.jsx(y,{value:l.entityName??"",onChange:(a,n)=>r({entityName:n.value||void 0})})}),e.jsx(s,{label:"Applies To",children:e.jsxs(h,{value:l.appliesTo??"",onChange:(a,n)=>r({appliesTo:n.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"PrimaryEntity",children:"PrimaryEntity"}),e.jsx("option",{value:"SelectedEntity",children:"SelectedEntity"})]})}),e.jsx(s,{label:"Property",children:e.jsx(h,{value:l.propertyName,onChange:(a,n)=>r({propertyName:n.value}),children:Ee.map(a=>e.jsx("option",{value:a,children:a},a))})}),e.jsx(w,{label:"Property value",checked:l.propertyValue,onChange:(a,n)=>r({propertyValue:n.checked===!0})})]});case"ValueRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Field",children:e.jsx(y,{value:l.field,onChange:(a,n)=>r({field:n.value})})}),e.jsx(s,{label:"Value",children:e.jsx(y,{value:l.value,onChange:(a,n)=>r({value:n.value})})})]});case"OrRule":{const a=g=>t({...l,groups:g.filter(b=>b.length>0)}),n=(g,b)=>e.jsxs(Q,{open:f===g,onOpenChange:(v,u)=>R(u.open?g:null),children:[e.jsx(Y,{children:e.jsx(O,{icon:e.jsx(K,{}),appearance:"secondary",size:"small",children:b})}),e.jsx(J,{className:c.pickerSurface,children:e.jsx(ee,{container:p,insideOr:!0,onSelect:v=>{a(g==="new"?[...l.groups,[v]]:l.groups.map((u,S)=>S===g?[...u,v]:u)),R(null)}})})]});return e.jsxs("div",{className:c.nested,children:[l.groups.map((g,b)=>e.jsxs("div",{className:c.nested,children:[e.jsxs(E,{size:100,weight:"semibold",children:[b===0?"Either":"Or",g.length>1?" (all of)":""]}),g.map((v,u)=>e.jsx(le,{step:v,container:p,onChange:S=>a(l.groups.map((T,D)=>D===b?T.map((P,M)=>M===u?S:P):T)),onRemove:()=>a(l.groups.map((S,T)=>T===b?S.filter((D,P)=>P!==u):S))},`${b}-${u}-${v.kind}`)),e.jsx("div",{className:c.nestedToolbar,children:n(b,"And…")})]},b)),e.jsxs("div",{className:c.nestedToolbar,children:[n("new","Add Or branch"),e.jsx(E,{size:100,style:{color:o.colorNeutralForeground3},children:"An OrRule needs at least two branches."})]})]})}case"FeatureControlRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Feature control bit",children:e.jsx(y,{value:l.featureControlBit,onChange:(a,n)=>r({featureControlBit:n.value})})}),e.jsx(w,{label:"Expected value",checked:l.expectedValue,onChange:(a,n)=>r({expectedValue:n.checked===!0})})]});case"RawRule":return e.jsxs(e.Fragment,{children:[e.jsx(E,{size:100,style:{color:o.colorNeutralForeground3},children:"Command Bar Studio doesn't edit this rule; it is kept exactly as loaded."}),e.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"11px"},children:l.xml})]});case"SkuRule":return e.jsx(s,{label:"SKU",children:e.jsxs(h,{value:l.sku,onChange:(a,n)=>r({sku:n.value}),children:[e.jsx("option",{value:"Online",children:"Online"}),e.jsx("option",{value:"OnPremise",children:"OnPremise"}),e.jsx("option",{value:"Spla",children:"Spla"})]})});case"OrganizationSettingRule":return e.jsx(s,{label:"Setting",children:e.jsx(h,{value:l.setting,onChange:(a,n)=>r({setting:n.value}),children:["IsSharepointEnabled","IsSOPIntegrationEnabled","IsFiscalCalendarDefined","IsReadFormModeDefined","IsBPFEntityCustomizationFeatureEnabled"].map(a=>e.jsx("option",{value:a,children:a},a))})});case"MiscellaneousPrivilegeRule":return e.jsxs("div",{className:c.row,children:[e.jsxs(s,{label:"Privilege name",children:[e.jsx(y,{value:l.privilegeName,onChange:(a,n)=>r({privilegeName:n.value}),placeholder:"ExportToExcel",list:"misc-privilege-suggestions"}),e.jsx("datalist",{id:"misc-privilege-suggestions",children:Te.map(a=>e.jsx("option",{value:a},a))})]}),e.jsx(s,{label:"Depth (optional)",children:e.jsxs(h,{value:l.privilegeDepth??"",onChange:(a,n)=>r({privilegeDepth:n.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),W.map(a=>e.jsx("option",{value:a,children:a},a))]})})]});case"OptionSetRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Option set",children:e.jsx(y,{value:l.optionSet,onChange:(a,n)=>r({optionSet:n.value})})}),e.jsx(s,{label:"State code",children:e.jsx(y,{value:l.stateCode,onChange:(a,n)=>r({stateCode:n.value})})}),e.jsx(s,{label:"Object type code",children:e.jsx(y,{value:l.objectTypeCode,onChange:(a,n)=>r({objectTypeCode:n.value})})})]});case"OutlookItemTrackingRule":return e.jsxs("div",{className:c.row,children:[e.jsx(w,{label:"Tracked in CRM",checked:l.trackedInCrm,onChange:(a,n)=>r({trackedInCrm:n.checked===!0})}),e.jsx(s,{label:"Applies To",children:e.jsx(h,{value:l.appliesTo??"PrimaryEntity",onChange:(a,n)=>r({appliesTo:n.value}),children:e.jsx("option",{value:"PrimaryEntity",children:"PrimaryEntity"})})})]});case"OutlookRenderTypeRule":return e.jsx(s,{label:"Render type",children:e.jsxs(h,{value:l.type,onChange:(a,n)=>r({type:n.value}),children:[e.jsx("option",{value:"Web",children:"Web"}),e.jsx("option",{value:"Outlook",children:"Outlook"})]})});case"OutlookVersionRule":return e.jsx(s,{label:"Outlook version",children:e.jsxs(h,{value:l.version,onChange:(a,n)=>r({version:n.value}),children:[e.jsx("option",{value:"2003",children:"2003"}),e.jsx("option",{value:"2007",children:"2007"}),e.jsx("option",{value:"2010",children:"2010"})]})});case"PageRule":return e.jsx(s,{label:"Address pattern",children:e.jsx(y,{value:l.address,onChange:(a,n)=>r({address:n.value}),placeholder:"main.aspx"})});case"RecordPrivilegeRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Privilege",children:e.jsx(h,{value:l.privilegeType,onChange:(a,n)=>r({privilegeType:n.value}),children:G.map(a=>e.jsx("option",{value:a,children:a},a))})}),e.jsx(s,{label:"Applies To",children:e.jsxs(h,{value:l.appliesTo??"",onChange:(a,n)=>r({appliesTo:n.value||void 0}),children:[e.jsx("option",{value:"",children:"Default"}),e.jsx("option",{value:"PrimaryEntity",children:"PrimaryEntity"})]})})]});case"RelationshipTypeRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Applies To",children:e.jsx(h,{value:l.appliesTo,disabled:!0,children:e.jsx("option",{value:"SelectedEntity",children:"SelectedEntity"})})}),e.jsx(s,{label:"Relationship type",children:e.jsxs(h,{value:l.relationshipType??"",onChange:(a,n)=>r({relationshipType:n.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"OneToMany",children:"OneToMany"}),e.jsx("option",{value:"ManyToMany",children:"ManyToMany"}),e.jsx("option",{value:"NoRelationship",children:"NoRelationship"})]})}),e.jsx(w,{label:"Allow custom relationship",checked:l.allowCustomRelationship===!0,onChange:(a,n)=>r({allowCustomRelationship:n.checked===!0})}),e.jsx(w,{label:"Allow system relationship",checked:l.allowSystemRelationship===!0,onChange:(a,n)=>r({allowSystemRelationship:n.checked===!0})})]});default:return e.jsxs(E,{size:200,italic:!0,style:{color:o.colorNeutralForeground3},children:[l.kind," — no additional parameters"]})}};return e.jsxs("div",{className:c.step,role:"listitem",children:[e.jsxs("div",{className:c.header,children:[e.jsx(q,{appearance:"outline",size:"small",className:c.kindBadge,children:V[l.kind]??l.kind}),e.jsx(O,{appearance:"subtle",icon:e.jsx(X,{}),size:"small",onClick:d,"aria-label":`Remove ${l.kind} step`})]}),e.jsxs("div",{className:c.fields,children:[A(),e.jsx("div",{className:c.row,children:x&&e.jsxs(e.Fragment,{children:[e.jsx(s,{label:"Default",title:"Value the rule returns when it cannot be evaluated.",children:e.jsxs(h,{value:C===void 0?"":String(C),onChange:(a,n)=>r({default:n.value===""?void 0:n.value==="true"}),children:[e.jsx("option",{value:"",children:"(not set)"}),e.jsx("option",{value:"true",children:"true"}),e.jsx("option",{value:"false",children:"false"})]})}),e.jsx(w,{label:"Invert result",checked:m===!0,title:"Reverse the evaluated result.",onChange:(a,n)=>r({invertResult:n.checked===!0?!0:void 0})})]})})]})]})};function Ne(l){return l.length===0?"No steps defined — rule always passes.":l.map(B).join(" AND ")}function B(l){const t="invertResult"in l&&l.invertResult?"NOT ":"";switch(l.kind){case"SelectionCountRule":{const d=l.minimum!==void 0?`at least ${l.minimum}`:null,p=l.maximum!==void 0?`at most ${l.maximum}`:null,c=[d,p].filter(Boolean).join(" and "),f=l.appliesTo?` (${l.appliesTo})`:"";return`${t}Selection count is ${c}${f}`}case"EntityRule":{const d=l.entityName??"any entity",p=l.context?` in ${l.context} context`:"",c=l.appliesTo?` (${l.appliesTo})`:"";return`${t}Entity is "${d}"${p}${c}`}case"FormStateRule":return`${t}Form state is "${l.state}"`;case"CommandClientTypeRule":return`${t}Client type is "${l.type}" (${$e(l.type)})`;case"CrmClientTypeRule":return`${t}CRM client type is "${l.type}"`;case"CustomRule":return`${t}Custom rule: ${l.functionName}() from ${l.library}`;case"OrRule":return`(${l.groups.map(p=>p.length===1?B(p[0]):`(${p.map(B).join(" AND ")})`).join(" OR ")})`;case"FeatureControlRule":return`${t}Feature "${l.featureControlBit}" is ${l.expectedValue?"on":"off"}`;case"RawRule":return`${l.tagName} (kept as XML)`;case"MiscellaneousPrivilegeRule":{const d=l.privilegeDepth?` at ${l.privilegeDepth} depth`:"";return`${t}User has "${l.privilegeName}" privilege${d}`}case"EntityPrivilegeRule":{const d=l.entityName?` on "${l.entityName}"`:"",p=l.appliesTo?` (${l.appliesTo})`:"";return`${t}User has ${l.privilegeType} privilege${d} at ${l.privilegeDepth} depth${p}`}case"EntityPropertyRule":{const d=l.entityName?` for "${l.entityName}"`:"";return`${t}Entity property "${l.propertyName}" is ${l.propertyValue}${d}`}case"FormTypeRule":return`${t}Form type is "${l.type}"`;case"FormEntityContextRule":return`${t}Form entity context is "${l.entityName}"`;case"ValueRule":return`${t}Field "${l.field}" equals "${l.value}"`;case"SkuRule":return`${t}SKU is "${l.sku}"`;case"HideForTabletExperienceRule":return`${t}Hide for tablet experience`;case"OrganizationSettingRule":return`${t}Organization setting "${l.setting}" is enabled`;case"PageRule":return`${t}Page address matches "${l.address}"`;case"RecordPrivilegeRule":{const d=l.appliesTo?` (${l.appliesTo})`:"";return`${t}User has ${l.privilegeType} privilege on current record${d}`}case"RelationshipTypeRule":{const d=l.relationshipType??"any";return`${t}Relationship type is "${d}" (${l.appliesTo})`}case"ReferencingAttributeRequiredRule":return`${t}Referencing attribute is required`;case"OutlookItemTrackingRule":return`${t}Outlook item is ${l.trackedInCrm?"":"not "}tracked in CRM`;case"OutlookRenderTypeRule":return`${t}Outlook render type is "${l.type}"`;case"OutlookVersionRule":return`${t}Outlook version is "${l.version}"`;case"CrmOfflineAccessStateRule":return`${t}CRM offline state is "${l.state}"`;case"CrmOutlookClientTypeRule":return`${t}CRM Outlook client type is "${l.type}"`;case"CrmOutlookClientVersionRule":return`${t}CRM Outlook client version is ${l.major}.${l.minor??0}+`;case"DeviceTypeRule":return`${t}Device type is "${l.type}"`;case"OptionSetRule":return`${t}Option set "${l.optionSet}" state code is "${l.stateCode}"`;default:return"Unknown rule step"}}function $e(l){switch(l){case"Modern":return"Dynamics 365 tablets";case"Refresh":return"Unified Interface / modern web";case"Legacy":return"Classic ribbon / Outlook list views";default:return l}}let Oe=0;const U=(l,t)=>Array.from({length:t},()=>`${l}#${++Oe}`);function ke(l,t){const[d,p]=I.useState(null),c=I.useMemo(()=>U(l,t.length),[l,t]),f=!!d&&d.scope===l&&d.keys.length===t.length&&(d.items===t||d.pending);d?.pending&&p({...d,items:f?t:d.items,pending:!1});const R=f?d.keys:c,x=m=>p({scope:l,items:t,pending:!0,keys:m});return{keys:R,add:()=>x([...R,...U(l,1)]),remove:m=>x(R.filter((C,r)=>r!==m)),move:(m,C)=>x(Z(R,m,C)),update:()=>x(R)}}const we=L({drawer:{width:"560px",maxWidth:"90vw"},body:{display:"flex",flexDirection:"column",gap:o.spacingVerticalS,padding:o.spacingVerticalM,overflowY:"auto"},header:{display:"flex",alignItems:"center",gap:o.spacingHorizontalS},stepsList:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS,listStyle:"none",padding:0,margin:0},summary:{padding:o.spacingVerticalS,backgroundColor:o.colorNeutralBackground3,borderRadius:o.borderRadiusMedium,fontStyle:"italic",color:o.colorNeutralForeground2,fontSize:o.fontSizeBase200},addRow:{display:"flex",gap:o.spacingHorizontalS},pickerPopover:{maxHeight:"60vh",overflowY:"auto",minWidth:"320px",padding:o.spacingVerticalM},usedBy:{color:o.colorNeutralForeground3,fontSize:o.fontSizeBase200},ruleIdRow:{display:"flex",alignItems:"flex-end",gap:o.spacingHorizontalS},ruleIdInput:{fontFamily:o.fontFamilyMonospace},error:{color:o.colorPaletteRedForeground1,fontSize:o.fontSizeBase100},sortableItem:{listStyle:"none"},sortableInner:{display:"flex",alignItems:"flex-start",gap:o.spacingHorizontalS},dragHandle:{marginTop:o.spacingVerticalS,cursor:"grab"}}),Ie=[],Le=()=>{const l=we(),t=_(i=>i.ruleEditorOpen),d=_(i=>i.ruleEditorId),p=_(i=>i.ruleEditorKind),c=_(i=>i.closeRuleEditor),f=_(i=>i.openRuleEditor),R=$(i=>i.enableRules),x=$(i=>i.displayRules),m=$(i=>i.commands),C=$(i=>i.upsertEnableRule),r=$(i=>i.upsertDisplayRule),k=$(i=>i.renameEnableRuleId),A=$(i=>i.renameDisplayRuleId),[a,n]=I.useState(!1),[g,b]=I.useState(""),v=p==="enable",u=v?R.find(i=>i.id===d):x.find(i=>i.id===d);I.useEffect(()=>{u&&b(u.id)},[u]);const S=ke(`${p}:${u?.id??""}`,u?.steps??Ie),T=S.keys,D=m.filter(i=>v?i.enableRules.includes(d??""):i.displayRules.includes(d??"")).length,P=(i,j)=>{if(!u)return;const N=[...u.steps];N[i]=j,S.update(),v?C({...u,steps:N}):r({...u,steps:N})},M=i=>{if(!u)return;const j=u.steps.filter((N,F)=>F!==i);S.remove(i),v?C({...u,steps:j}):r({...u,steps:j})},ne=i=>{if(!u)return;const j=[...u.steps,i];S.add(),v?C({...u,steps:j}):r({...u,steps:j}),n(!1)},ae=i=>{if(!u||!i.over||i.active.id===i.over.id)return;const j=T.indexOf(String(i.active.id)),N=T.indexOf(String(i.over.id));if(j<0||N<0)return;const F=Z(u.steps,j,N);S.move(j,N),v?C({...u,steps:F}):r({...u,steps:F})};if(!u)return null;const re=Ne(u.steps),ie=(v?R:x).some(i=>i.id===g.trim()&&i.id!==u.id),z=g.trim()?/\s/.test(g)?"Rule ID cannot contain whitespace.":ie?"A rule with this ID already exists.":"":"Rule ID is required.";return e.jsxs(ce,{position:"end",open:t,onOpenChange:()=>c(),className:l.drawer,children:[e.jsx(ue,{children:e.jsx(de,{action:e.jsx(O,{appearance:"subtle",icon:e.jsx(X,{}),onClick:c,"aria-label":"Close rule editor"}),children:e.jsxs("div",{className:l.header,children:[e.jsx(q,{appearance:"filled",color:v?"success":"informative",size:"small",children:v?"Enable":"Display"}),e.jsx(E,{size:400,weight:"semibold",style:{fontFamily:o.fontFamilyMonospace},children:u.id})]})})}),e.jsxs(pe,{className:l.body,children:[e.jsxs(E,{className:l.usedBy,children:["Used by ",D," command(s)"]}),e.jsxs("div",{className:l.ruleIdRow,children:[e.jsx(y,{className:l.ruleIdInput,value:g,onChange:(i,j)=>b(j.value),"aria-label":"Rule ID"}),e.jsx(O,{appearance:"secondary",size:"small",disabled:!g.trim()||!!z||g===u.id,onClick:()=>{const i=g.trim();(v?k(u.id,i):A(u.id,i))&&f(i,v?"enable":"display")},children:"Apply ID change"})]}),z&&e.jsx(E,{className:l.error,children:z}),v&&e.jsx(he,{intent:"warning",children:e.jsx(me,{children:"Enable rules have a restricted set of allowed step types. Display-only rule kinds are disabled."})}),e.jsx(H,{children:"Steps (ALL must pass)"}),e.jsx(ye,{collisionDetection:ve,onDragEnd:ae,children:e.jsx(je,{items:T,strategy:ge,children:e.jsxs("ol",{className:l.stepsList,role:"list","aria-label":"Rule steps",children:[u.steps.map((i,j)=>e.jsx(Pe,{id:T[j],styles:l,children:e.jsx(le,{step:i,onChange:N=>P(j,N),onRemove:()=>M(j),container:v?"enable":"display"})},T[j])),u.steps.length===0&&e.jsx(E,{italic:!0,style:{color:o.colorNeutralForeground3},children:"No steps yet — all buttons with this rule will be visible/enabled by default."})]})})}),e.jsxs(Q,{open:a,onOpenChange:(i,j)=>n(j.open),children:[e.jsx(Y,{children:e.jsx(O,{icon:e.jsx(K,{}),appearance:"secondary",onClick:()=>n(!0),children:"Add step"})}),e.jsx(J,{className:l.pickerPopover,children:e.jsx(ee,{onSelect:ne,container:v?"enable":"display"})})]}),e.jsx(H,{children:"Plain-English summary"}),e.jsx("div",{className:l.summary,role:"note","aria-label":"Rule summary",children:re})]})]})};function Pe({id:l,children:t,styles:d}){const{attributes:p,listeners:c,setNodeRef:f,setActivatorNodeRef:R,transform:x,transition:m}=Re({id:l});return e.jsx("li",{ref:f,className:d.sortableItem,style:{transform:be.Transform.toString(x),transition:m},children:e.jsxs("div",{className:d.sortableInner,children:[e.jsx(O,{ref:R,appearance:"subtle",size:"small",className:d.dragHandle,...p,...c,"aria-label":"Drag to reorder step",children:"Drag"}),e.jsx("div",{style:{flex:1},children:t})]})})}export{Le as RuleEditorPanel,Le as default};
|
|
1
|
+
import{y as e,z as L,h as X,cq as K}from"./fluent-icons-DUgjkNjy.js";import{a as I,R as te}from"./monaco-BIO15LCS.js";import{a as _,u as $}from"./index-CL8TmfXp.js";import{R as se,i as oe,a as V}from"./ruleKinds-B9hACGaq.js";import{b as E,t as o,I as y,d as O,B as q,F as s,S as h,an as w,P as Q,c as Y,e as J,ai as ce,aj as ue,ak as de,al as pe,M as he,f as me,a7 as H}from"./fluent-ui-Dde22_ZN.js";import{C as xe}from"./CrmParameterEditor-CQD0gNNH.js";import{f as Z,D as ye,c as ve,S as je,v as ge,g as Re,C as be}from"./dnd-BmqIZ1-i.js";import"./crmParameters-rgfZhhzN.js";const fe=L({root:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS},search:{marginBottom:o.spacingVerticalXS},group:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXXS},groupLabel:{color:o.colorNeutralForeground3,paddingTop:o.spacingVerticalXS},kindButton:{justifyContent:"flex-start",textAlign:"left"}});function Ce(l){switch(l){case"CommandClientTypeRule":return{kind:l,type:"Refresh"};case"CrmClientTypeRule":return{kind:l,type:"Web"};case"FormStateRule":return{kind:l,state:"Existing"};case"FormTypeRule":return{kind:l,type:"Main"};case"SelectionCountRule":return{kind:l,minimum:1};case"EntityRule":return{kind:l};case"CustomRule":return{kind:l,library:"$webresource:",functionName:""};case"ValueRule":return{kind:l,field:"",value:""};case"SkuRule":return{kind:l,sku:"Online"};case"OrRule":return{kind:l,groups:[[{kind:"FormStateRule",state:"Existing"}],[{kind:"FormStateRule",state:"Create"}]]};case"FeatureControlRule":return{kind:l,featureControlBit:"",expectedValue:!0};case"OrganizationSettingRule":return{kind:l,setting:"IsSharepointEnabled"};case"EntityPrivilegeRule":return{kind:l,privilegeType:"Read",privilegeDepth:"Basic"};case"EntityPropertyRule":return{kind:l,propertyName:"IsCustomizable",propertyValue:!0};case"RecordPrivilegeRule":return{kind:l,privilegeType:"Read"};case"RelationshipTypeRule":return{kind:l,appliesTo:"SelectedEntity"};case"MiscellaneousPrivilegeRule":return{kind:l,privilegeName:"ExportToExcel"};case"FormEntityContextRule":return{kind:l,entityName:""};case"PageRule":return{kind:l,address:""};case"CrmOfflineAccessStateRule":return{kind:l,state:"Online"};case"CrmOutlookClientTypeRule":return{kind:l,type:"CrmForOutlook"};case"CrmOutlookClientVersionRule":return{kind:l,major:15,minor:0,build:0,revision:0};case"DeviceTypeRule":return{kind:l,type:"Web"};case"OptionSetRule":return{kind:l,optionSet:"",stateCode:"",objectTypeCode:""};case"OutlookItemTrackingRule":return{kind:l,trackedInCrm:!0};case"OutlookRenderTypeRule":return{kind:l,type:"Web"};case"OutlookVersionRule":return{kind:l,version:"2010"};case"HideForTabletExperienceRule":return{kind:l};case"ReferencingAttributeRequiredRule":return{kind:l};default:return{kind:l}}}const ee=({onSelect:l,container:t,insideOr:d=!1})=>{const p=fe(),[c,f]=I.useState(""),R=se.map(x=>({...x,kinds:x.kinds.filter(m=>{if(t&&!oe(m,t,d)||d&&m==="OrRule")return!1;const C=V[m]??m;return!c||C.toLowerCase().includes(c.toLowerCase())||m.toLowerCase().includes(c.toLowerCase())})})).filter(x=>x.kinds.length>0);return e.jsxs("div",{className:p.root,children:[e.jsx(E,{size:100,style:{color:o.colorNeutralForeground3},children:"Quick action rules are OOB references and should be bound by ID (for example, Mscrm.ShowOnQuickAction), not created as custom step kinds."}),e.jsx(y,{className:p.search,placeholder:"Search rule kinds…",value:c,onChange:(x,m)=>f(m.value)}),R.map(x=>e.jsxs("div",{className:p.group,children:[e.jsx(E,{size:100,weight:"semibold",className:p.groupLabel,children:x.label}),x.kinds.map(m=>e.jsx(O,{appearance:"subtle",className:p.kindButton,onClick:()=>l(Ce(m)),children:V[m]??m},m))]},x.label))]})},Se=L({step:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS,padding:o.spacingVerticalS,border:`1px solid ${o.colorNeutralStroke2}`,borderRadius:o.borderRadiusMedium,backgroundColor:o.colorNeutralBackground2},header:{display:"flex",alignItems:"center",justifyContent:"space-between"},kindBadge:{flexShrink:0},fields:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS},row:{display:"flex",gap:o.spacingHorizontalS,alignItems:"flex-end",flexWrap:"wrap"},nested:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS,paddingLeft:o.spacingHorizontalM,borderLeft:`2px solid ${o.colorBrandStroke2}`},nestedToolbar:{display:"flex",alignItems:"center",gap:o.spacingHorizontalXS},pickerSurface:{minWidth:"300px",maxHeight:"50vh",overflowY:"auto",padding:o.spacingVerticalS}}),G=["Create","Read","Write","Delete","Assign","Share","Append","AppendTo"],W=["None","Basic","Local","Deep","Global"],Ee=["DuplicateDetectionEnabled","GridFiltersEnabled","HasStateCode","IsConnectionsEnabled","MailMergeEnabled","WorksWithQueue","HasActivities","IsActivity","HasNotes","IsCustomizable","IsActivityParty","HasEmailAddresses","IsChildEntity","IsImportable","IsEnabledForCharts","IsBusinessProcessEnabled","HasFeedback","IsBPFEntity"],Te=["ExportToExcel","MailMerge","GoOffline","OfflineSynchronize","PublishReports"],le=({step:l,onChange:t,onRemove:d,container:p})=>{const c=Se(),[f,R]=te.useState(null),x=l.kind!=="OrRule"&&l.kind!=="RawRule",m=x?l.invertResult:void 0,C=x?l.default:void 0,r=a=>{t({...l,...a})},k=a=>{if(!a.trim())return;const n=parseInt(a,10);return Number.isNaN(n)?void 0:n},A=()=>{switch(l.kind){case"CommandClientTypeRule":return e.jsx(s,{label:"Type",children:e.jsxs(h,{value:l.type,onChange:(a,n)=>r({type:n.value}),children:[e.jsx("option",{value:"Refresh",children:"Refresh (Unified Interface / modern web)"}),e.jsx("option",{value:"Modern",children:"Modern (Dynamics 365 for tablets)"}),e.jsx("option",{value:"Legacy",children:"Legacy (classic ribbon + Outlook list views)"})]})});case"CrmClientTypeRule":return e.jsx(s,{label:"Type",children:e.jsxs(h,{value:l.type,onChange:(a,n)=>r({type:n.value}),children:[e.jsx("option",{value:"Web",children:"Web"}),e.jsx("option",{value:"Outlook",children:"Outlook"})]})});case"FormStateRule":return e.jsx(s,{label:"State",children:e.jsx(h,{value:l.state,onChange:(a,n)=>r({state:n.value}),children:["Create","Existing","ReadOnly","Disabled","BulkEdit"].map(a=>e.jsx("option",{value:a,children:a},a))})});case"FormTypeRule":return e.jsx(s,{label:"Type",children:e.jsx(h,{value:l.type,onChange:(a,n)=>r({type:n.value}),children:["Main","Preview","AppointmentBook","Dashboard","Quick","QuickCreate","Card","MainInteractionCentric"].map(a=>e.jsx("option",{value:a,children:a},a))})});case"SelectionCountRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Minimum",children:e.jsx(y,{value:String(l.minimum??""),onChange:(a,n)=>r({minimum:n.value?parseInt(n.value):void 0}),style:{width:"80px"}})}),e.jsx(s,{label:"Maximum",children:e.jsx(y,{type:"number",value:String(l.maximum??""),onChange:(a,n)=>r({maximum:n.value?parseInt(n.value):void 0}),style:{width:"80px"}})}),e.jsx(s,{label:"Applies To",children:e.jsxs(h,{value:l.appliesTo??"",onChange:(a,n)=>r({appliesTo:n.value}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"PrimaryEntity",children:"PrimaryEntity"}),e.jsx("option",{value:"SelectedEntity",children:"SelectedEntity"})]})})]});case"EntityRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Entity name",children:e.jsx(y,{value:l.entityName??"",onChange:(a,n)=>r({entityName:n.value||void 0})})}),e.jsx(s,{label:"Applies To",children:e.jsxs(h,{value:l.appliesTo??"",onChange:(a,n)=>r({appliesTo:n.value}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"PrimaryEntity",children:"PrimaryEntity"}),e.jsx("option",{value:"SelectedEntity",children:"SelectedEntity"})]})}),e.jsx(s,{label:"Context",children:e.jsxs(h,{value:l.context??"",onChange:(a,n)=>r({context:n.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"Form",children:"Form"}),e.jsx("option",{value:"HomePageGrid",children:"HomePageGrid"}),e.jsx("option",{value:"SubGridStandard",children:"SubGridStandard"}),e.jsx("option",{value:"SubGridAssociated",children:"SubGridAssociated"})]})})]});case"FormEntityContextRule":return e.jsx(s,{label:"Entity name",children:e.jsx(y,{value:l.entityName,onChange:(a,n)=>r({entityName:n.value})})});case"CustomRule":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Library ($webresource:)",children:e.jsx(y,{value:l.library,onChange:(a,n)=>r({library:n.value}),placeholder:"$webresource:..."})}),e.jsx(s,{label:"Function name",children:e.jsx(y,{value:l.functionName,onChange:(a,n)=>r({functionName:n.value})})})]}),e.jsx(s,{label:"Parameters",children:e.jsx(xe,{params:l.params??[],onChange:a=>r({params:a.length?a:void 0})})}),e.jsx(E,{size:100,style:{color:o.colorNeutralForeground3},children:"Async support: on Unified Interface, custom rules can return Promise<boolean>; unresolved promises default to false after 10 seconds."})]});case"CrmOfflineAccessStateRule":return e.jsx(s,{label:"State",children:e.jsxs(h,{value:l.state,onChange:(a,n)=>r({state:n.value}),children:[e.jsx("option",{value:"Online",children:"Online"}),e.jsx("option",{value:"Offline",children:"Offline"})]})});case"CrmOutlookClientTypeRule":return e.jsx(s,{label:"Type",children:e.jsxs(h,{value:l.type,onChange:(a,n)=>r({type:n.value}),children:[e.jsx("option",{value:"CrmForOutlook",children:"CrmForOutlook"}),e.jsx("option",{value:"CrmForOutlookOfflineAccess",children:"CrmForOutlookOfflineAccess"})]})});case"CrmOutlookClientVersionRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Major",children:e.jsx(y,{type:"number",value:String(l.major),onChange:(a,n)=>r({major:k(n.value)??l.major}),style:{width:"84px"}})}),e.jsx(s,{label:"Minor",children:e.jsx(y,{type:"number",value:String(l.minor??""),onChange:(a,n)=>r({minor:k(n.value)}),style:{width:"84px"}})}),e.jsx(s,{label:"Build",children:e.jsx(y,{type:"number",value:String(l.build??""),onChange:(a,n)=>r({build:k(n.value)}),style:{width:"84px"}})}),e.jsx(s,{label:"Revision",children:e.jsx(y,{type:"number",value:String(l.revision??""),onChange:(a,n)=>r({revision:k(n.value)}),style:{width:"84px"}})})]});case"DeviceTypeRule":return e.jsx(s,{label:"Device type",children:e.jsxs(h,{value:l.type,onChange:(a,n)=>r({type:n.value}),children:[e.jsx("option",{value:"None",children:"None"}),e.jsx("option",{value:"Phone",children:"Phone"}),e.jsx("option",{value:"Tablet",children:"Tablet"}),e.jsx("option",{value:"Web",children:"Web"}),e.jsx("option",{value:"Outlook",children:"Outlook"}),e.jsx("option",{value:"InteractionCentric",children:"InteractionCentric"})]})});case"EntityPrivilegeRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Entity (optional)",children:e.jsx(y,{value:l.entityName??"",onChange:(a,n)=>r({entityName:n.value||void 0})})}),e.jsx(s,{label:"Applies To",children:e.jsxs(h,{value:l.appliesTo??"",onChange:(a,n)=>r({appliesTo:n.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"PrimaryEntity",children:"PrimaryEntity"}),e.jsx("option",{value:"SelectedEntity",children:"SelectedEntity"})]})}),e.jsx(s,{label:"Privilege",children:e.jsx(h,{value:l.privilegeType,onChange:(a,n)=>r({privilegeType:n.value}),children:G.map(a=>e.jsx("option",{value:a,children:a},a))})}),e.jsx(s,{label:"Depth",children:e.jsx(h,{value:l.privilegeDepth,onChange:(a,n)=>r({privilegeDepth:n.value}),children:W.map(a=>e.jsx("option",{value:a,children:a},a))})})]});case"EntityPropertyRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Entity (optional)",children:e.jsx(y,{value:l.entityName??"",onChange:(a,n)=>r({entityName:n.value||void 0})})}),e.jsx(s,{label:"Applies To",children:e.jsxs(h,{value:l.appliesTo??"",onChange:(a,n)=>r({appliesTo:n.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"PrimaryEntity",children:"PrimaryEntity"}),e.jsx("option",{value:"SelectedEntity",children:"SelectedEntity"})]})}),e.jsx(s,{label:"Property",children:e.jsx(h,{value:l.propertyName,onChange:(a,n)=>r({propertyName:n.value}),children:Ee.map(a=>e.jsx("option",{value:a,children:a},a))})}),e.jsx(w,{label:"Property value",checked:l.propertyValue,onChange:(a,n)=>r({propertyValue:n.checked===!0})})]});case"ValueRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Field",children:e.jsx(y,{value:l.field,onChange:(a,n)=>r({field:n.value})})}),e.jsx(s,{label:"Value",children:e.jsx(y,{value:l.value,onChange:(a,n)=>r({value:n.value})})})]});case"OrRule":{const a=g=>t({...l,groups:g.filter(b=>b.length>0)}),n=(g,b)=>e.jsxs(Q,{open:f===g,onOpenChange:(v,u)=>R(u.open?g:null),children:[e.jsx(Y,{children:e.jsx(O,{icon:e.jsx(K,{}),appearance:"secondary",size:"small",children:b})}),e.jsx(J,{className:c.pickerSurface,children:e.jsx(ee,{container:p,insideOr:!0,onSelect:v=>{a(g==="new"?[...l.groups,[v]]:l.groups.map((u,S)=>S===g?[...u,v]:u)),R(null)}})})]});return e.jsxs("div",{className:c.nested,children:[l.groups.map((g,b)=>e.jsxs("div",{className:c.nested,children:[e.jsxs(E,{size:100,weight:"semibold",children:[b===0?"Either":"Or",g.length>1?" (all of)":""]}),g.map((v,u)=>e.jsx(le,{step:v,container:p,onChange:S=>a(l.groups.map((T,D)=>D===b?T.map((P,M)=>M===u?S:P):T)),onRemove:()=>a(l.groups.map((S,T)=>T===b?S.filter((D,P)=>P!==u):S))},`${b}-${u}-${v.kind}`)),e.jsx("div",{className:c.nestedToolbar,children:n(b,"And…")})]},b)),e.jsxs("div",{className:c.nestedToolbar,children:[n("new","Add Or branch"),e.jsx(E,{size:100,style:{color:o.colorNeutralForeground3},children:"An OrRule needs at least two branches."})]})]})}case"FeatureControlRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Feature control bit",children:e.jsx(y,{value:l.featureControlBit,onChange:(a,n)=>r({featureControlBit:n.value})})}),e.jsx(w,{label:"Expected value",checked:l.expectedValue,onChange:(a,n)=>r({expectedValue:n.checked===!0})})]});case"RawRule":return e.jsxs(e.Fragment,{children:[e.jsx(E,{size:100,style:{color:o.colorNeutralForeground3},children:"Command Bar Studio doesn't edit this rule; it is kept exactly as loaded."}),e.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"11px"},children:l.xml})]});case"SkuRule":return e.jsx(s,{label:"SKU",children:e.jsxs(h,{value:l.sku,onChange:(a,n)=>r({sku:n.value}),children:[e.jsx("option",{value:"Online",children:"Online"}),e.jsx("option",{value:"OnPremise",children:"OnPremise"}),e.jsx("option",{value:"Spla",children:"Spla"})]})});case"OrganizationSettingRule":return e.jsx(s,{label:"Setting",children:e.jsx(h,{value:l.setting,onChange:(a,n)=>r({setting:n.value}),children:["IsSharepointEnabled","IsSOPIntegrationEnabled","IsFiscalCalendarDefined","IsReadFormModeDefined","IsBPFEntityCustomizationFeatureEnabled"].map(a=>e.jsx("option",{value:a,children:a},a))})});case"MiscellaneousPrivilegeRule":return e.jsxs("div",{className:c.row,children:[e.jsxs(s,{label:"Privilege name",children:[e.jsx(y,{value:l.privilegeName,onChange:(a,n)=>r({privilegeName:n.value}),placeholder:"ExportToExcel",list:"misc-privilege-suggestions"}),e.jsx("datalist",{id:"misc-privilege-suggestions",children:Te.map(a=>e.jsx("option",{value:a},a))})]}),e.jsx(s,{label:"Depth (optional)",children:e.jsxs(h,{value:l.privilegeDepth??"",onChange:(a,n)=>r({privilegeDepth:n.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),W.map(a=>e.jsx("option",{value:a,children:a},a))]})})]});case"OptionSetRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Option set",children:e.jsx(y,{value:l.optionSet,onChange:(a,n)=>r({optionSet:n.value})})}),e.jsx(s,{label:"State code",children:e.jsx(y,{value:l.stateCode,onChange:(a,n)=>r({stateCode:n.value})})}),e.jsx(s,{label:"Object type code",children:e.jsx(y,{value:l.objectTypeCode,onChange:(a,n)=>r({objectTypeCode:n.value})})})]});case"OutlookItemTrackingRule":return e.jsxs("div",{className:c.row,children:[e.jsx(w,{label:"Tracked in CRM",checked:l.trackedInCrm,onChange:(a,n)=>r({trackedInCrm:n.checked===!0})}),e.jsx(s,{label:"Applies To",children:e.jsx(h,{value:l.appliesTo??"PrimaryEntity",onChange:(a,n)=>r({appliesTo:n.value}),children:e.jsx("option",{value:"PrimaryEntity",children:"PrimaryEntity"})})})]});case"OutlookRenderTypeRule":return e.jsx(s,{label:"Render type",children:e.jsxs(h,{value:l.type,onChange:(a,n)=>r({type:n.value}),children:[e.jsx("option",{value:"Web",children:"Web"}),e.jsx("option",{value:"Outlook",children:"Outlook"})]})});case"OutlookVersionRule":return e.jsx(s,{label:"Outlook version",children:e.jsxs(h,{value:l.version,onChange:(a,n)=>r({version:n.value}),children:[e.jsx("option",{value:"2003",children:"2003"}),e.jsx("option",{value:"2007",children:"2007"}),e.jsx("option",{value:"2010",children:"2010"})]})});case"PageRule":return e.jsx(s,{label:"Address pattern",children:e.jsx(y,{value:l.address,onChange:(a,n)=>r({address:n.value}),placeholder:"main.aspx"})});case"RecordPrivilegeRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Privilege",children:e.jsx(h,{value:l.privilegeType,onChange:(a,n)=>r({privilegeType:n.value}),children:G.map(a=>e.jsx("option",{value:a,children:a},a))})}),e.jsx(s,{label:"Applies To",children:e.jsxs(h,{value:l.appliesTo??"",onChange:(a,n)=>r({appliesTo:n.value||void 0}),children:[e.jsx("option",{value:"",children:"Default"}),e.jsx("option",{value:"PrimaryEntity",children:"PrimaryEntity"})]})})]});case"RelationshipTypeRule":return e.jsxs("div",{className:c.row,children:[e.jsx(s,{label:"Applies To",children:e.jsx(h,{value:l.appliesTo,disabled:!0,children:e.jsx("option",{value:"SelectedEntity",children:"SelectedEntity"})})}),e.jsx(s,{label:"Relationship type",children:e.jsxs(h,{value:l.relationshipType??"",onChange:(a,n)=>r({relationshipType:n.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"OneToMany",children:"OneToMany"}),e.jsx("option",{value:"ManyToMany",children:"ManyToMany"}),e.jsx("option",{value:"NoRelationship",children:"NoRelationship"})]})}),e.jsx(w,{label:"Allow custom relationship",checked:l.allowCustomRelationship===!0,onChange:(a,n)=>r({allowCustomRelationship:n.checked===!0})}),e.jsx(w,{label:"Allow system relationship",checked:l.allowSystemRelationship===!0,onChange:(a,n)=>r({allowSystemRelationship:n.checked===!0})})]});default:return e.jsxs(E,{size:200,italic:!0,style:{color:o.colorNeutralForeground3},children:[l.kind," — no additional parameters"]})}};return e.jsxs("div",{className:c.step,role:"listitem",children:[e.jsxs("div",{className:c.header,children:[e.jsx(q,{appearance:"outline",size:"small",className:c.kindBadge,children:V[l.kind]??l.kind}),e.jsx(O,{appearance:"subtle",icon:e.jsx(X,{}),size:"small",onClick:d,"aria-label":`Remove ${l.kind} step`})]}),e.jsxs("div",{className:c.fields,children:[A(),e.jsx("div",{className:c.row,children:x&&e.jsxs(e.Fragment,{children:[e.jsx(s,{label:"Default",title:"Value the rule returns when it cannot be evaluated.",children:e.jsxs(h,{value:C===void 0?"":String(C),onChange:(a,n)=>r({default:n.value===""?void 0:n.value==="true"}),children:[e.jsx("option",{value:"",children:"(not set)"}),e.jsx("option",{value:"true",children:"true"}),e.jsx("option",{value:"false",children:"false"})]})}),e.jsx(w,{label:"Invert result",checked:m===!0,title:"Reverse the evaluated result.",onChange:(a,n)=>r({invertResult:n.checked===!0?!0:void 0})})]})})]})]})};function Ne(l){return l.length===0?"No steps defined — rule always passes.":l.map(B).join(" AND ")}function B(l){const t="invertResult"in l&&l.invertResult?"NOT ":"";switch(l.kind){case"SelectionCountRule":{const d=l.minimum!==void 0?`at least ${l.minimum}`:null,p=l.maximum!==void 0?`at most ${l.maximum}`:null,c=[d,p].filter(Boolean).join(" and "),f=l.appliesTo?` (${l.appliesTo})`:"";return`${t}Selection count is ${c}${f}`}case"EntityRule":{const d=l.entityName??"any entity",p=l.context?` in ${l.context} context`:"",c=l.appliesTo?` (${l.appliesTo})`:"";return`${t}Entity is "${d}"${p}${c}`}case"FormStateRule":return`${t}Form state is "${l.state}"`;case"CommandClientTypeRule":return`${t}Client type is "${l.type}" (${$e(l.type)})`;case"CrmClientTypeRule":return`${t}CRM client type is "${l.type}"`;case"CustomRule":return`${t}Custom rule: ${l.functionName}() from ${l.library}`;case"OrRule":return`(${l.groups.map(p=>p.length===1?B(p[0]):`(${p.map(B).join(" AND ")})`).join(" OR ")})`;case"FeatureControlRule":return`${t}Feature "${l.featureControlBit}" is ${l.expectedValue?"on":"off"}`;case"RawRule":return`${l.tagName} (kept as XML)`;case"MiscellaneousPrivilegeRule":{const d=l.privilegeDepth?` at ${l.privilegeDepth} depth`:"";return`${t}User has "${l.privilegeName}" privilege${d}`}case"EntityPrivilegeRule":{const d=l.entityName?` on "${l.entityName}"`:"",p=l.appliesTo?` (${l.appliesTo})`:"";return`${t}User has ${l.privilegeType} privilege${d} at ${l.privilegeDepth} depth${p}`}case"EntityPropertyRule":{const d=l.entityName?` for "${l.entityName}"`:"";return`${t}Entity property "${l.propertyName}" is ${l.propertyValue}${d}`}case"FormTypeRule":return`${t}Form type is "${l.type}"`;case"FormEntityContextRule":return`${t}Form entity context is "${l.entityName}"`;case"ValueRule":return`${t}Field "${l.field}" equals "${l.value}"`;case"SkuRule":return`${t}SKU is "${l.sku}"`;case"HideForTabletExperienceRule":return`${t}Hide for tablet experience`;case"OrganizationSettingRule":return`${t}Organization setting "${l.setting}" is enabled`;case"PageRule":return`${t}Page address matches "${l.address}"`;case"RecordPrivilegeRule":{const d=l.appliesTo?` (${l.appliesTo})`:"";return`${t}User has ${l.privilegeType} privilege on current record${d}`}case"RelationshipTypeRule":{const d=l.relationshipType??"any";return`${t}Relationship type is "${d}" (${l.appliesTo})`}case"ReferencingAttributeRequiredRule":return`${t}Referencing attribute is required`;case"OutlookItemTrackingRule":return`${t}Outlook item is ${l.trackedInCrm?"":"not "}tracked in CRM`;case"OutlookRenderTypeRule":return`${t}Outlook render type is "${l.type}"`;case"OutlookVersionRule":return`${t}Outlook version is "${l.version}"`;case"CrmOfflineAccessStateRule":return`${t}CRM offline state is "${l.state}"`;case"CrmOutlookClientTypeRule":return`${t}CRM Outlook client type is "${l.type}"`;case"CrmOutlookClientVersionRule":return`${t}CRM Outlook client version is ${l.major}.${l.minor??0}+`;case"DeviceTypeRule":return`${t}Device type is "${l.type}"`;case"OptionSetRule":return`${t}Option set "${l.optionSet}" state code is "${l.stateCode}"`;default:return"Unknown rule step"}}function $e(l){switch(l){case"Modern":return"Dynamics 365 tablets";case"Refresh":return"Unified Interface / modern web";case"Legacy":return"Classic ribbon / Outlook list views";default:return l}}let Oe=0;const U=(l,t)=>Array.from({length:t},()=>`${l}#${++Oe}`);function ke(l,t){const[d,p]=I.useState(null),c=I.useMemo(()=>U(l,t.length),[l,t]),f=!!d&&d.scope===l&&d.keys.length===t.length&&(d.items===t||d.pending);d?.pending&&p({...d,items:f?t:d.items,pending:!1});const R=f?d.keys:c,x=m=>p({scope:l,items:t,pending:!0,keys:m});return{keys:R,add:()=>x([...R,...U(l,1)]),remove:m=>x(R.filter((C,r)=>r!==m)),move:(m,C)=>x(Z(R,m,C)),update:()=>x(R)}}const we=L({drawer:{width:"560px",maxWidth:"90vw"},body:{display:"flex",flexDirection:"column",gap:o.spacingVerticalS,padding:o.spacingVerticalM,overflowY:"auto"},header:{display:"flex",alignItems:"center",gap:o.spacingHorizontalS},stepsList:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS,listStyle:"none",padding:0,margin:0},summary:{padding:o.spacingVerticalS,backgroundColor:o.colorNeutralBackground3,borderRadius:o.borderRadiusMedium,fontStyle:"italic",color:o.colorNeutralForeground2,fontSize:o.fontSizeBase200},addRow:{display:"flex",gap:o.spacingHorizontalS},pickerPopover:{maxHeight:"60vh",overflowY:"auto",minWidth:"320px",padding:o.spacingVerticalM},usedBy:{color:o.colorNeutralForeground3,fontSize:o.fontSizeBase200},ruleIdRow:{display:"flex",alignItems:"flex-end",gap:o.spacingHorizontalS},ruleIdInput:{fontFamily:o.fontFamilyMonospace},error:{color:o.colorPaletteRedForeground1,fontSize:o.fontSizeBase100},sortableItem:{listStyle:"none"},sortableInner:{display:"flex",alignItems:"flex-start",gap:o.spacingHorizontalS},dragHandle:{marginTop:o.spacingVerticalS,cursor:"grab"}}),Ie=[],Le=()=>{const l=we(),t=_(i=>i.ruleEditorOpen),d=_(i=>i.ruleEditorId),p=_(i=>i.ruleEditorKind),c=_(i=>i.closeRuleEditor),f=_(i=>i.openRuleEditor),R=$(i=>i.enableRules),x=$(i=>i.displayRules),m=$(i=>i.commands),C=$(i=>i.upsertEnableRule),r=$(i=>i.upsertDisplayRule),k=$(i=>i.renameEnableRuleId),A=$(i=>i.renameDisplayRuleId),[a,n]=I.useState(!1),[g,b]=I.useState(""),v=p==="enable",u=v?R.find(i=>i.id===d):x.find(i=>i.id===d);I.useEffect(()=>{u&&b(u.id)},[u]);const S=ke(`${p}:${u?.id??""}`,u?.steps??Ie),T=S.keys,D=m.filter(i=>v?i.enableRules.includes(d??""):i.displayRules.includes(d??"")).length,P=(i,j)=>{if(!u)return;const N=[...u.steps];N[i]=j,S.update(),v?C({...u,steps:N}):r({...u,steps:N})},M=i=>{if(!u)return;const j=u.steps.filter((N,F)=>F!==i);S.remove(i),v?C({...u,steps:j}):r({...u,steps:j})},ne=i=>{if(!u)return;const j=[...u.steps,i];S.add(),v?C({...u,steps:j}):r({...u,steps:j}),n(!1)},ae=i=>{if(!u||!i.over||i.active.id===i.over.id)return;const j=T.indexOf(String(i.active.id)),N=T.indexOf(String(i.over.id));if(j<0||N<0)return;const F=Z(u.steps,j,N);S.move(j,N),v?C({...u,steps:F}):r({...u,steps:F})};if(!u)return null;const re=Ne(u.steps),ie=(v?R:x).some(i=>i.id===g.trim()&&i.id!==u.id),z=g.trim()?/\s/.test(g)?"Rule ID cannot contain whitespace.":ie?"A rule with this ID already exists.":"":"Rule ID is required.";return e.jsxs(ce,{position:"end",open:t,onOpenChange:()=>c(),className:l.drawer,children:[e.jsx(ue,{children:e.jsx(de,{action:e.jsx(O,{appearance:"subtle",icon:e.jsx(X,{}),onClick:c,"aria-label":"Close rule editor"}),children:e.jsxs("div",{className:l.header,children:[e.jsx(q,{appearance:"filled",color:v?"success":"informative",size:"small",children:v?"Enable":"Display"}),e.jsx(E,{size:400,weight:"semibold",style:{fontFamily:o.fontFamilyMonospace},children:u.id})]})})}),e.jsxs(pe,{className:l.body,children:[e.jsxs(E,{className:l.usedBy,children:["Used by ",D," command(s)"]}),e.jsxs("div",{className:l.ruleIdRow,children:[e.jsx(y,{className:l.ruleIdInput,value:g,onChange:(i,j)=>b(j.value),"aria-label":"Rule ID"}),e.jsx(O,{appearance:"secondary",size:"small",disabled:!g.trim()||!!z||g===u.id,onClick:()=>{const i=g.trim();(v?k(u.id,i):A(u.id,i))&&f(i,v?"enable":"display")},children:"Apply ID change"})]}),z&&e.jsx(E,{className:l.error,children:z}),v&&e.jsx(he,{intent:"warning",children:e.jsx(me,{children:"Enable rules have a restricted set of allowed step types. Display-only rule kinds are disabled."})}),e.jsx(H,{children:"Steps (ALL must pass)"}),e.jsx(ye,{collisionDetection:ve,onDragEnd:ae,children:e.jsx(je,{items:T,strategy:ge,children:e.jsxs("ol",{className:l.stepsList,role:"list","aria-label":"Rule steps",children:[u.steps.map((i,j)=>e.jsx(Pe,{id:T[j],styles:l,children:e.jsx(le,{step:i,onChange:N=>P(j,N),onRemove:()=>M(j),container:v?"enable":"display"})},T[j])),u.steps.length===0&&e.jsx(E,{italic:!0,style:{color:o.colorNeutralForeground3},children:"No steps yet — all buttons with this rule will be visible/enabled by default."})]})})}),e.jsxs(Q,{open:a,onOpenChange:(i,j)=>n(j.open),children:[e.jsx(Y,{children:e.jsx(O,{icon:e.jsx(K,{}),appearance:"secondary",onClick:()=>n(!0),children:"Add step"})}),e.jsx(J,{className:l.pickerPopover,children:e.jsx(ee,{onSelect:ne,container:v?"enable":"display"})})]}),e.jsx(H,{children:"Plain-English summary"}),e.jsx("div",{className:l.summary,role:"note","aria-label":"Rule summary",children:re})]})]})};function Pe({id:l,children:t,styles:d}){const{attributes:p,listeners:c,setNodeRef:f,setActivatorNodeRef:R,transform:x,transition:m}=Re({id:l});return e.jsx("li",{ref:f,className:d.sortableItem,style:{transform:be.Transform.toString(x),transition:m},children:e.jsxs("div",{className:d.sortableInner,children:[e.jsx(O,{ref:R,appearance:"subtle",size:"small",className:d.dragHandle,...p,...c,"aria-label":"Drag to reorder step",children:"Drag"}),e.jsx("div",{style:{flex:1},children:t})]})})}export{Le as RuleEditorPanel,Le as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e,h as O,co as I,cq as C,z as $}from"./fluent-icons-DUgjkNjy.js";import{a as M,R as X}from"./monaco-BIO15LCS.js";import{a as k,a8 as H,u as q}from"./index-CL8TmfXp.js";import{ai as A,aj as P,ak as U,aa as G,d as c,al as Y,b as x,t as l,a7 as R,B,F as p,S as j,I as L}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const Z=$({drawer:{width:"600px",maxWidth:"95vw"},body:{display:"flex",flexDirection:"column",gap:l.spacingHorizontalM,padding:l.spacingHorizontalM,overflowY:"auto"},stepRow:{display:"flex",flexDirection:"column",gap:l.spacingHorizontalXS,padding:l.spacingHorizontalS,border:`1px solid ${l.colorNeutralStroke2}`,borderRadius:l.borderRadiusMedium,backgroundColor:l.colorNeutralBackground2},stepHeader:{display:"flex",alignItems:"center",gap:l.spacingHorizontalS},stepFields:{display:"flex",gap:l.spacingHorizontalS,flexWrap:"wrap",alignItems:"flex-end"},sectionLabel:{color:l.colorNeutralForeground3,textTransform:"uppercase",fontSize:l.fontSizeBase100,letterSpacing:"0.5px",fontWeight:l.fontWeightSemibold},warningNote:{backgroundColor:l.colorStatusWarningBackground1,borderRadius:l.borderRadiusMedium,padding:`${l.spacingHorizontalXS} ${l.spacingHorizontalS}`,fontSize:l.fontSizeBase100}}),D=["Large","LargeLarge","LargeMedium","LargeSmall","MediumLarge","MediumMedium","MediumSmall","SmallMedium","SmallSmall","Popup"],ae=()=>{const o=Z(),b=k(a=>a.scalingEditorOpen),S=k(a=>a.closeScalingEditor),y=H(a=>a.location),u=H(a=>a.tabId),_=q(a=>a.ribbons),E=q(a=>a.setScaling),v=_[y],r=v.tabs.find(a=>a.id===u),h=u?v.scalingByTab?.[u]:void 0,[w,g]=M.useState([]),[N,m]=M.useState([]);X.useEffect(()=>{if(!(!b||!r)){if(h){g([...h.maxSizes]),m([...h.scales]);return}g([{id:`MaxSize.${r.id}.1`,groupId:r.groups[0]?.id??"",size:"Large",sequence:10}]),m([{id:`Scale.${r.id}.1`,groupId:r.groups[0]?.id??"",size:"SmallSmall",sequence:200}])}},[b,r,h]);const d=r?.groups??[],F=()=>{g(a=>[...a,{id:`MaxSize.${a.length+1}`,groupId:d[0]?.id??"",size:"Large",sequence:(a.length+1)*10}])},T=()=>{m(a=>[...a,{id:`Scale.${a.length+1}`,groupId:d[0]?.id??"",size:"SmallSmall",sequence:200+(a.length+1)*10}])},z=(a,i)=>{g(s=>s.map((n,t)=>t===a?{...n,...i}:n))},f=(a,i)=>{m(s=>s.map((n,t)=>t===a?{...n,...i}:n))},W=()=>{E(y,u,{tabId:u,maxSizes:w,scales:N}),S()};return e.jsxs(A,{className:o.drawer,open:b,position:"end",onOpenChange:(a,i)=>!i.open&&S(),children:[e.jsx(P,{children:e.jsx(U,{action:e.jsx(c,{appearance:"subtle",icon:e.jsx(O,{}),onClick:S,"aria-label":"Close"}),children:e.jsx(G,{children:"Scaling Editor"})})}),e.jsx(Y,{children:e.jsxs("div",{className:o.body,children:[e.jsxs("div",{className:o.warningNote,children:["⚠ ",e.jsx("strong",{children:"Scaling applies ONLY to the Classic ribbon"})," — forms NOT updated to Unified Interface, and Dynamics 365 for Outlook list views. The modern command bar (Unified Interface) ignores all MaxSize and Scale definitions entirely."]}),r&&e.jsxs(x,{size:200,style:{color:l.colorNeutralForeground3},children:["Tab: ",e.jsx("strong",{children:r.label})," (",r.id,")"]}),e.jsx(R,{}),e.jsxs("div",{children:[e.jsx(x,{className:o.sectionLabel,children:"MaxSize (largest size, shown first)"}),e.jsx(x,{size:100,style:{color:l.colorNeutralForeground3,display:"block",marginBottom:l.spacingHorizontalS},children:"Sequence numbers must be lower than all Scale step sequence numbers."}),w.map((a,i)=>e.jsxs("div",{className:o.stepRow,style:{marginBottom:l.spacingHorizontalXS},children:[e.jsxs("div",{className:o.stepHeader,children:[e.jsxs(B,{appearance:"tint",color:"brand",size:"small",children:["MaxSize ",i+1]}),e.jsx("div",{style:{flex:1}}),e.jsx(c,{appearance:"subtle",size:"small",icon:e.jsx(I,{}),onClick:()=>g(s=>s.filter((n,t)=>t!==i))})]}),e.jsxs("div",{className:o.stepFields,children:[e.jsx(p,{label:"Group",style:{minWidth:"160px"},children:e.jsxs(j,{size:"small",value:a.groupId,onChange:(s,n)=>z(i,{groupId:n.value}),children:[d.length===0&&e.jsx("option",{value:"",children:"— no groups —"}),d.map(s=>e.jsx("option",{value:s.id,children:s.label||s.id},s.id))]})}),e.jsx(p,{label:"Size",style:{minWidth:"140px"},children:e.jsx(j,{size:"small",value:a.size,onChange:(s,n)=>z(i,{size:n.value}),children:D.map(s=>e.jsx("option",{value:s,children:s},s))})}),e.jsx(p,{label:"Sequence",style:{width:"80px"},children:e.jsx(L,{size:"small",type:"number",value:String(a.sequence),onChange:(s,n)=>z(i,{sequence:parseInt(n.value,10)||0})})})]})]},i)),e.jsx(c,{appearance:"subtle",size:"small",icon:e.jsx(C,{}),onClick:F,children:"Add MaxSize"})]}),e.jsx(R,{}),e.jsxs("div",{children:[e.jsx(x,{className:o.sectionLabel,children:"Scale steps (collapse order — top-down)"}),e.jsx(x,{size:100,style:{color:l.colorNeutralForeground3,display:"block",marginBottom:l.spacingHorizontalS},children:"Scale elements are applied in document order (top-down when shrinking, bottom-up when growing). Sequence numbers must be higher than all MaxSize sequence numbers."}),N.map((a,i)=>e.jsxs("div",{className:o.stepRow,style:{marginBottom:l.spacingHorizontalXS},children:[e.jsxs("div",{className:o.stepHeader,children:[e.jsxs(B,{appearance:"tint",color:"informative",size:"small",children:["Scale ",i+1]}),e.jsx("div",{style:{flex:1}}),e.jsx(c,{appearance:"subtle",size:"small",icon:e.jsx(I,{}),onClick:()=>m(s=>s.filter((n,t)=>t!==i))})]}),e.jsxs("div",{className:o.stepFields,children:[e.jsx(p,{label:"Group",style:{minWidth:"160px"},children:e.jsxs(j,{size:"small",value:a.groupId,onChange:(s,n)=>f(i,{groupId:n.value}),children:[d.length===0&&e.jsx("option",{value:"",children:"— no groups —"}),d.map(s=>e.jsx("option",{value:s.id,children:s.label||s.id},s.id))]})}),e.jsx(p,{label:"Size",style:{minWidth:"140px"},children:e.jsx(j,{size:"small",value:a.size,onChange:(s,n)=>f(i,{size:n.value}),children:D.map(s=>e.jsx("option",{value:s,children:s},s))})}),e.jsx(p,{label:"Sequence",style:{width:"80px"},children:e.jsx(L,{size:"small",type:"number",value:String(a.sequence),onChange:(s,n)=>f(i,{sequence:parseInt(n.value,10)||0})})})]})]},i)),e.jsx(c,{appearance:"subtle",size:"small",icon:e.jsx(C,{}),onClick:T,children:"Add Scale step"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:l.spacingHorizontalS,paddingTop:l.spacingHorizontalS},children:[e.jsx(c,{appearance:"secondary",onClick:S,children:"Cancel"}),e.jsx(c,{appearance:"primary",onClick:W,children:"Save scaling"})]})]})})]})};export{ae as ScalingEditorPanel,ae as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e,h as L,co as I,cq as T,z as V}from"./fluent-icons-DUgjkNjy.js";import{a as P,R as X}from"./monaco-BIO15LCS.js";import{a as E,a8 as w,u as F}from"./index-CL8TmfXp.js";import{ai as Y,aj as J,ak as K,aa as Q,d as c,al as Z,M as H,f as N,b as p,t as o,B as ee,F as x,I as v,S}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";function C(){return{kind:"EntityRule",appliesTo:"PrimaryEntity",context:"HomePageGrid"}}function A(){return{kind:"PageRule",address:""}}const ae=V({drawer:{width:"560px",maxWidth:"95vw"},body:{display:"flex",flexDirection:"column",gap:o.spacingHorizontalM,padding:o.spacingHorizontalM,overflowY:"auto"},ruleRow:{display:"flex",flexDirection:"column",gap:o.spacingHorizontalXS,padding:o.spacingHorizontalS,border:`1px solid ${o.colorNeutralStroke2}`,borderRadius:o.borderRadiusMedium,backgroundColor:o.colorNeutralBackground2},ruleHeader:{display:"flex",alignItems:"center",gap:o.spacingHorizontalS},stepFields:{display:"flex",gap:o.spacingHorizontalS,alignItems:"flex-end",flexWrap:"wrap"}}),re=()=>{const b=ae(),j=E(a=>a.tabDisplayRulesOpen),h=E(a=>a.closeTabDisplayRules),g=w(a=>a.location),z=w(a=>a.tabId),B=F(a=>a.ribbons),M=F(a=>a.setTabDisplayRules),i=B[g].tabs.find(a=>a.id===z),f=g==="Application",D=!!i?.commandId,[y,d]=P.useState(()=>i?.tabDisplayRules??[]),[k,u]=P.useState(null);X.useEffect(()=>{j&&(u(null),d(i?.tabDisplayRules??[]))},[j,i]);const _=()=>{d(a=>[...a,{tabCommand:i?.commandId??"",rules:[C()]}])},G=a=>{d(l=>l.filter((s,n)=>n!==a))},W=(a,l)=>{D||d(s=>s.map((n,t)=>t===a?{...n,tabCommand:l}:n))},m=(a,l,s)=>{d(n=>n.map((t,r)=>r===a?{...t,rules:t.rules.map((R,U)=>U===l?s:R)}:t))},$=a=>{d(l=>l.map((s,n)=>n===a?{...s,rules:[...s.rules,f?A():C()]}:s))},O=(a,l)=>{d(s=>s.map((n,t)=>t===a?{...n,rules:n.rules.filter((r,R)=>R!==l)}:n))},q=()=>{if(!i){u("No active tab selected.");return}for(const[a,l]of y.entries()){if(!l.tabCommand.trim()){u(`Rule ${a+1}: tabCommand is required.`);return}if(i.commandId&&l.tabCommand!==i.commandId){u(`Rule ${a+1}: tabCommand must match the tab command ID (${i.commandId}).`);return}if(!f&&l.rules.some(s=>s.kind==="PageRule")){u(`Rule ${a+1}: PageRule is only valid for Application ribbon tabs.`);return}}u(null),M(g,z,y),h()};return e.jsxs(Y,{className:b.drawer,open:j,position:"end",onOpenChange:(a,l)=>!l.open&&h(),children:[e.jsx(J,{children:e.jsx(K,{action:e.jsx(c,{appearance:"subtle",icon:e.jsx(L,{}),onClick:h,"aria-label":"Close"}),children:e.jsx(Q,{children:"Tab Display Rules"})})}),e.jsx(Z,{children:e.jsxs("div",{className:b.body,children:[k&&e.jsx(H,{intent:"error",children:e.jsx(N,{children:k})}),e.jsx(H,{intent:"info",children:e.jsx(N,{children:e.jsxs(p,{size:200,children:["Tabs are ",e.jsx("strong",{children:"hidden by default"}),". Each Tab Display Rule defines when this tab is shown. The tabCommand must match the tab's Command ID."]})})}),i&&e.jsxs("div",{children:[e.jsxs(p,{size:200,style:{color:o.colorNeutralForeground3},children:["Tab: ",e.jsx("strong",{children:i.label})," (",i.id,")"]}),i.commandId&&e.jsxs(p,{size:200,style:{color:o.colorNeutralForeground3,display:"block"},children:["Command ID:"," ",e.jsx("code",{style:{fontFamily:o.fontFamilyMonospace},children:i.commandId})]})]}),y.length===0&&e.jsx(p,{style:{color:o.colorNeutralForeground3,textAlign:"center"},children:"No display rules — this tab will be hidden."}),y.map((a,l)=>e.jsxs("div",{className:b.ruleRow,children:[e.jsxs("div",{className:b.ruleHeader,children:[e.jsxs(ee,{appearance:"outline",size:"small",children:["Rule ",l+1]}),e.jsx("div",{style:{flex:1}}),e.jsx(c,{appearance:"subtle",size:"small",icon:e.jsx(I,{}),onClick:()=>G(l),"aria-label":"Remove rule"})]}),e.jsx(x,{label:"Tab command ID",hint:"Must match Tab.commandId",children:e.jsx(v,{value:a.tabCommand,onChange:(s,n)=>W(l,n.value),disabled:D,size:"small",style:{fontFamily:o.fontFamilyMonospace}})}),e.jsx(p,{size:100,weight:"semibold",style:{color:o.colorNeutralForeground3},children:"Steps"}),a.rules.map((s,n)=>e.jsxs("div",{className:b.stepFields,children:[e.jsx(x,{label:"Type",style:{minWidth:"140px"},children:e.jsxs(S,{size:"small",value:s.kind,onChange:(t,r)=>{r.value==="PageRule"?m(l,n,A()):m(l,n,C())},children:[e.jsx("option",{value:"EntityRule",children:"Entity Rule"}),f&&e.jsx("option",{value:"PageRule",children:"Page Rule"})]})}),s.kind==="EntityRule"&&e.jsxs(e.Fragment,{children:[e.jsx(x,{label:"Applies to",style:{minWidth:"130px"},children:e.jsxs(S,{size:"small",value:s.appliesTo??"PrimaryEntity",onChange:(t,r)=>m(l,n,{...s,appliesTo:r.value}),children:[e.jsx("option",{value:"PrimaryEntity",children:"Primary entity"}),e.jsx("option",{value:"SelectedEntity",children:"Selected entity"})]})}),e.jsx(x,{label:"Context",style:{minWidth:"160px"},children:e.jsxs(S,{size:"small",value:s.context??"HomePageGrid",onChange:(t,r)=>m(l,n,{...s,context:r.value}),children:[e.jsx("option",{value:"Form",children:"Form"}),e.jsx("option",{value:"HomePageGrid",children:"Home Page Grid"}),e.jsx("option",{value:"SubGridStandard",children:"SubGrid Standard"}),e.jsx("option",{value:"SubGridAssociated",children:"SubGrid Associated"})]})}),e.jsx(x,{label:"Entity (optional)",children:e.jsx(v,{size:"small",value:s.entityName??"",onChange:(t,r)=>m(l,n,{...s,entityName:r.value||void 0}),placeholder:"any"})})]}),s.kind==="PageRule"&&e.jsx(x,{label:"Address pattern",style:{flex:1},children:e.jsx(v,{size:"small",value:s.address,onChange:(t,r)=>m(l,n,{...s,address:r.value}),placeholder:"https://…"})}),e.jsx(c,{appearance:"subtle",size:"small",icon:e.jsx(I,{}),onClick:()=>O(l,n),"aria-label":"Remove step"})]},n)),e.jsx(c,{appearance:"subtle",size:"small",icon:e.jsx(T,{}),onClick:()=>$(l),children:"Add step"}),e.jsx(p,{size:100,style:{color:o.colorNeutralForeground3},children:"Info: EntityRule is valid for entity-scoped tabs. Use PageRule only for globally-scoped application ribbon tabs."})]},l)),e.jsx(c,{appearance:"subtle",icon:e.jsx(T,{}),onClick:_,children:"Add display rule"}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:o.spacingHorizontalS,paddingTop:o.spacingHorizontalS},children:[e.jsx(c,{appearance:"secondary",onClick:h,children:"Cancel"}),e.jsx(c,{appearance:"primary",onClick:q,children:"Save rules"})]})]})})]})};export{re as TabDisplayRulesPanel,re as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{y as e,h as D,co as M,cq as L,z as $}from"./fluent-icons-DUgjkNjy.js";import{a as n,R as A}from"./monaco-BIO15LCS.js";import{a as k}from"./index-CL8TmfXp.js";import{D as F,i as I,k as _,j as X,aa as T,d as c,l as H,F as u,I as j,a1 as O,b as i,t as l,S as V,m as E}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const q=$({surface:{width:"720px",maxWidth:"95vw",maxHeight:"84vh",height:"84vh"},body:{display:"flex",flexDirection:"column",gap:l.spacingHorizontalM,overflowY:"auto"},paramRow:{display:"flex",alignItems:"flex-end",gap:l.spacingHorizontalS},urlPreview:{fontFamily:l.fontFamilyMonospace,fontSize:l.fontSizeBase200,backgroundColor:l.colorNeutralBackground3,padding:`${l.spacingVerticalXS} ${l.spacingHorizontalS}`,borderRadius:l.borderRadiusMedium,wordBreak:"break-all",border:`1px solid ${l.colorNeutralStroke2}`},passParamsTable:{display:"grid",gridTemplateColumns:"120px 1fr",gap:`${l.spacingVerticalXS} ${l.spacingHorizontalS}`,fontSize:l.fontSizeBase200},warnNote:{backgroundColor:l.colorStatusWarningBackground1,borderRadius:l.borderRadiusMedium,padding:`${l.spacingVerticalXS} ${l.spacingHorizontalS}`,fontSize:l.fontSizeBase100}}),f=[{key:"typename",desc:"Logical name of the table"},{key:"type",desc:"Entity type code (integer — may vary between orgs)"},{key:"id",desc:"GUID of the primary record"},{key:"orgname",desc:"Unique organization name"},{key:"userlcid",desc:"User's language LCID"},{key:"orglcid",desc:"Organization's base language LCID"}],W=[{label:"New tab (Navigate)",value:"0"},{label:"Dialog",value:"1"},{label:"Popup",value:"2"}],Z=()=>{const r=q(),S=k(a=>a.urlComposerOpen),d=k(a=>a.closeUrlComposer),[t,z]=n.useState("https://"),[m,C]=n.useState(!1),[w,R]=n.useState("0"),[h,g]=n.useState([]),x=n.useMemo(()=>{const a=[...h].filter(s=>s.key.trim()).map(s=>`${encodeURIComponent(s.key)}={${s.value||s.key}}`);return m&&f.forEach(s=>{a.push(`${s.key}={${s.key}}`)}),a.length>0?`${t}?${a.join("&")}`:t},[t,m,h]),U=n.useMemo(()=>x.replace(/&/g,"&"),[x]),N=()=>{g(a=>[...a,{key:"",value:""}])},P=a=>{g(s=>s.filter((p,o)=>o!==a))},b=(a,s,p)=>{g(o=>o.map((v,B)=>B===a?{...v,[s]:p}:v))},y=t.startsWith("https://");return e.jsx(F,{open:S,onOpenChange:(a,s)=>!s.open&&d(),children:e.jsx(I,{className:r.surface,children:e.jsxs(_,{style:{height:"100%"},children:[e.jsx(X,{action:e.jsx(c,{appearance:"subtle",icon:e.jsx(D,{}),onClick:d,"aria-label":"Close"}),children:e.jsx(T,{children:"URL Action Composer"})}),e.jsxs(H,{className:r.body,children:[e.jsx(u,{label:"Base URL",required:!0,validationState:y?"none":"error",validationMessage:y?void 0:"URL must start with https://",children:e.jsx(j,{value:t,onChange:(a,s)=>z(s.value),placeholder:"https://contoso.com/page"})}),e.jsxs("div",{className:r.warnNote,children:["⚠ Ampersands in URLs must be escaped as ",e.jsx("code",{children:"&"})," in XML. CBS handles this automatically when generating XML."]}),e.jsx(O,{label:"PassParams — append standard record context parameters",checked:m,onChange:(a,s)=>C(s.checked)}),m&&e.jsxs("div",{children:[e.jsx(i,{size:200,weight:"semibold",children:"Standard PassParams:"}),e.jsx("div",{className:r.passParamsTable,children:f.map(a=>e.jsxs(A.Fragment,{children:[e.jsx("code",{style:{fontFamily:l.fontFamilyMonospace,fontSize:l.fontSizeBase200},children:a.key}),e.jsx(i,{size:100,style:{color:l.colorNeutralForeground3},children:a.desc})]},a.key))}),e.jsxs(i,{size:100,style:{color:l.colorStatusWarningForeground1,marginTop:l.spacingVerticalXS,display:"block"},children:["Note: Use ",e.jsx("code",{children:"typename"})," instead of ",e.jsx("code",{children:"type"})," for reliability — type codes can differ between environments."]})]}),e.jsxs("div",{children:[e.jsx(i,{weight:"semibold",size:200,children:"Custom query parameters"}),e.jsxs(i,{size:100,style:{color:l.colorNeutralForeground3,display:"block",marginBottom:l.spacingVerticalXS},children:["Each parameter becomes a querystring key=value pair. Use CRM tokens like"," ",e.jsx("code",{children:"{id}"}),"."]}),h.map((a,s)=>e.jsxs("div",{className:r.paramRow,style:{marginBottom:l.spacingHorizontalXS},children:[e.jsx(u,{label:"Key",style:{flex:1},children:e.jsx(j,{size:"small",value:a.key,onChange:(p,o)=>b(s,"key",o.value),placeholder:"paramName"})}),e.jsx(u,{label:"Value / token",style:{flex:1},children:e.jsx(j,{size:"small",value:a.value,onChange:(p,o)=>b(s,"value",o.value),placeholder:"static value or {id}"})}),e.jsx(c,{appearance:"subtle",size:"small",icon:e.jsx(M,{}),onClick:()=>P(s),"aria-label":"Remove parameter",style:{marginBottom:"4px"}})]},s)),e.jsx(c,{appearance:"subtle",size:"small",icon:e.jsx(L,{}),onClick:N,children:"Add parameter"})]}),e.jsx(u,{label:"Open in",children:e.jsx(V,{value:w,onChange:(a,s)=>R(s.value),children:W.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})}),e.jsxs("div",{children:[e.jsx(i,{size:200,weight:"semibold",style:{display:"block",marginBottom:"4px"},children:"URL preview (tokens shown literally):"}),e.jsx("div",{className:r.urlPreview,children:x})]}),e.jsxs("div",{children:[e.jsxs(i,{size:200,weight:"semibold",style:{display:"block",marginBottom:"4px"},children:["XML-encoded URL (",e.jsx("code",{children:"&"})," → ",e.jsx("code",{children:"&"}),"):"]}),e.jsx("div",{className:r.urlPreview,children:U})]})]}),e.jsxs(E,{children:[e.jsx(c,{appearance:"secondary",onClick:d,children:"Cancel"}),e.jsx(c,{appearance:"primary",disabled:!y,onClick:d,children:"Apply URL"})]})]})})})};export{Z as UrlComposerModal,Z as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as s,h as se,E as le,bc as ae,z as oe,bo as D,cs as j,N as S}from"./fluent-icons-DUgjkNjy.js";import{a as U,W as re,l as L,au as ne,av as te,aw as _,ax as ie,w as z,E as ce,s as de,aq as ue,M as ge,h as xe}from"./index-CL8TmfXp.js";import{a as t}from"./monaco-BIO15LCS.js";import{u as pe}from"./useReplaceWebResourceConfirm-Dx7RdpEN.js";import{a0 as B,D as he,i as me,k as fe,j as je,aa as Se,d as b,l as be,I as ye,S as we,an as ve,M as G,f as P,b as i,t as a,a2 as Ce,a3 as Re,m as ke}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const Ne=oe({surface:{width:"780px",maxWidth:"95vw",height:"80vh",maxHeight:"80vh"},body:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",gap:a.spacingHorizontalS},toolbar:{display:"flex",alignItems:"center",gap:a.spacingHorizontalS,flexShrink:0},grid:{flex:1,overflow:"hidden"},gridWrap:{height:"100%"},gridRow:{display:"flex",alignItems:"center",gap:a.spacingHorizontalS,padding:`${a.spacingVerticalXS} ${a.spacingHorizontalS}`,cursor:"pointer",borderRadius:a.borderRadiusMedium,":hover":{backgroundColor:a.colorNeutralBackground3}},gridRowSelected:{backgroundColor:a.colorBrandBackground2},gridHeader:{display:"flex",alignItems:"center",gap:a.spacingHorizontalS,padding:`${a.spacingVerticalXS} ${a.spacingHorizontalS}`,borderBottom:`1px solid ${a.colorNeutralStroke2}`,flexShrink:0},col1:{width:"24px",flexShrink:0},col2:{width:"32px",flexShrink:0},col3:{flex:1,overflow:"hidden"},col4:{width:"60px",flexShrink:0,textAlign:"right"},col5:{width:"100px",flexShrink:0,color:a.colorNeutralForeground3},nameCell:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},descCell:{fontSize:a.fontSizeBase100,color:a.colorNeutralForeground3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}),ze={js:s.jsx(S,{}),ts:s.jsx(S,{}),css:s.jsx(S,{}),html:s.jsx(S,{}),svg:s.jsx(j,{}),png:s.jsx(j,{}),gif:s.jsx(j,{}),jpg:s.jsx(j,{}),xml:s.jsx(D,{}),resx:s.jsx(D,{})};function y(x){return x.split(".").pop()?.toLowerCase()??""}const Be=[{label:"All types",value:"all"},{label:".js",value:"js"},{label:".html",value:"html"},{label:".svg",value:"svg"},{label:".png",value:"png"},{label:".css",value:"css"},{label:".xml",value:"xml"},{label:".resx",value:"resx"}],Me=({onSelect:x})=>{const n=Ne(),I=pe(),w=U(e=>e.webResourceBrowserOpen),u=U(e=>e.closeWebResourceBrowser),A=re(e=>e.publisherPrefix),E=t.useRef(null),[F,W]=t.useState([]),[v,p]=t.useState(!1),[H,M]=t.useState(!1),[$,g]=t.useState(null),[O,C]=t.useState(null),[R,X]=t.useState(""),[h,q]=t.useState("all"),[k,V]=t.useState(!0),[m,T]=t.useState(null),f=t.useMemo(()=>{const e=R.toLowerCase();return F.filter(l=>{const o=y(l.name),r=e===""||l.name.toLowerCase().includes(e)||(l.description??"").toLowerCase().includes(e),c=h==="all"||o===h,N=!k||l.isCustom;return r&&c&&N})},[F,R,h,k]),d=f.find(e=>e.id===m)??null,Y=[B({columnId:"type",renderHeaderCell:()=>s.jsx(i,{size:100,style:{color:a.colorNeutralForeground3},children:"Type"}),renderCell:e=>{const l=y(e.name),o=ze[l]??s.jsx(D,{});return s.jsx("div",{className:n.col2,style:{color:a.colorNeutralForeground3},children:o})}}),B({columnId:"name",renderHeaderCell:()=>s.jsx(i,{size:100,style:{color:a.colorNeutralForeground3},children:"Name"}),renderCell:e=>s.jsxs("div",{className:n.col3,children:[s.jsx("div",{className:n.nameCell,children:s.jsx(i,{style:{fontFamily:a.fontFamilyMonospace,fontSize:a.fontSizeBase200},children:e.name})}),e.description&&s.jsx("div",{className:n.descCell,children:e.description})]})}),B({columnId:"modified",renderHeaderCell:()=>s.jsx(i,{size:100,style:{color:a.colorNeutralForeground3},children:"Modified"}),renderCell:e=>s.jsx("div",{className:n.col5,children:s.jsx(i,{size:100,children:e.modifiedOn?new Date(e.modifiedOn).toLocaleDateString():"—"})})})];t.useEffect(()=>{w&&(p(!0),g(null),C(null),L().then(e=>W(e)).catch(e=>g(e instanceof Error?e.message:String(e))).finally(()=>p(!1)))},[w]);const J=async()=>{p(!0),g(null);try{W(await L())}catch(e){g(e instanceof Error?e.message:String(e))}finally{p(!1)}},K=e=>new Promise((l,o)=>{const r=new FileReader;r.onerror=()=>o(r.error??new Error("Unable to read file")),r.onload=()=>{const c=String(r.result??"");l(c.includes(",")?c.split(",")[1]??"":c)},r.readAsDataURL(e)}),Q=e=>{const l=y(e.name);return`${A||"new"}_/${l==="js"||l==="css"||l==="html"||l==="xml"?"scripts":l==="svg"||l==="png"?"icons":"webresources"}/${e.name}`},Z=async e=>{const l=xe();M(!0),C(null);try{const o=await K(e),r=y(e.name),c={html:1,css:2,js:3,xml:4,png:5,jpg:6,gif:7,xsl:9,ico:10,svg:11,resx:12}[r]??4,N=await de(Q(e),o,c,{displayName:e.name,guard:l,onExisting:I.onExisting});await J(),C(N.solutionWarning??null)}catch(o){if(o instanceof ue)return;const r=o instanceof Error?o.message:String(o);g(r),ge.getState().logError("webresource",`Upload of ${e.name} failed: ${r}`)}finally{M(!1)}},ee=()=>{d&&(z.invoke(d),x?.(d),u())};return s.jsxs(s.Fragment,{children:[I.dialog,s.jsx(he,{open:w,onOpenChange:(e,l)=>{l.open||(z.clear(),u())},children:s.jsx(me,{className:n.surface,children:s.jsxs(fe,{style:{height:"100%"},children:[s.jsx(je,{action:s.jsx(b,{appearance:"subtle",icon:s.jsx(se,{}),onClick:u,"aria-label":"Close"}),children:s.jsx(Se,{children:"Web Resource Browser"})}),s.jsxs(be,{className:n.body,children:[s.jsx("input",{ref:E,type:"file",accept:".js,.html,.svg,.png,.css,.xml,.resx,.jpg,.gif,.ico,.xsl",style:{display:"none"},onChange:e=>{const l=e.target.files?.[0];e.currentTarget.value="",l&&Z(l)}}),s.jsxs("div",{className:n.toolbar,children:[s.jsx(ye,{contentBefore:s.jsx(le,{}),placeholder:"Search by name…",value:R,onChange:(e,l)=>X(l.value),size:"small",style:{flex:1}}),s.jsx(we,{size:"small",value:h,onChange:(e,l)=>q(l.value),style:{width:"100px"},children:Be.map(e=>s.jsx("option",{value:e.value,children:e.label},e.value))}),s.jsx(ve,{label:"Custom only",checked:k,onChange:(e,l)=>V(l.checked===!0)})]}),$&&s.jsx(G,{intent:"error",children:s.jsx(P,{children:$})}),O&&s.jsx(G,{intent:"warning",children:s.jsx(P,{children:O})}),s.jsxs("div",{className:n.grid,children:[v&&s.jsx(i,{style:{color:a.colorNeutralForeground3,padding:a.spacingHorizontalM},children:"Loading web resources…"}),!v&&f.length===0&&s.jsx(i,{style:{color:a.colorNeutralForeground3,padding:a.spacingHorizontalM,textAlign:"center"},children:"No web resources found."}),!v&&f.length>0&&s.jsxs(ne,{className:n.gridWrap,items:f,columns:Y,getRowId:e=>e.id,focusMode:"composite",selectionMode:"single",subtleSelection:!0,selectedItems:m?new Set([m]):new Set,onSelectionChange:(e,l)=>{const o=[...l.selectedItems][0];T(o??null)},children:[s.jsx(te,{children:s.jsx(_,{children:({renderHeaderCell:e})=>s.jsx(Ce,{children:e()})})}),s.jsx(ie,{itemSize:56,height:360,listProps:{width:"100%"},children:({item:e,rowId:l},o)=>s.jsx(_,{style:o,className:`${n.gridRow} ${e.id===m?n.gridRowSelected:""}`,onDoubleClick:()=>{T(e.id),z.invoke(e),x?.(e),u()},children:({renderCell:r})=>s.jsx(Re,{children:r(e)})},l)})]})]}),d&&s.jsx("div",{style:{padding:a.spacingHorizontalXS,backgroundColor:a.colorNeutralBackground3,borderRadius:a.borderRadiusMedium,flexShrink:0},children:s.jsxs(i,{size:200,style:{fontFamily:a.fontFamilyMonospace},children:["$webresource:",d.name]})})]}),s.jsxs(ke,{fluid:!0,children:[s.jsx(b,{appearance:"subtle",icon:s.jsx(ae,{}),disabled:H,onClick:()=>E.current?.click(),children:H?"Uploading…":"Upload"}),s.jsx(ce,{prefix:"Uploads to"}),s.jsx("div",{style:{flex:1}}),s.jsx(b,{appearance:"secondary",onClick:u,children:"Cancel"}),s.jsx(b,{appearance:"primary",disabled:!d,onClick:ee,children:"Select"})]})]})})})]})};export{Me as WebResourceBrowser,Me as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{y as r,Z as A,h as $,cj as E,be as B,cA as X,bc as O,z as P}from"./fluent-icons-DUgjkNjy.js";import{a as m}from"./monaco-BIO15LCS.js";import{u as C,a as k,l as F,g as H}from"./index-CL8TmfXp.js";import{M as U}from"./MonacoEditor-CBUJNFgC.js";import{ai as V,aj as z,ak as G,t as d,d as W,al as _,M as K,f as Z,ac as Q,ad as q,am as N}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const J=["Add","AddCircle","Alert","AppFolder","Archive","ArrowClockwise","ArrowCounterclockwise","ArrowDown","ArrowExport","ArrowImport","ArrowLeft","ArrowRight","ArrowSync","ArrowUp","Attach","Beaker","Bookmark","Bug","Building","Calculator","CalendarLtr","CalendarMonth","Call","Camera","Cart","Chart","Checkmark","CheckmarkCircle","Circle","ClipboardTask","Clock","Cloud","Code","CodeBlock","Comment","ContactCard","Copy","CreditCard","Crown","Cube","CursorClick","DataBarVertical","Delete","Diamond","Document","DocumentCopy","DocumentEdit","DocumentText","Download","Edit","Emoji","ErrorCircle","Eye","EyeOff","Filter","Flag","Flow","FolderOpen","Globe","Grid","Group","Heart","Home","Image","Info","Key","Library","Link","List","Location","Lock","Mail","Map","MegaphoneLoud","Money","MoreCircle","MoreHorizontal","Note","NoteEdit","NumberCircle1","Open","Organization","Pause","People","PeopleCommunity","Person","PersonAdd","PersonSearch","Phone","Play","Plug","Print","Question","Refresh","Rename","Save","Search","Send","Settings","Share","Shield","ShoppingBag","Sparkle","Star","StarEmphasis","Stop","Table","Tag","TaskList","TextBulletList","TextDescription","ThumbLike","Timer","ToggleLeft","ToggleRight","Tool","Translate","Umbrella","Unlock","Upload","Video","Warning","Wrench"];function I(t,p){const g=[];return g.push(t.languages.registerCompletionItemProvider("xml",{triggerCharacters:[":","$"],provideCompletionItems(l,e){const a=l.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column});if(!a.includes("$LocLabels:"))return{suggestions:[]};const b=a.lastIndexOf("$LocLabels:")+11,s=a.slice(b),i={startLineNumber:e.lineNumber,startColumn:e.column-s.length,endLineNumber:e.lineNumber,endColumn:e.column};return{suggestions:C.getState().locLabels.map(u=>({label:u.id,kind:t.languages.CompletionItemKind.Reference,insertText:u.id,range:i,detail:"LocLabel reference"}))}}})),g.push(t.languages.registerCompletionItemProvider("xml",{triggerCharacters:[":","$"],provideCompletionItems(l,e){const a=l.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column});if(!a.includes("$webresource:"))return{suggestions:[]};const b=a.lastIndexOf("$webresource:")+13,s=a.slice(b),i={startLineNumber:e.lineNumber,startColumn:e.column-s.length,endLineNumber:e.lineNumber,endColumn:e.column};return{suggestions:p().map(u=>({label:u,kind:t.languages.CompletionItemKind.File,insertText:u,range:i,detail:"Web resource"}))}}})),g.push(t.languages.registerCompletionItemProvider("xml",{triggerCharacters:['"'],provideCompletionItems(l,e){const a=l.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column});if(!/Command\s*=\s*"[^"]*$/.test(a))return{suggestions:[]};const s=a.match(/Command\s*=\s*"([^"]*)$/)?.[1]??"",i={startLineNumber:e.lineNumber,startColumn:e.column-s.length,endLineNumber:e.lineNumber,endColumn:e.column};return{suggestions:C.getState().commands.map(u=>({label:u.id,kind:t.languages.CompletionItemKind.Function,insertText:u.id,range:i,detail:"CommandDefinition"}))}}})),g.push(t.languages.registerCompletionItemProvider("xml",{triggerCharacters:['"'],provideCompletionItems(l,e){const a=l.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column});if(!/ModernImage\s*=\s*"[^"]*$/.test(a))return{suggestions:[]};const s=a.match(/ModernImage\s*=\s*"([^"]*)$/)?.[1]??"",i={startLineNumber:e.lineNumber,startColumn:e.column-s.length,endLineNumber:e.lineNumber,endColumn:e.column};return{suggestions:J.map(c=>({label:c,kind:t.languages.CompletionItemKind.Color,insertText:c,range:i,detail:"Fluent icon (ModernImage)",documentation:`Renders the ${c}_20_Regular Fluent icon`}))}}})),g}function S(t){t.forEach(p=>p.dispose())}const Y=P({drawer:{width:"960px",maxWidth:"90vw"},body:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",padding:0},infoBar:{flexShrink:0,margin:`${d.spacingVerticalS} ${d.spacingHorizontalM}`},tabRow:{flexShrink:0,padding:`0 ${d.spacingHorizontalM}`},toolbar:{flexShrink:0,display:"flex",alignItems:"center",gap:d.spacingHorizontalS,padding:`${d.spacingVerticalXS} ${d.spacingHorizontalM}`,borderTop:`1px solid ${d.colorNeutralStroke2}`,borderBottom:`1px solid ${d.colorNeutralStroke2}`},editorContainer:{flex:1,minHeight:0,overflow:"hidden"}}),ee=[{label:"Home Grid",value:"HomepageGrid"},{label:"Sub Grid",value:"SubGrid"},{label:"Form",value:"Form"},{label:"Application",value:"Application"}],ie=()=>{const t=Y(),p=k(n=>n.xmlDrawerOpen),g=k(n=>n.closeXmlDrawer),l=C(n=>n.ribbons),e=C(n=>n.baseline),a=C(n=>n.commands),b=C(n=>n.displayRules),s=C(n=>n.enableRules),i=C(n=>n.locLabels),f=k(n=>n.openImportXml),[c,u]=m.useState("HomepageGrid"),[x,y]=m.useState([]),v=m.useRef(null),w=m.useRef(null),h=m.useRef([]);m.useEffect(()=>{p&&F().then(n=>y(n.map(o=>o.name))).catch(()=>y([]))},[p]),m.useEffect(()=>()=>{S(h.current),h.current=[]},[]);const D=m.useCallback((n,o)=>{v.current=n,w.current=o,S(h.current),h.current=I(o,()=>x)},[x]);m.useEffect(()=>{w.current&&(S(h.current),h.current=I(w.current,()=>x))},[x]);const T=()=>{v.current?.getAction("editor.action.formatDocument")?.run()},L=m.useCallback(n=>{try{return`<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
${H({location:n,current:l[n],baseline:e[n],commands:a,displayRules:b,enableRules:s,locLabels:i,entityLogicalName:l[n].entityLogicalName})}`}catch(o){return`<!-- Error generating XML: ${String(o)} -->`}},[l,e,a,b,s,i])(c),j=()=>{navigator.clipboard.writeText(L)},M=()=>{const n=new Blob([L],{type:"application/xml"}),o=URL.createObjectURL(n),R=document.createElement("a");R.href=o,R.download=`RibbonDiffXml_${c}.xml`,R.click(),URL.revokeObjectURL(o)};return r.jsxs(V,{position:"end",open:p,onOpenChange:()=>g(),className:t.drawer,children:[r.jsx(z,{children:r.jsxs(G,{action:r.jsx(W,{appearance:"subtle",icon:r.jsx($,{}),onClick:g,"aria-label":"Close XML drawer"}),children:[r.jsx(A,{style:{marginRight:d.spacingHorizontalS}}),"RibbonDiffXml"]})}),r.jsxs(_,{className:t.body,children:[r.jsx(K,{className:t.infoBar,intent:"info",children:r.jsxs(Z,{children:["This is the ",r.jsx("strong",{children:"RibbonDiffXml"})," that will be packaged into your solution ZIP and imported into Dataverse. It contains only the delta (your changes), not the full ribbon."]})}),r.jsx("div",{className:t.tabRow,children:r.jsx(Q,{selectedValue:c,onTabSelect:(n,o)=>u(o.value),children:ee.map(n=>r.jsx(q,{value:n.value,children:n.label},n.value))})}),r.jsxs("div",{className:t.toolbar,children:[r.jsx(N,{icon:r.jsx(E,{}),onClick:j,children:"Copy"}),r.jsx(N,{icon:r.jsx(B,{}),onClick:M,children:"Download"}),r.jsx(N,{icon:r.jsx(X,{}),onClick:T,children:"Format XML"}),r.jsx(N,{icon:r.jsx(O,{}),onClick:()=>f(L),children:"Import this XML"})]}),r.jsx("div",{className:t.editorContainer,children:r.jsx(U,{language:"xml",value:L,readOnly:!0,height:"100%",onMount:D})})]})]})};export{ie as XmlDrawer,ie as default};
|
|
Binary file
|