@mohsinonxrm/pptb-commandbar-studio 0.7.0 → 0.8.0
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 +189 -0
- package/README.md +13 -10
- package/SECURITY.md +9 -8
- package/dist/assets/BulkPublishModal-mJ41AWew.js +36 -0
- package/dist/assets/CommandEditorPanel-BiP1kPHY.js +1 -0
- package/dist/assets/CommandPalette-q51_0qRZ.js +1 -0
- package/dist/assets/{ConflictDrawer-DAQi31Y8.js → ConflictDrawer-CdWv_PbN.js} +1 -1
- package/dist/assets/{DiffViewer-DVIsuwXy.js → DiffViewer-BQP5f73U.js} +1 -1
- package/dist/assets/HideInsteadOfDeleteModal-C9r6ah5p.js +1 -0
- package/dist/assets/IconPickerModal-B81Tnf5i.js +1 -0
- package/dist/assets/{ImportXmlModal-2-0E4Ib_.js → ImportXmlModal-C0cMaS59.js} +1 -1
- package/dist/assets/LocalizationEditor-DniDtrZV.js +1 -0
- package/dist/assets/{MonacoEditor-DGzdcWNE.js → MonacoEditor-uzfuRCpJ.js} +1 -1
- package/dist/assets/{NewButtonModal-CKKbFpLd.js → NewButtonModal-BXpX1Ld5.js} +1 -1
- package/dist/assets/{NewGroupModal-BpXuxZKo.js → NewGroupModal-Bh7lXq52.js} +1 -1
- package/dist/assets/{NewTabModal-CoBSto1f.js → NewTabModal-Pntdk3in.js} +1 -1
- package/dist/assets/RuleEditorPanel-BUGKgc0N.js +1 -0
- package/dist/assets/{ScalingEditorPanel-L_j0ox4f.js → ScalingEditorPanel-p3-Yw3CO.js} +1 -1
- package/dist/assets/TabDisplayRulesPanel-CSNshwaw.js +1 -0
- package/dist/assets/{UrlComposerModal-BhcG5L1S.js → UrlComposerModal-WKSTwUcW.js} +1 -1
- package/dist/assets/WebResourceBrowser-BK-gVU2g.js +1 -0
- package/dist/assets/XmlDrawer-CQJElnD1.js +2 -0
- package/dist/assets/{dnd-BmqIZ1-i.js → dnd-Cq8OftAq.js} +1 -1
- package/dist/assets/fluent-icons-BqJj6rDi.js +1 -0
- package/dist/assets/{fluent-ui-Dde22_ZN.js → fluent-ui-QADO660t.js} +1 -1
- package/dist/assets/index-Di2_5czx.js +136 -0
- package/dist/assets/{useReplaceWebResourceConfirm-Mb36NTI7.js → useReplaceWebResourceConfirm-BUWBVNSC.js} +1 -1
- package/dist/assets/useStableKeys-p2OkzZWO.js +1 -0
- package/dist/assets/xmlValidator-BkeotXuB.js +3 -0
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/BulkPublishModal-B0Ecmiq1.js +0 -36
- package/dist/assets/CommandEditorPanel-FdBZ2zNj.js +0 -1
- package/dist/assets/CommandPalette-BL4yGqtx.js +0 -1
- package/dist/assets/CrmParameterEditor-CQD0gNNH.js +0 -1
- package/dist/assets/HideInsteadOfDeleteModal-BBfhx5dO.js +0 -1
- package/dist/assets/IconPickerModal-D97ew6l_.js +0 -1
- package/dist/assets/LocalizationEditor-7sYCHKMx.js +0 -1
- package/dist/assets/RuleEditorPanel-Dg2vnxrc.js +0 -1
- package/dist/assets/TabDisplayRulesPanel-W1SMJTlj.js +0 -1
- package/dist/assets/WebResourceBrowser-CQemLOXD.js +0 -1
- package/dist/assets/XmlDrawer-BOOdH0HN.js +0 -2
- package/dist/assets/fluent-icons-DUgjkNjy.js +0 -1
- package/dist/assets/index-DUEHURiA.js +0 -136
- package/dist/assets/xmlValidator-BB2o3QUU.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{y as e}from"./fluent-icons-
|
|
1
|
+
import{y as e}from"./fluent-icons-BqJj6rDi.js";import{a as r}from"./monaco-BIO15LCS.js";import{Z as u,E as g}from"./index-Di2_5czx.js";import{D as x,i as h,k as j,j as f,l as y,t as b,b as l,m as k,d as o}from"./fluent-ui-QADO660t.js";function E(){const[n,t]=r.useState(null),i=r.useRef(null),d=u(a=>a.connectionVersion),s=r.useCallback(a=>{i.current?.(a),i.current=null,t(null)},[]),p=r.useCallback(a=>new Promise(c=>{i.current?.("cancel"),i.current=c,t({name:a.name,managed:a.managed})}),[]);r.useEffect(()=>()=>s("cancel"),[d,s]);const m=e.jsx(x,{open:n!==null,onOpenChange:(a,c)=>!c.open&&s("cancel"),children:e.jsx(h,{style:{maxWidth:520},children:e.jsxs(j,{children:[e.jsx(f,{children:n?.managed?"Use the existing web resource?":"Replace the existing web resource?"}),e.jsxs(y,{style:{display:"flex",flexDirection:"column",gap:b.spacingVerticalS},children:[n?.managed?e.jsxs(l,{children:["A managed web resource named ",e.jsx("strong",{children:n.name})," already exists. It can't be replaced: keep it as it is, or rename the file and upload it again."]}):e.jsxs(l,{children:["A web resource named ",e.jsx("strong",{children:n?.name})," already exists. Replacing it changes its content everywhere it is used (other ribbons, forms, apps)."]}),e.jsx(g,{prefix:"In"})]}),e.jsxs(k,{children:[e.jsx(o,{appearance:"secondary",onClick:()=>s("cancel"),children:"Cancel"}),e.jsx(o,{appearance:n?.managed?"primary":"secondary",onClick:()=>s("keep"),children:"Keep existing"}),!n?.managed&&e.jsx(o,{appearance:"primary",onClick:()=>s("replace"),children:"Replace"})]})]})})});return{onExisting:p,dialog:m}}export{E as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as t,s as p,A as P,h as j,cq as k,z as I}from"./fluent-icons-BqJj6rDi.js";import{R as h,a as f}from"./monaco-BIO15LCS.js";import{U as b}from"./crmParameters-rgfZhhzN.js";import{S as y,F as R,I as S,an as N,B as A,d as v,b as _,t as u}from"./fluent-ui-QADO660t.js";import{f as E}from"./dnd-Cq8OftAq.js";const U=I({root:{display:"flex",flexDirection:"column",gap:u.spacingVerticalXS},param:{display:"flex",gap:u.spacingHorizontalS,alignItems:"flex-end",padding:u.spacingVerticalXS,border:`1px solid ${u.colorNeutralStroke2}`,borderRadius:u.borderRadiusMedium},typeSelect:{width:"140px",flexShrink:0},valueField:{flex:1},actions:{display:"flex",gap:u.spacingHorizontalXS,flexShrink:0},addButton:{alignSelf:"flex-start"},hint:{color:u.colorNeutralForeground3,fontSize:u.fontSizeBase100}}),B=[{label:"Context",values:["PrimaryControl","PrimaryControlId","SelectedControl","CommandProperties"]},{label:"Record",values:["PrimaryEntityTypeCode","PrimaryEntityTypeName","FirstPrimaryItemId","PrimaryItemIds"]},{label:"Selection context",values:["SelectedEntityTypeCode","SelectedEntityTypeName","FirstSelectedItemId"]},{label:"Grid selection",values:["SelectedControlSelectedItemCount","SelectedControlSelectedItemIds","SelectedControlSelectedItemReferences","SelectedControlAllItemCount","SelectedControlAllItemIds","SelectedControlAllItemReferences","SelectedControlUnselectedItemCount","SelectedControlUnselectedItemIds","SelectedControlUnselectedItemReferences"]},{label:"Org/User",values:["OrgName","OrgLcid","UserLcid"]}];function F({value:r,integer:o,onChange:s}){const[c,i]=h.useState(String(r));return h.useEffect(()=>i(Number.isFinite(r)?String(r):""),[r]),t.jsx(S,{type:"number",value:c,onChange:(g,d)=>{i(d.value);const m=Number(d.value);d.value.trim()!==""&&Number.isFinite(m)&&(!o||Number.isInteger(m))&&!/e/i.test(String(m))&&s(m)},onBlur:()=>i(Number.isFinite(r)?String(r):"")})}const q=({params:r,onChange:o,urlMode:s=!1})=>{const c=U(),i=(e,a)=>{const l=[...r];l[e]=a,o(l)},g=e=>{o(r.filter((a,l)=>l!==e))},d=(e,a)=>{const l=[...r],n=e+a;n<0||n>=l.length||([l[e],l[n]]=[l[n],l[e]],o(l))},m=()=>{o([...r,{kind:"CrmParameter",value:"PrimaryControl"}])};return t.jsxs("div",{className:c.root,children:[r.map((e,a)=>t.jsxs("div",{className:c.param,children:[t.jsx("div",{className:c.typeSelect,children:t.jsxs(y,{value:e.kind,onChange:(l,n)=>{const x=n.value;x==="CrmParameter"?i(a,{kind:x,value:"PrimaryControl"}):x==="BoolParameter"?i(a,{kind:x,value:!1}):x==="IntParameter"||x==="DecimalParameter"?i(a,{kind:x,value:0}):i(a,{kind:"StringParameter",value:""})},children:[t.jsx("option",{value:"CrmParameter",children:"CrmParameter"}),t.jsx("option",{value:"StringParameter",children:"String"}),t.jsx("option",{value:"BoolParameter",children:"Boolean"}),t.jsx("option",{value:"IntParameter",children:"Integer"}),t.jsx("option",{value:"DecimalParameter",children:"Decimal"})]})}),s&&t.jsx(R,{label:"Name (querystring key)",style:{width:"130px",flexShrink:0},children:t.jsx(S,{value:e.name??"",onChange:(l,n)=>i(a,{...e,name:n.value||void 0}),placeholder:"key"})}),t.jsx("div",{className:c.valueField,children:e.kind==="CrmParameter"?t.jsx(y,{value:e.value,onChange:(l,n)=>i(a,{...e,value:n.value}),children:B.map(l=>l.values.filter(n=>!s||!b.has(n)).map(n=>t.jsx("option",{value:n,children:n},n)))}):e.kind==="BoolParameter"?t.jsx(N,{checked:e.value,onChange:(l,n)=>i(a,{...e,value:n.checked}),label:"true"}):e.kind==="StringParameter"?t.jsx(S,{value:String(e.value),onChange:(l,n)=>i(a,{...e,value:n.value})}):t.jsx(F,{value:e.value,integer:e.kind==="IntParameter",onChange:l=>i(a,{...e,value:l})})}),s&&e.kind==="CrmParameter"&&!e.name&&t.jsx(A,{appearance:"filled",color:"warning",size:"small",title:"Name required for URL actions"}),t.jsxs("div",{className:c.actions,children:[t.jsx(v,{appearance:"subtle",size:"small",icon:t.jsx(p,{}),onClick:()=>d(a,-1),disabled:a===0,"aria-label":"Move up"}),t.jsx(v,{appearance:"subtle",size:"small",icon:t.jsx(P,{}),onClick:()=>d(a,1),disabled:a===r.length-1,"aria-label":"Move down"}),t.jsx(v,{appearance:"subtle",size:"small",icon:t.jsx(j,{}),onClick:()=>g(a),"aria-label":"Remove parameter"})]})]},a)),s&&t.jsxs(_,{className:c.hint,children:["For URL actions, each CrmParameter must have a ",t.jsx("code",{children:"name"})," attribute (querystring key)."]}),t.jsx(v,{className:c.addButton,appearance:"secondary",size:"small",icon:t.jsx(k,{}),onClick:m,children:"Add parameter"})]})};let z=0;const C=(r,o)=>Array.from({length:o},()=>`${r}#${++z}`);function O(r,o){const[s,c]=f.useState(null),i=f.useMemo(()=>C(r,o.length),[r,o]),g=!!s&&s.scope===r&&s.keys.length===o.length&&(s.items===o||s.pending);s?.pending&&c({...s,items:g?o:s.items,pending:!1});const d=g?s.keys:i,m=e=>c({scope:r,items:o,pending:!0,keys:e});return{keys:d,add:()=>m([...d,...C(r,1)]),remove:e=>m(d.filter((a,l)=>l!==e)),move:(e,a)=>m(E(d,e,a)),update:()=>m(d)}}export{q as C,O as u};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a6 as v,a7 as ie,a8 as re,a9 as V,aa as le,p as ce}from"./index-Di2_5czx.js";import{D as ue,E as me}from"./ruleKinds-B9hACGaq.js";import{C as de,i as fe}from"./crmParameters-rgfZhhzN.js";const pe=/^[a-zA-Z_$][a-zA-Z_$0-9.]*$/,he=/^[a-zA-Z_][a-zA-Z_0-9]*$/,ge=/^[+-]?\d+$/,be=/^[+-]?(\d+(\.\d*)?|\.\d+)$/,H=/^(true|false|1|0)$/,W={JavaScriptFunction:["FunctionName","Library"],Url:["Address"],CustomRule:["FunctionName","Library"],CommandClientTypeRule:["Type"],CrmClientTypeRule:["Type"],CrmOfflineAccessStateRule:["State"],CrmOutlookClientTypeRule:["Type"],CrmOutlookClientVersionRule:["Major"],DeviceTypeRule:["Type"],EntityPrivilegeRule:["PrivilegeType","PrivilegeDepth"],EntityPropertyRule:["PropertyName","PropertyValue"],FeatureControlRule:["FeatureControlBit","ExpectedValue"],FormEntityContextRule:["EntityName"],FormStateRule:["State"],FormTypeRule:["Type"],MiscellaneousPrivilegeRule:["PrivilegeName"],OptionSetRule:["OptionSet","StateCode","ObjectTypeCode"],OrganizationSettingRule:["Setting"],OutlookItemTrackingRule:["TrackedInCrm"],OutlookRenderTypeRule:["Type"],OutlookVersionRule:["Version"],PageRule:["Address"],RecordPrivilegeRule:["PrivilegeType"],RelationshipTypeRule:["AppliesTo"],SkuRule:["Sku"],ValueRule:["Field","Value"],BoolParameter:["Value"],CrmParameter:["Value"],DecimalParameter:["Value"],IntParameter:["Value"],StringParameter:["Value"]},ye=new Set(["ValueRule.Value","StringParameter.Value"]),$e={SelectionCountRule:["Minimum","Maximum"],CrmOutlookClientVersionRule:["Major","Minor","Build","Revision"],IntParameter:["Value"],Url:["WinMode"]},Ae={DecimalParameter:["Value"]},Re={BoolParameter:["Value"],Url:["PassParams"],OutlookItemTrackingRule:["TrackedInCrm"],EntityPropertyRule:["PropertyValue"],FeatureControlRule:["ExpectedValue"],RelationshipTypeRule:["AllowCustomRelationship","AllowSystemRelationship"]},Se=["Default","InvertResult"],Ie=new Set(["BoolParameter","CrmParameter","DecimalParameter","IntParameter","StringParameter"]),O=s=>Array.from(s.children);function q(s,l,g){const u=[],f=s.tagName;for(const p of W[f]??[]){const m=s.getAttribute(p);(m===null||!m.trim()&&!ye.has(`${f}.${p}`))&&u.push(`${l}: ${f} has no ${p}`)}const b=(p,m,i)=>{for(const d of p??[]){const R=s.getAttribute(d);R===null||R===""&&W[f]?.includes(d)||m.test(R.trim())||u.push(`${l}: ${f} ${d}="${R}" is not ${i}`)}};if(b($e[f],ge,"a whole number"),b(Ae[f],be,"a number"),b(Re[f],H,"true or false"),g&&b(Se,H,"true or false"),f==="JavaScriptFunction"||f==="CustomRule"){const p=s.getAttribute("FunctionName");p?.trim()&&!pe.test(p)&&u.push(`${l}: FunctionName "${p}" isn't a JavaScript function name (letters, digits, _, $ and dots)`)}if((f==="JavaScriptFunction"||f==="CustomRule")&&/^\$webresource:\s*$/i.test(s.getAttribute("Library")??"")&&u.push(`${l}: ${f} Library names no web resource`),f==="EntityRule"){const p=s.getAttribute("Context");p!==null&&!he.test(p)&&u.push(`${l}: EntityRule Context "${p}" isn't valid`)}f==="Url"&&/^https?:\/\/$/i.test(s.getAttribute("Address")?.trim()??"")&&u.push(`${l}: Url has no address`);for(const p of O(s).filter(m=>Ie.has(m.tagName)))f==="Url"&&!p.getAttribute("Name")?.trim()&&u.push(`${l}: a ${p.tagName} of the Url has no Name`),f!=="Url"&&p.hasAttribute("Name")&&u.push(`${l}: a ${p.tagName} of ${f} can't have a Name`),u.push(...q(p,l,!1));return u}function we(s){const l=s.getAttribute("Id")??"";if(s.tagName==="CommandDefinition"){const b=`Command ${l}`,p=O(s).find(m=>m.tagName==="Actions");return O(p??s).filter(m=>m.tagName==="JavaScriptFunction"||m.tagName==="Url").flatMap(m=>q(m,b,!1))}if(s.tagName!=="EnableRule"&&s.tagName!=="DisplayRule")return[];const g=`${s.tagName==="EnableRule"?"Enable":"Display"} rule ${l}`,u=O(s);if(u.length===0)return[`${g} has no steps — add one, or remove the rule from its commands`];const f=[];for(const b of u){if(b.tagName!=="OrRule"){f.push(...q(b,g,!0));continue}const p=O(b).filter(m=>m.tagName==="Or");p.length<2&&f.push(`${g}: an OrRule needs at least 2 alternatives (it has ${p.length})`);for(const m of p){const i=O(m);i.length===0&&f.push(`${g}: an alternative of its OrRule has no steps`);for(const d of i)d.tagName==="OrRule"?f.push(`${g}: an OrRule can't contain another OrRule`):f.push(...q(d,g,!0))}}return f}const Ne=["Mscrm.HideOnModern","Mscrm.ShowOnlyOnModern"];function E(s,l){const g=s.indexOf(l);return g<0?void 0:`Line ${s.slice(0,g).split(/\r?\n/).length}`}function _e(s,l,g){const u=[],b=new DOMParser().parseFromString(s,"application/xml"),p=b.querySelector("parsererror");if(p){const i=p.textContent?.trim()??"Unknown",d=i.match(/line\s+(\d+)/i);return u.push({message:`XML parse error: ${i}`,lineHint:d?`Line ${d[1]}`:void 0}),u}const m=new Set([]);return b.querySelectorAll("[Id]").forEach(i=>{const d=i.getAttribute("Id")??"";if(/\s/.test(d)){const R=E(s,`Id="${d}"`);u.push({message:`Element ID "${d}" contains invalid whitespace characters`,elementId:d,lineHint:R})}}),b.querySelectorAll("[LabelText]").forEach(i=>{const d=i.getAttribute("LabelText")??"",R=d.match(/^\$LocLabels:(.+)$/);if(R&&m.size>0&&!m.has(R[1])){const $=i.getAttribute("Id")??"",S=E(s,$?`Id="${$}"`:`LabelText="${d}"`);u.push({message:`Button label reference "$LocLabels:${R[1]}" has no matching LocLabel entry`,elementId:$||void 0,lineHint:S})}}),(s.includes("& ")||s.includes(`&
|
|
2
|
+
`))&&u.push({message:'URL may contain an unescaped "&" — all ampersands in XML must be written as &',lineHint:E(s,"& ")??E(s,`&
|
|
3
|
+
`)}),b.querySelectorAll("Group").forEach(i=>{const d=[];i.querySelectorAll(":scope > Controls > Button, :scope > Controls > FlyoutAnchor, :scope > Controls > SplitButton").forEach(R=>{const $=parseInt(R.getAttribute("Sequence")??"0",10);if(d.includes($)){const S=i.getAttribute("Id")??"?";u.push({message:`Two elements share Sequence "${$}" in group "${S}"`,elementId:S,lineHint:E(s,`Sequence="${$}"`)})}d.push($)})}),u.push(...Ee(b,s)),u}const X=new Set(["BoolParameter","CrmParameter","DecimalParameter","IntParameter","StringParameter"]);function A(s){return Array.from(s.children)}function te(s,l){return l==="enable"?ue.has(s):me.has(s)}function Ee(s,l){const g=[],u=(m,i,d)=>g.push({message:m,elementId:d,lineHint:E(l,i)}),f=(m,i,d)=>g.push({message:m,elementId:d,lineHint:E(l,i),severity:"warning"}),b=s.querySelector("RibbonDiffXml > RuleDefinitions"),p=[{tag:"EnableRule",label:"Enable",container:"enable"},{tag:"DisplayRule",label:"Display",container:"display"}];for(const{tag:m,label:i,container:d}of p)b?.querySelectorAll(`:scope > ${m}s > ${m}`).forEach(R=>{const $=R.getAttribute("Id")??"",S=A(R);S.length===0&&u(`${i} rule "${$}" has no steps — the schema requires at least one`,`Id="${$}"`,$);const D=I=>{te(I.tagName,d)&&f(`${i} rule "${$}" contains ${I.tagName}, which RibbonTypes.xsd only allows in ${d==="enable"?"display":"enable"} rules`,`<${I.tagName}`,$)};for(const I of S){if(I.tagName!=="OrRule"){D(I);continue}const T=A(I);T.filter(w=>w.tagName==="Or").length<2&&u(`OrRule in ${i.toLowerCase()} rule "${$}" needs at least 2 <Or> children (found ${T.filter(w=>w.tagName==="Or").length})`,"<OrRule",$);for(const w of T){const C=A(w);C.length===0&&u(`Empty <Or> in rule "${$}"`,"<Or",$);for(const L of C)L.tagName==="OrRule"?u(`Rule "${$}": an <Or> cannot contain another OrRule`,"<OrRule",$):D(L)}}});return b||s.querySelectorAll("OrRule").forEach(m=>{const i=m.querySelectorAll(":scope > Or").length;i<2&&u(`OrRule requires at least 2 <Or> children (found ${i})`,"<OrRule")}),s.querySelectorAll("JavaScriptFunction, CustomRule").forEach(m=>{for(const i of A(m)){if(!X.has(i.tagName))continue;i.hasAttribute("Name")&&u(`${i.tagName} inside <${m.tagName}> must not have a Name attribute (only <Url> parameters are named)`,`<${i.tagName} Name=`);const d=i.getAttribute("Value")??"";i.tagName==="CrmParameter"&&!de.has(d)&&u(`CrmParameter Value "${d}" is not a valid CrmParameterValue`,`Value="${d}"`)}}),s.querySelectorAll("Url").forEach(m=>{for(const i of A(m)){if(!X.has(i.tagName))continue;i.getAttribute("Name")||u(`${i.tagName} inside <Url> requires a Name (the query-string key)`,`<${i.tagName}`);const d=i.getAttribute("Value")??"";i.tagName==="CrmParameter"&&!fe(d)&&u(`CrmParameter Value "${d}" is not allowed in a <Url> action (CrmNamedParameterValue)`,`Value="${d}"`)}}),s.querySelector("RibbonDiffXml > Scalings")&&u('<Scalings> is not allowed in RibbonDiffXml — scaling changes are CustomActions with Location="{tabId}.Scaling._children"',"<Scalings"),s.querySelectorAll("CustomAction > CommandUIDefinition > Tab").forEach(m=>{const i=m.getAttribute("Id")??"",d=A(m).map(S=>S.tagName),R=d.indexOf("Scaling"),$=d.indexOf("Groups");(R<0||$>=0&&R>$)&&u(`Tab "${i}" needs a <Scaling Id> element before <Groups>`,`Id="${i}"`,i)}),s.querySelectorAll("TabDisplayRule > DisplayRules").forEach(()=>{u("TabDisplayRule rules must be direct children — remove the <DisplayRules> wrapper","<TabDisplayRule")}),g}const Te=["LabelText","ToolTipTitle","ToolTipDescription","Alt","Title","Description"],Ce=new Set(["powerFx","customApi"]),Le={powerFx:"Power Fx",customApi:"Custom API"};function ve(s){return[...new Set(s.actions.map(l=>l.kind).filter(l=>Ce.has(l)))]}const K=/^\$LocLabels:(.+)$/,ne=/^\$webresource:([^?#]+)/i,J=new Set(["ModernImage","Image16by16","Image32by32"]),Q=new Set(["Tab","Group"]),oe=new Set(["main_system_library.js"]),Oe=new Set(["FlyoutAnchor","SplitButton"]),Pe=new Set(["Button","FlyoutAnchor","SplitButton","TextBox","ComboBox","CheckBox"]),Y=/^(.+)\.Scaling\._children$/,Z=s=>/^(Mscrm|Microsoft)\./.test(s);function ae(s){const l=[],g=[],u=new DOMParser;for(const f of Object.keys(s))for(const[b,p]of s[f]){const m=u.parseFromString(p,"application/xml");if(m.querySelector("parsererror")){g.push({severity:"error",code:"xml-parse",message:`${f} element ${b} is not well-formed XML`,elementId:b});continue}l.push({part:f,key:`${f}:${b}`,el:m.documentElement})}return{elements:l,errors:g}}function N(s){return[s,...Array.from(s.getElementsByTagName("*"))]}function se(s){return typeof s=="string"?ce(s):s}function Be(s){let l;try{l=se(s)}catch{return[]}const g=new Map;for(const{el:u}of ae(l).elements)for(const f of N(u))for(const b of Array.from(f.attributes)){const p=ne.exec(b.value.trim())?.[1],m=p?.toLowerCase();p&&m&&!oe.has(m)&&!g.has(m)&&g.set(m,p)}return[...g.values()]}const ee=s=>{const l=s.trim();return l&&!l.includes(".")?`Mscrm.Templates.${l}`:l};function qe(s,l={}){let g;try{g=se(s)}catch(e){return[{severity:"error",code:"xml-parse",message:e instanceof Error?e.message:String(e)}]}const{elements:u,errors:f}=ae(g),b=l.changedKeys?new Set(l.changedKeys):null,p=e=>!b||b.has(e),m=new Set(l.newKeys??[]),i=(e,n,t,a,o=!1)=>{const r=(Array.isArray(n)?n:[n]).some(p);f.push({severity:o||!r?"warning":"error",code:e,message:r?t:`${t} (already in the published customizations)`,elementId:a})},d=u.filter(e=>e.part==="customActions"),R=u.filter(e=>e.part==="commandDefinitions");for(const{part:e,key:n,el:t}of u)if(!(e!=="commandDefinitions"&&e!=="enableRules"&&e!=="displayRules"))for(const a of we(t))i("schema",n,a,t.getAttribute("Id")??void 0);const $=new Map((l.commands??[]).map(e=>[e.id,e]));for(const{key:e,el:n}of R){const t=n.getAttribute("Id")??"",a=$.get(t);if(!a||!p(e))continue;const o=ve(a);o.length!==0&&i("dropped-action",e,`Command ${t} has a ${o.map(r=>Le[r]??r).join(" / ")} action — classic ribbon commands can't run it, so it would be dropped; remove the action`,t)}const S=new Set;for(const{el:e}of d)if(e.tagName==="CustomAction")for(const n of Array.from(e.getElementsByTagName("*")))n.getAttribute("Command")===v&&S.add(n.getAttribute("Id")??"");for(const{key:e,el:n}of d){if(n.tagName!=="HideCustomAction")continue;const t=n.getAttribute("Location")??"";!S.has(t)&&!ie({id:t,commandId:v})||i("open-record-hidden",e,`${t} is hidden, but it carries the record open override (${v}) — Unified Interface may then open records as usual or fail to open them; unhide it, or turn the override off`,t,!0)}for(const{key:e,el:n}of R){if(n.getAttribute("Id")!==v)continue;const t=A(n).filter(o=>o.tagName==="DisplayRules").flatMap(o=>A(o).map(r=>r.getAttribute("Id")??r.tagName));if(t.length===0)continue;const a=t.includes("Mscrm.HideOnModern")?Ne.filter(o=>t.includes(o)):[];i("open-record-hidden",e,`${v} has display rules (${t.join(", ")})${a.length>0?` — ${a.join(" + ")} hide its button`:""}: where they hide the "Open record" button, the record open override may stop working; the button must stay shown`,v,!0)}for(const{key:e,el:n}of d)for(const t of Array.from(n.getElementsByTagName("*"))){if(!Oe.has(t.tagName)||A(t).some(o=>o.tagName==="Menu"))continue;const a=t.getAttribute("Id")??"";if(re(t.getAttribute("PopulateDynamically"))){t.getAttribute("PopulateQueryCommand")?.trim()||i("menu-missing",e,`${t.tagName} ${a} is populated dynamically but has no PopulateQueryCommand — its drop-down may stay empty`,a,!0);continue}i("menu-missing",e,`${t.tagName} ${a} has no <Menu> — it would publish as an empty drop-down`,a)}const D=new Set(l.menuControlsIds??[]);for(const{key:e,el:n}of d){const t=n.getAttribute("Location")??"",a=t.endsWith("._children")&&D.has(t.slice(0,-10));for(const o of Array.from(n.getElementsByTagName("*"))){const r=a||!!o.parentElement?.closest("Menu");for(const c of Te){const y=o.getAttribute(c);if(!y?.startsWith("$LocLabels:"))continue;const h=y.slice(11);h.length<=V||i("label-id-length",e,`${o.tagName} ${o.getAttribute("Id")??""} uses label ${h} (${h.length} characters)`+(r?`: a menu item's label id may have at most ${V} characters, or the publish fails after the import — give the control a shorter id`:`: label ids over ${V} characters fail inside menus; consider a shorter control id`),o.getAttribute("Id")??void 0,!r)}}}if(l.known?.commandIds){const e=new Set([...g.commandDefinitions.keys(),...l.known.commandIds]);for(const{key:n,el:t}of d)for(const a of Array.from(t.getElementsByTagName("*")))if(!Q.has(a.tagName))for(const o of["Command","PopulateQueryCommand"]){const r=a.getAttribute(o);if(!r||e.has(r))continue;const c=a.getAttribute("Id")??"";i("undefined-command",n,`${a.tagName} ${c} uses ${o==="Command"?"command":"PopulateQueryCommand"} ${r}, which is defined neither in the customizations nor in the loaded ribbon`,c,Z(r))}}const I={EnableRule:l.known?.enableRuleIds?new Set([...g.enableRules.keys(),...l.known.enableRuleIds]):null,DisplayRule:l.known?.displayRuleIds?new Set([...g.displayRules.keys(),...l.known.displayRuleIds]):null};for(const{key:e,el:n}of R){const t=n.getAttribute("Id")??"",a=A(n).filter(o=>o.tagName==="EnableRules"||o.tagName==="DisplayRules").flatMap(A);for(const o of a){const r=I[o.tagName],c=o.getAttribute("Id");!r||!c||r.has(c)||i("undefined-rule",e,`Command ${t} uses ${o.tagName==="EnableRule"?"enable":"display"} rule ${c}, which is defined neither in the customizations nor in the loaded ribbon`,t,Z(c))}}for(const{part:e,key:n,el:t}of u){if(e!=="enableRules"&&e!=="displayRules")continue;const a=e==="enableRules"?"enable":"display",o=t.getAttribute("Id")??"",r=A(t).flatMap(c=>c.tagName==="OrRule"?A(c).filter(y=>y.tagName==="Or").flatMap(A):[c]);for(const c of r)te(c.tagName,a)&&i("rule-placement",n,`${a==="enable"?"Enable":"Display"} rule ${o} contains ${c.tagName}, which the ribbon schema only allows in ${a==="enable"?"display":"enable"} rules`,o,!0)}const T=new Set;for(const e of Object.values(l.loadedAttributes??{}))for(const n of Object.values(e))K.test(n)&&T.add(n);for(const{key:e,el:n}of u)if(n.tagName!=="LocLabel")for(const t of N(n))for(const a of Array.from(t.attributes)){const o=K.exec(a.value)?.[1];if(!o||g.locLabels.has(o))continue;const r=t.getAttribute("Id")??void 0;r&&l.loadedAttributes?.[r]?.[a.name]===a.value||T.has(a.value)||i("loclabel-missing",e,`${[t.tagName,r,a.name].filter(Boolean).join(" ")} references $LocLabels:${o}, which has no <LocLabel> in these customizations — the text won't resolve unless another solution defines the label`,r,!0)}const w=new Map;for(const{key:e,el:n}of d){const t=n.getAttribute("Location")??"",a=n.getAttribute("Sequence");if(n.tagName!=="CustomAction"||!t.endsWith("._children")||!a)continue;const o=`${t}|${a}`;w.set(o,[...w.get(o)??[],{key:e,id:n.getAttribute("Id")??e}])}for(const[e,n]of w){if(n.length<2||!n.some(o=>p(o.key)))continue;const[t,a]=e.split("|");i("duplicate-sequence",n.map(o=>o.key),`${n.map(o=>o.id).join(" and ")} have the same Sequence (${a}) in ${t} — their order isn't defined; give one another Sequence`,n[0].id,!0)}for(const{key:e,el:n}of u)for(const t of N(n))for(const a of Array.from(t.attributes)){if(a.name!=="Library"&&!J.has(a.name))continue;const o=/^\/?WebResources\/(.+)$/i.exec(a.value.trim())?.[1];o&&i("webresource-path",e,`${t.tagName} ${t.getAttribute("Id")??""} ${a.name} is the path ${a.value} — use $webresource:${o}, the only form that makes the solution depend on the web resource`.replace(/\s+/g," "),t.getAttribute("Id")??void 0,!0)}if(l.webResources){const e=new Set;for(const{el:n}of u)for(const t of N(n))for(const a of Array.from(t.attributes)){const o=ne.exec(a.value.trim())?.[1],r=o?.toLowerCase();if(!o||!r||oe.has(r)||e.has(r))continue;const c=l.webResources[r];if(!c)continue;const y=t.getAttribute("Id")??void 0;c.exists?!c.inSolution&&!c.managed&&(e.add(r),f.push({severity:"warning",code:"webresource-not-in-solution",message:`Web resource ${o} isn't in the selected solution — the ribbon won't import into another environment without it`,elementId:y})):(e.add(r),f.push({severity:"warning",code:"webresource-missing",message:`Web resource ${o} (${t.tagName} ${a.name}) doesn't exist in this environment — ${J.has(a.name)?"the button will show no icon":"the action or rule that loads it will fail when it runs"}`,elementId:y}))}}const C=new Map,L=e=>{let n=C.get(e);return n||C.set(e,n=new Map),n};for(const[e,n]of Object.entries(l.tabScaling??{})){for(const t of n.maxSizes)L(e).set(t.id,{...t,tag:"MaxSize"});for(const t of n.scales)L(e).set(t.id,{...t,tag:"Scale"})}const F=new Map(Object.entries(l.groupTemplates??{}).map(([e,n])=>[e,ee(n)])),z=new Map(Object.entries(l.templateLayouts??{}));for(const{part:e,el:n}of u)if(e==="templates")for(const t of N(n).filter(a=>a.tagName==="GroupTemplate")){const a=A(t).filter(o=>o.tagName==="Layout").map(o=>o.getAttribute("Title")??"");z.set(t.getAttribute("Id")??"",a)}const x=[];for(const{key:e,el:n}of d){for(const r of Array.from(n.getElementsByTagName("Group"))){const c=r.getAttribute("Template");c&&F.set(r.getAttribute("Id")??"",ee(c))}const t=[],a=Y.exec(n.getAttribute("Location")??"")?.[1],o=A(n).find(r=>r.tagName==="CommandUIDefinition");if(a&&o)for(const r of A(o))t.push([a,r]);for(const r of Array.from(n.getElementsByTagName("Tab")))for(const c of A(r).filter(y=>y.tagName==="Scaling"))for(const y of A(c))t.push([r.getAttribute("Id")??"",y]);for(const[r,c]of t){if(c.tagName!=="MaxSize"&&c.tagName!=="Scale")continue;const y={id:c.getAttribute("Id")??"",tag:c.tagName,groupId:c.getAttribute("GroupId")??"",size:c.getAttribute("Size")??"",sequence:parseInt(c.getAttribute("Sequence")??"",10),key:e};L(r).set(y.id,y),x.push(y)}}for(const[e,n]of C){const t=new Map;for(const a of n.values())Number.isNaN(a.sequence)||t.set(a.sequence,[...t.get(a.sequence)??[],a]);for(const[a,o]of t){const r=[...new Set(o.flatMap(h=>h.key?[h.key]:[]))];if(o.length<2||r.length===0)continue;const c=o.find(h=>h.key&&h.tag==="MaxSize"&&h.id===`${h.groupId}.MaxSize`),y=c?`move group ${c.groupId} to another position (its MaxSize takes the group's Sequence; #66 picks a free one automatically)`:"give each step its own Sequence";i("scaling-collision",r,`Scaling of tab ${e}: ${o.map(h=>`${h.tag} ${h.id}`).join(" and ")} have the same Sequence ${a} — Unified Interface then drops every custom control of the table; ${y}`,o.find(h=>h.key)?.id)}}for(const e of x){const n=F.get(e.groupId),t=n?z.get(n):void 0;!t?.length||t.includes(e.size)||i("scaling-size",e.key??[],`${e.tag} ${e.id} has Size "${e.size}", which isn't a layout of template ${n} used by group ${e.groupId} (${t.join(", ")})`,e.id,!0)}const j=new Set(l.known?.elementIds??[]),M=new Map;for(const{key:e,el:n}of d){if(!(n.getAttribute("Location")??"").endsWith("._children"))continue;const t=A(n).find(o=>o.tagName==="CommandUIDefinition"),a=t?A(t)[0]:void 0;if(!(!a||a.tagName==="MaxSize"||a.tagName==="Scale"))for(const o of N(a)){const r=o.getAttribute("Id");if(!r||o.closest("Scaling"))continue;const c=M.get(r)??[];c.includes(e)||M.set(r,[...c,e])}}for(const[e,n]of M)n.length>1?i("duplicate-id",n,`Id ${e} is added by more than one CustomAction (${n.map(t=>t.replace(/^customActions:ca:/,"")).join(", ")})`,e):m.has(n[0])&&j.has(e)&&i("duplicate-id",n,`Id ${e} is added as a new element, but the ribbon already has an element with this id`,e);if(l.places){const{entityLogicalName:e,tabByCollection:n}=l.places,t=new Set(["Mscrm.Tabs",`Mscrm.SubGrid.${e}.ContextualTabs`]);for(const{key:a,el:o}of d){const r=o.getAttribute("Location")??"",c=/^(.+)\._children$/.exec(r)?.[1];if(!c||Y.test(r)||!p(a))continue;const y=A(o).find(k=>k.tagName==="CommandUIDefinition"),h=y?A(y)[0]:void 0,P=h?.getAttribute("Id")??"";if(!h||!P||!(Pe.has(h.tagName)||Q.has(h.tagName)))continue;const B=c.split("{!EntityLogicalName}").join(e),U=n[B];if(U!==void 0){le(U)&&i("orphan-location",a,`${h.tagName} ${P} is added to ${c}, on the tab ${U}: Unified Interface doesn't show that tab and the ribbon doesn't return what is added there, so it won't show anywhere — add it to the table's main tab instead`,P,!0);continue}const G=k=>k.replace(/\.(Controls|Groups)$/,"");t.has(B)||[c,B,G(c),G(B)].some(k=>M.has(k))||i("orphan-location",a,`${h.tagName} ${P} is added at ${r}, but this table's ribbon has no ${c} — it won't show anywhere (check the Location, or move it to an existing group)`,P,!0)}}const _=l.publisherPrefix?.trim().toLowerCase();if(_&&m.size>0){const e=new Set([...j,...l.known?.commandIds??[],...l.known?.enableRuleIds??[],...l.known?.displayRuleIds??[]]),n=o=>{const r=o.split(".");for(let c=r.length;c>0;c--)if(e.has(r.slice(0,c).join(".")))return!0;return!1},t=o=>{const r=o.toLowerCase();return r.startsWith(`${_}.`)||r.startsWith(`${_}_`)},a=new Set;for(const{part:o,key:r,el:c}of u)if(!(!m.has(r)||o==="templates"||o==="tabDisplayRules"))for(const y of N(c)){if(y!==c&&y.closest("Actions, EnableRules, DisplayRules, EnableRule, DisplayRule"))continue;const h=y.getAttribute("Id")??y.getAttribute("HideActionId");!h||a.has(h)||t(h)||n(h)||(a.add(h),f.push({severity:"warning",code:"id-prefix",message:`${y.tagName} id ${h} doesn't start with the publisher prefix "${_}." — ids without it can collide with other solutions`,elementId:h}))}}return f}export{_e as a,qe as v,Be as w};
|
package/dist/index.html
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Command Bar Studio</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-Di2_5czx.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/monaco-BIO15LCS.js">
|
|
9
|
-
<link rel="modulepreload" crossorigin href="./assets/fluent-icons-
|
|
10
|
-
<link rel="modulepreload" crossorigin href="./assets/fluent-ui-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="./assets/dnd-
|
|
9
|
+
<link rel="modulepreload" crossorigin href="./assets/fluent-icons-BqJj6rDi.js">
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/fluent-ui-QADO660t.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="./assets/dnd-Cq8OftAq.js">
|
|
12
12
|
<link rel="stylesheet" crossorigin href="./assets/monaco-DdLsZAcA.css">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="./assets/index-D9lerlVA.css">
|
|
14
14
|
</head>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mohsinonxrm/pptb-commandbar-studio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"displayName": "Command Bar Studio",
|
|
5
5
|
"description": "Visual designer for Dataverse classic ribbon / command bar customizations — the spiritual successor to Ribbon Workbench, built for Power Platform ToolBox",
|
|
6
6
|
"author": "Mohsin On xRM",
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import{y as t,z as jn}from"./fluent-icons-DUgjkNjy.js";import{p as je,m as Wn,g as Kn,n as ze,o as _n,q as Hn,r as Gn,t as Yn,v as Jn,x as Fe,y as Zn,z as Qn,A as es,B as ns,d as Se,D as ss,F as ts,G as os,H as cn,I as is,J as as,K as Me,L as rs,M as ls,N as O,k as qe,O as Ie,P as cs,Q as ds,R as dn,S as us,T as Oe,U as ms,V as un,W as hs,X as Rn,Y as G,Z as Sn,_ as ps,$ as Ve,a0 as bs,a as Ue,u as D,a1 as fs,a2 as gs,a3 as ys,a4 as mn}from"./index-DUEHURiA.js";import{a as A,R as se}from"./monaco-BIO15LCS.js";import{w as ws,v as In}from"./xmlValidator-BB2o3QUU.js";import{M as X,f as V,ae as xs,b as W,B as $n,F as Re,I as kn,t as E,D as Cs,i as vs,j as js,k as Rs,l as Ss,a5 as Is,ao as $s,O as hn,a1 as ks,a6 as Ps,d as Xe,ap as Ns,m as Ds}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";import"./ruleKinds-B9hACGaq.js";import"./crmParameters-rgfZhhzN.js";let pn=0;async function We(e){const n=typeof window<"u"?window.toolboxAPI:void 0;pn++===0&&await bn(()=>n?.preventClose?.());try{return await e()}finally{--pn===0&&await bn(()=>n?.releasePreventClose?.())}}const As=2e3;async function bn(e){let n;try{await Promise.race([e(),new Promise(o=>n=setTimeout(o,As))])}catch{}finally{clearTimeout(n)}}function me(e,n){const o=e.match(new RegExp(`\\s${n}="([^"]*)"`));return o?o[1]:null}function fn(e,n,o){const r=e.indexOf(o,n);return e.slice(n,r===-1?void 0:r).match(/<result\s[^>]*>/g)??[]}function gn(e){const n=e.find(o=>me(o,"result")!=="success");if(n){const o=me(n,"errorcode")??"",r=me(n,"errortext")??"unknown error";return{ok:!1,message:`Dataverse rejected the ribbon (${o}): ${r}`}}return null}function Es(e,n){if(!e)return{ok:!1,message:"The import job returned no result data, so the ribbon import could not be verified."};if(n.kind==="application"){const i=e.search(/<ribbon\s[^>]*processed="true"/);return i===-1?{ok:!1,message:"Import completed, but Dataverse did not process the application ribbon."}:gn(fn(e,i,"</ribbon>"))??{ok:!0,message:"Application ribbon imported."}}const o=new Set(n.names.filter(Boolean).map(i=>i.toLowerCase())),r=/<entityRibbon\s[^>]*>/g;let a;for(;a=r.exec(e);){const i=(me(a[0],"id")??"").toLowerCase();if(o.has(i))return me(a[0],"processed")!=="true"?{ok:!1,message:`Dataverse did not process the ribbon for ${i}.`}:gn(fn(e,a.index,"</entityRibbon>"))??{ok:!0,message:`Ribbon for ${i} imported.`}}return{ok:!1,message:`Import completed, but Dataverse did not apply a ribbon for ${n.names.join(" / ")} (no entityRibbon result in the import job). Nothing was changed.`}}const J=window.dataverseAPI;async function Ts(e,n,o){return await o("The import"),J.execute({operationName:"ImportSolution",operationType:"action",parameters:{CustomizationFile:e,ImportJobId:n,OverwriteUnmanagedCustomizations:!0,PublishWorkflows:!1}})}async function Ls(e,n){await n("Publishing");const o=e.map(r=>`<entity>${O(r)}</entity>`).join("");return J.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:`<importexportxml><entities>${o}</entities></importexportxml>`}})}function yn(e){const n=e.data?.progress;return!!(typeof n=="object"&&n!==null&&n.completed===!0||typeof e.progress=="number"&&e.progress>=100||typeof n=="number"&&n>=100||e.completedon||e.data?.completedon||e.statuscode===30)}function zs(e){const n=e.titles.map(o=>`<Title languagecode="${o.languageCode}" description="${O(o.description)}"/>`).join("");return`<LocLabel Id="${O(e.id)}"><Titles>${n}</Titles></LocLabel>`}async function Pn(e){const n=e.entity?.logicalName??"{!EntityLogicalName}",o={deletedContainerIds:e.plan.deletedContainerIds??[],movedButtons:e.plan.movedButtons??[],editedLocLabelIds:e.plan.editedLocLabelIds??[],editedTabIds:e.plan.editedTabIds??[]},r=e.locLabels.filter(l=>o.editedLocLabelIds.includes(l.id)),a=e.languageCode??1033;for(const l of e.plan.renamedLabels??[]){const h=r.find(I=>I.id===l.id)??e.locLabels.find(I=>I.id===l.id),R=[{languageCode:a,description:l.text},...(h?.titles??[]).filter(I=>I.languageCode!==a)],y=r.findIndex(I=>I.id===l.id);y>=0?r[y]={id:l.id,titles:R}:r.push({id:l.id,titles:R})}let i=r.length?je(`<RibbonDiffXml><LocLabels>${r.map(zs).join("")}</LocLabels></RibbonDiffXml>`):Wn();for(const l of e.locations){const h=Kn({current:l.current,baseline:l.baseline,commands:e.commands,enableRules:e.enableRules,displayRules:e.displayRules,locLabels:e.locLabels,entityLogicalName:n,location:l.current.location,languageCode:e.languageCode});i=ze(i,je(h))}const d=[],u=[];for(const l of e.locations)for(const h of l.current.tabs){if(!o.editedTabIds.includes(h.id))continue;if(h.tabDisplayRules.length>0){const y=_n(h,e.entity===null);y&&u.push(y)}const R=new Set(h.tabDisplayRules.map(y=>y.tabCommand));for(const y of l.baseline.tabs.find(I=>I.id===h.id)?.tabDisplayRules??[])R.has(y.tabCommand)||d.push(y.tabCommand)}u.length>0&&(i=ze(i,je(`<RibbonDiffXml><RuleDefinitions><TabDisplayRules>${u.join("")}</TabDisplayRules></RuleDefinitions></RibbonDiffXml>`)));const f=[...e.commands.filter(l=>e.plan.editedCommandIds.includes(l.id)).map(Hn)],$={enable:e.enableRules.filter(l=>e.plan.editedEnableRuleIds.includes(l.id)).map(Yn),display:e.displayRules.filter(l=>e.plan.editedDisplayRuleIds.includes(l.id)).map(Gn)};(f.length||$.enable.length||$.display.length)&&(i=ze(i,je(`<RibbonDiffXml><CommandDefinitions>${f.join("")}</CommandDefinitions><RuleDefinitions><DisplayRules>${$.display.join("")}</DisplayRules><EnableRules>${$.enable.join("")}</EnableRules></RuleDefinitions></RibbonDiffXml>`)));const S=(l,h)=>{for(const R of Array.from(l.keys()))h.includes(R)||l.delete(R)},v=e.locations.flatMap(l=>l.current.tabs.filter(h=>!l.baseline.tabs.some(R=>R.id===h.id)).map(Jn));S(i.commandDefinitions,[...e.plan.editedCommandIds,...v]),S(i.enableRules,e.plan.editedEnableRuleIds),S(i.displayRules,e.plan.editedDisplayRuleIds);const m=await Fe(e.entity?.logicalName??null),C=Zn(m),b=e.plan.deletedButtonIds.filter(l=>!C.has(l));if(b.length>0)throw new Error(`Can't delete ${b.join(", ")}: not defined in this table's unmanaged customizations (it comes from a managed solution or the platform). Undo the delete and hide the button instead.`);const w=Qn(m),P=o.deletedContainerIds.filter(l=>!w.has(l));if(P.length>0)throw new Error(`Can't delete ${P.join(", ")}: not added by this table's unmanaged customizations (it comes from a managed solution or the platform). Undo the delete.`);const j=o.movedButtons.filter(l=>!C.has(l.id)).map(l=>l.id);if(j.length>0)throw new Error(`Can't move ${j.join(", ")}: not defined in this table's unmanaged customizations. Undo the move.`);const q=es(m),Z=(e.plan.uncustomisedCommandIds??[]).filter(l=>m.commandDefinitions.has(l)&&!ns(l,q));if(Z.length>0)throw new Error(`Can't uncustomise ${Z.join(", ")}: it is your own command (your customizations' buttons use it and no other solution defines it), so removing it would leave those buttons without a command. Undo the uncustomise.`);const K=new Set;for(const l of e.locations)for(const h of l.current.tabs)for(const R of h.groups)for(const y of Se(R))for(const I of ss(y))K.add(I);const Q=e.plan.uncustomisedCommandIds??[],Y=new Set,ee=new Set;for(const l of e.commands)if(!(!K.has(l.id)||Q.includes(l.id))){l.enableRules.forEach(h=>Y.add(h)),l.displayRules.forEach(h=>ee.add(h));for(const h of l.rawRuleRefs??[]){const R=/^\s*<(EnableRule|DisplayRule)\b[^>]*?\sId="([^"]+)"/.exec(h.xml);R&&(R[1]==="EnableRule"?Y:ee).add(R[2])}}let k=ts(m,i,{retainedCommandIds:K,editedCommandIds:e.plan.editedCommandIds,editedEnableRuleIds:e.plan.editedEnableRuleIds,editedDisplayRuleIds:e.plan.editedDisplayRuleIds,deletedControlIds:e.plan.deletedButtonIds,unhiddenControlIds:e.plan.unhiddenButtonIds,deletedContainerIds:o.deletedContainerIds,movedControls:o.movedButtons,removedTabCommands:d,uncustomisedCommandIds:Q,retainedEnableRuleIds:Y,retainedDisplayRuleIds:ee});for(const l of e.plan.renamedLabels??[])l.newLabel&&(k=os(k,l.containerId,`$LocLabels:${l.id}`));const c=new Set([...cn(m),...cn(k)].map(l=>l.id)),g={};for(const l of e.locations)for(const[h,R]of Object.entries(l.baseline.scalingByTab??{}))g[h]={maxSizes:R.maxSizes.filter(y=>!c.has(y.id)).map(y=>y.sequence),scales:R.scales.filter(y=>!c.has(y.id)).map(y=>y.sequence)};const L=is(k,g);if(L.problems.length>0)throw new Error(`Not published: ${L.problems.join("; ")}.`);return k=L.parts,{scalingChanges:L.changes,xml:rs(k),parts:k,elementCount:Me(k),preservedCount:Me(m),changedCount:Me(i),changedKeys:as(m,k),newKeys:Object.keys(k).flatMap(l=>Array.from(k[l].keys()).filter(h=>!m[l].has(h)).map(h=>`${l}:${h}`)),layerDefinitionIds:{commandIds:Array.from(m.commandDefinitions.keys()),enableRuleIds:Array.from(m.enableRules.keys()),displayRuleIds:Array.from(m.displayRules.keys())},layer:m}}function Nn(e,n){const o=[],r={},a={},i={},d={},u=new Set,f=new Set,$=new Set;for(const{current:m,baseline:C}of e.locations)for(const b of[C,m])for(const w of b.tabs)for(const P of w.groups)for(const j of Se(P))for(const q of j.menu?.sections??[])$.add(q.controlsId);for(const{current:m,baseline:C}of e.locations){Object.assign(i,C.templateLayouts);for(const b of C.tabs){o.push(b.id),b.label&&(d[b.id]={Title:b.label});for(const w of b.groups){u.add(w.id),o.push(w.id),w.label&&(d[w.id]={Title:w.label,Label:w.label});for(const P of Se(w))o.push(P.id),P.source&&(d[P.id]=P.source.attributes)}}for(const b of m.tabs)for(const w of b.groups)f.add(w.id);for(const b of[C,m])for(const w of b.tabs)for(const P of w.groups)P.template&&(a[P.id]=P.template)}const S=m=>u.has(m.groupId)&&!f.has(m.groupId);for(const{baseline:m}of e.locations)for(const[C,b]of Object.entries(m.scalingByTab??{}))r[C]={...b,maxSizes:b.maxSizes.filter(w=>!S(w)),scales:b.scales.filter(w=>!S(w))};const v=(m,C)=>{if(!m)return;const b=new Set(C??[]);return m.map(w=>w.id).filter(w=>!b.has(w))};return{changedKeys:n.changedKeys,newKeys:n.newKeys,commands:e.commands,known:{commandIds:v(e.baselineCommands,n.layerDefinitionIds?.commandIds),enableRuleIds:v(e.baselineEnableRules,n.layerDefinitionIds?.enableRuleIds),displayRuleIds:v(e.baselineDisplayRules,n.layerDefinitionIds?.displayRuleIds),elementIds:o},loadedAttributes:d,publisherPrefix:e.publisherPrefix,tabScaling:r,groupTemplates:a,templateLayouts:i,menuControlsIds:$,...e.entity?{places:{entityLogicalName:e.entity.logicalName,tabByCollection:Object.fromEntries(ls(e.locations.map(m=>m.baseline),e.entity.logicalName))}}:{}}}function Ms(e,n){return new Promise((o,r)=>{const a=setTimeout(()=>r(new Error(`it didn't finish within ${Math.round(n/1e3)} s`)),n);e.then(i=>{clearTimeout(a),o(i)},i=>{clearTimeout(a),r(i)})})}async function wn(e,n={}){const o=await Pn(e),r=Nn(e,o),a=[],i=ws(o.parts);if(n.lookupWebResources&&i.length>0)try{r.webResources=await n.lookupWebResources(i)}catch(d){a.push({severity:"warning",code:"webresource-lookup",message:`Couldn't check the ${i.length} referenced web resource(s): ${d instanceof Error?d.message:String(d)}`})}return{findings:[...In(o.parts,r),...a],xml:o.xml}}async function Os(e,n,o={}){const r=o.attempts??3,a=o.contentKeys??[];let i={missing:[],unexpected:[],differing:[]};for(let u=0;u<r;u++){u>0&&await new Promise(f=>setTimeout(f,o.delayMs??5e3));try{i=Rn(n,await Fe(e),{contentKeys:a})}catch(f){return{ok:!1,missing:[],unexpected:[],differing:[],message:`Couldn't read the published ribbon layer to verify it (${f instanceof Error?f.message:String(f)}).`}}if(i.missing.length===0&&i.unexpected.length===0&&i.differing.length===0){const f=a.length;return{ok:!0,...i,message:"Verified: the published ribbon layer has every element that was imported"+(f>0?`, and the ${f} element(s) this publish changed have the imported content.`:".")}}}const d=u=>u.slice(0,5).join(", ")+(u.length>5?", …":"");return{ok:!1,...i,message:"The published ribbon layer doesn't match what was imported"+(i.missing.length?`; missing: ${d(i.missing)}`:"")+(i.unexpected.length?`; unexpected: ${d(i.unexpected)}`:"")+(i.differing.length?`; different content: ${d(i.differing)}`:"")+". Reload the table and check before publishing again."}}class Be extends Error{constructor(n,o,r=!1){const a=r?"another solution import ran in the environment meanwhile, and what it changed may not be published yet":Dn(o);super(r?`${n}'s ribbon customizations may have changed in Dataverse since you started publishing: ${a}. Importing could overwrite that change, so nothing was imported. Publish again: the table is published first, so the change is kept.`:`${n}'s ribbon customizations changed in Dataverse since you started publishing (${a}): other ribbon changes for it were published meanwhile, from another session, tool or solution import. Importing would overwrite that change, so nothing was imported. Reload the table to get the change, then publish again.`),this.scopeLabel=n,this.changes=o,this.importRan=r,this.name="RibbonLayerChangedError",this.summary=a}scopeLabel;changes;importRan;summary}function Dn(e){const n=o=>o.slice(0,5).join(", ")+(o.length>5?", …":"");return[e.unexpected.length?`added: ${n(e.unexpected)}`:"",e.missing.length?`removed: ${n(e.missing)}`:"",e.differing.length?`changed: ${n(e.differing)}`:""].filter(Boolean).join("; ")}function Us(e){const n=e instanceof Error?e.message:String(e);return/there is (?:another|a previous) \[(\w+)\] running/i.exec(n)?.[1]??null}const Xs=e=>Object.keys(e).flatMap(n=>Array.from(e[n].keys()).map(o=>`${n}:${o}`));function An(e,n){const o=[],r=[],a=[];for(const i of Object.keys(e)){for(const[d,u]of e[i]){const f=n[i].get(d);f===void 0?o.push(`${i}:${d}`):f!==u&&a.push(`${i}:${d}`)}for(const d of n[i].keys())e[i].has(d)||r.push(`${i}:${d}`)}return{missing:o,unexpected:r,differing:a}}const En=e=>e.missing.length+e.unexpected.length+e.differing.length>0;async function Vs(e,n,o,r){const a=r.kind==="imported"?r.attempts??3:1;let i={missing:[],unexpected:[],differing:[]};for(let d=0;d<a;d++){d>0&&r.kind==="imported"&&await new Promise(f=>setTimeout(f,r.delayMs??5e3));const u=await Fe(e);if(i=r.kind==="read"?An(o,u):Rn(o,u,{contentKeys:Xs(o)}),!En(i))return}throw new Be(n,i)}function xn(e,n){return We(()=>Bs(e,n))}async function Bs(e,n){const o=e.guard??qe(),r=Ie.getState(),a=e.entity?e.entity.logicalName:"Application ribbon",i={onProgress:n,...e.busy},d=e.entity===null;if(d&&!e.ribbonCustomizationIds?.length)throw new Error("The selected solution does not contain Application Ribbons. Add it in make.powerapps.com (Solutions → your solution → Add existing → Application Ribbons) and reload the solution.");const u=async(c="Publishing customizations…")=>{n?.(c),await un("Publish",async()=>{d?(await o("Publishing"),await J.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:"<importexportxml><ribbons><ribbon></ribbon></ribbons></importexportxml>"}})):await Ls([e.entity.logicalName],o)},i)},f=e.languageCode??await cs(),$=async c=>{n?.(`Reading existing ribbon customizations for ${a}…`),c&&r.logInfo("publish",`Reading unmanaged ribbon layer for ${a}.`);const g=await Pn({...e,languageCode:f}),L=In(g.parts,Nn({...e,publisherPrefix:e.solution.publisherPrefix},g)),l=L.filter(h=>h.severity==="error");if(c||l.length>0){r.logInfo("publish",`RibbonDiffXml for ${a}: ${g.preservedCount} existing element(s) preserved, ${g.changedCount} element(s) from this session, ${g.elementCount} total.`);for(const h of g.scalingChanges)r.logWarn("publish",ms(h));for(const h of L)h.severity==="warning"&&r.logWarn("publish",h.message)}if(l.length>0){for(const h of l)r.logError("publish",h.message);throw new Error(`The pre-publish check found ${l.length} error(s), so nothing was imported: `+l.map(h=>h.message).join("; "))}return g},S=e.publishCustomizations!==!1?await $(!1):null;n?.("Checking that no other solution operation is running…"),await ds(i);const v=await Ws(e.solution);let m=!1;const C=c=>(S&&!m&&c instanceof Error&&(c.message+=` (${a} was published first, so customizations imported elsewhere for it and not yet published are now published.)`),c);if(S){r.logInfo("publish",`Publishing ${a} first, so ribbon changes imported elsewhere but not yet published are kept.`);try{await u(`Publishing ${a} first (keeps changes imported elsewhere but not published)…`)}catch(c){throw c instanceof Error&&(c.message=`Publishing ${a} first failed, so nothing was imported: ${c.message}`),c}}let b;try{b=await $(!0)}catch(c){throw S&&c instanceof Error&&!c.message.startsWith("The pre-publish check")&&(c.message=`${a}'s customizations changed when it was published first (changes imported elsewhere and not yet published): ${c.message} Reload the table to get them, then publish again.`),C(c)}if(S){const c=An(S.layer,b.layer);En(c)&&r.logInfo("publish",`Publishing ${a} first published ribbon changes imported elsewhere (${Dn(c)}); they are kept.`)}const w=e.entity?.schemaName||e.entity?.logicalName||"",P=d?dn({applicationRibbonDiffXml:b.xml}):dn({entities:[{schemaName:w,localizedName:e.entity?.displayName||w,ribbonDiffXml:b.xml}]}),j=d?[{type:50,schemaName:":RibbonDiffXml",behavior:0}]:[{type:1,schemaName:e.entity.logicalName,behavior:2}],q=Hs({...e.solution,languageCode:f,rootComponents:j,details:v});n?.("Packaging solution ZIP…");const Z=us({"customizations.xml":Oe(P),"solution.xml":Oe(q),"[Content_Types].xml":Oe('<?xml version="1.0" encoding="utf-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="xml" ContentType="application/xml"/></Types>')});let K="";for(let c=0;c<Z.length;c++)K+=String.fromCharCode(Z[c]);const Q=btoa(K),Y=async(c,g)=>{n?.(`Importing ${a} ribbon${c}…`);const L=crypto.randomUUID();r.logInfo("publish",`Importing solution${c} (import job ${L})…`);let l=!1;await un("Import",async()=>{if(await o("Importing"),l)throw new Be(a,{missing:[],unexpected:[],differing:[]},!0);await Vs(e.entity?.logicalName??null,a,g.layer,g.as);try{await Ts(Q,L,o)}catch(N){throw hs(N)&&Us(N)?.toLowerCase()==="import"&&(l=!0),N}m=!0},i);const h=150,R=2e3;let y=await J.getImportJobStatus(L),I=0;for(;!yn(y)&&I<h;)await new Promise(N=>setTimeout(N,R)),y=await J.getImportJobStatus(L),I++,I%10===0&&n?.(`Still importing… (${I*2}s elapsed)`);if(!yn(y))throw new Error(`Solution import did not complete within ${h*R/1e3} seconds. Check Solutions › History for import job ${L}.`);n?.("Verifying the import…");const $e=await J.retrieve("importjob",L,["data"]),B=Es($e.data,d?{kind:"application"}:{kind:"entity",names:[w,e.entity.logicalName]});if(!B.ok)throw r.logError("publish",B.message),new Error(B.message);return r.logInfo("publish",B.message),L};let ee;try{ee=await Y("",{layer:b.layer,as:{kind:"read"}})}catch(c){throw C(c)}let k;if(e.publishCustomizations!==!1){await u();{r.logInfo("publish","Refreshing Unified Interface command-bar metadata (second import of the same package)…");try{await Y(" (refreshing Unified Interface metadata)",{layer:b.parts,as:{kind:"imported",delayMs:e.verifyDelayMs}}),await u()}catch(c){if(c instanceof Be)k={ok:!1,...c.changes,message:`Your changes were imported and published, but ${a}'s ribbon customizations changed in Dataverse after that (${c.summary}): other changes were published meanwhile. They weren't imported a second time to refresh Unified Interface's command-bar metadata, since that would overwrite the other change, so new or changed buttons may not appear in the app until the table's ribbon is published again. Reload the table to see the other change.`},r.logWarn("publish",k.message);else throw new Error(`Your changes were imported and published, but refreshing Unified Interface's command-bar metadata failed (${c instanceof Error?c.message:String(c)}). New or changed buttons may not appear in the app until you publish again.`)}}k||(n?.("Verifying the published ribbon…"),k=await Os(e.entity?.logicalName??null,b.parts,{delayMs:e.verifyDelayMs,contentKeys:b.changedKeys}),k.ok?r.logInfo("publish",k.message):r.logWarn("publish",k.message))}else r.logWarn("publish","Imported without publishing. New or changed buttons appear in Unified Interface only after you publish from Command Bar Studio (which re-imports once to refresh the command-bar metadata).");return n?.(e.publishCustomizations!==!1?`${a} ribbon published.`:`${a} ribbon imported (not published).`),{elementCount:b.elementCount,preservedCount:b.preservedCount,importJobId:ee,verification:k,parts:b.parts,changedKeys:b.changedKeys}}function Fs(e,n){return We(()=>qs(e,n))}async function qs(e,n){const o=n?.guard??qe(),r=Ie.getState(),a=n?.pollIntervalMs??2e3,i=n?.timeoutMs??600*1e3;e?.("Starting asynchronous publish (PublishAllXmlAsync)..."),r.logInfo("publish","Calling PublishAllXmlAsync action."),await o("Publishing");const u=(await J.execute({operationName:"PublishAllXmlAsync",operationType:"action"}))?.AsyncOperationId;if(!u)throw new Error("PublishAllXmlAsync did not return AsyncOperationId.");r.logInfo("publish",`PublishAllXmlAsync job id: ${u}`),e?.("Async publish job started. Waiting for completion...");const f=Date.now();let $=0,S;for(;Date.now()-f<i;){$+=1;const v=await J.retrieve("asyncoperation",u,["asyncoperationid","statecode","statuscode","name","message","friendlymessage","completedon"]);if(S=v.statuscode,v.statecode===3||!!v.completedon){if(typeof v.statuscode=="number"&&v.statuscode!==30){const C=v.friendlymessage||v.message||`statuscode=${v.statuscode}`;throw new Error(`Asynchronous publish failed: ${C}`)}return e?.("Asynchronous publish completed successfully."),r.logInfo("publish",`PublishAllXmlAsync completed in ${$} poll(s).`),{asyncOperationId:u,statusCode:v.statuscode}}e?.(`Waiting for async publish job... (poll ${$})`),await new Promise(C=>setTimeout(C,a))}throw new Error(`Asynchronous publish timed out after ${Math.round(i/1e3)} seconds (last status: ${S??"unknown"}).`)}const Tn=[["AddressTypeCode","addresstypecode"],["City","city"],["County","county"],["Country","country"],["Fax","fax"],["FreightTermsCode","freighttermscode"],["Latitude","latitude"],["Line1","line1"],["Line2","line2"],["Line3","line3"],["Longitude","longitude"],["Name","name"],["PostalCode","postalcode"],["PostOfficeBox","postofficebox"],["PrimaryContactName","primarycontactname"],["ShippingMethodCode","shippingmethodcode"],["StateOrProvince","stateorprovince"],["Telephone1","telephone1"],["Telephone2","telephone2"],["Telephone3","telephone3"],["UPSZone","upszone"],["UTCOffset","utcoffset"],["UTCConversionTimeZoneCode","utcconversiontimezonecode"]];async function Ws(e){let n;try{n=(await J.queryData(`solutions?$select=description&$expand=publisherid&$filter=uniquename eq '${e.uniqueName.replace(/'/g,"''")}'`)).value?.[0]}catch(d){throw new Error(`Couldn't read solution ${e.uniqueName} and its publisher (${d instanceof Error?d.message:String(d)}), so nothing was imported: an import without them would clear the publisher's details.`)}const o=n?.publisherid;if(!n||!o)throw new Error(`Couldn't read solution ${e.uniqueName} and its publisher, so nothing was imported: an import without them would clear the publisher's details.`);const r=o.customizationoptionvalueprefix;if(typeof r!="number")throw new Error(`Couldn't read the option-value prefix of publisher ${e.publisherUniqueName}, so nothing was imported: a wrong one would change the publisher.`);const a=d=>typeof d=="string"?d:"",i=[1,2].map(d=>Object.fromEntries(Tn.map(([,u])=>[u,o[`address${d}_${u}`]]).filter(([,u])=>u!=null&&u!==""))).map((d,u)=>({number:u+1,...d}));return{solutionDescription:a(n.description),publisherDescription:a(o.description),publisherEmail:a(o.emailaddress),publisherWebsite:a(o.supportingwebsiteurl),publisherOptionValuePrefix:r,publisherAddresses:i.filter(d=>Object.keys(d).length>1)}}const Ks=e=>O(e).replace(/\r/g,"
").replace(/\n/g,"
").replace(/\t/g,"	"),Cn=(e,n)=>e?`<Descriptions>
|
|
2
|
-
<Description description="${Ks(e)}" languagecode="${n}"/>
|
|
3
|
-
</Descriptions>`:"<Descriptions/>",_s=e=>e.length===0?"<Addresses/>":`<Addresses>${e.map(n=>`
|
|
4
|
-
<Address>
|
|
5
|
-
<AddressNumber>${n.number}</AddressNumber>${Tn.filter(([,o])=>o in n).map(([o,r])=>`
|
|
6
|
-
<${o}>${O(String(n[r]))}</${o}>`).join("")}
|
|
7
|
-
</Address>`).join("")}
|
|
8
|
-
</Addresses>`;function Hs(e){const n=e.publisherUniqueName?.trim()||"DefaultPublisher",o=e.publisherName?.trim()||n,r=e.publisherPrefix?.trim()||"new",a=e.languageCode||1033,i=e.friendlyName?.trim()||e.uniqueName,d=e.rootComponents.length===0?"<RootComponents/>":`<RootComponents>
|
|
9
|
-
${e.rootComponents.map(u=>{const f=[`type="${u.type}"`];return u.schemaName&&f.push(`schemaName="${O(u.schemaName)}"`),u.id&&f.push(`id="{${O(u.id)}}"`),f.push(`behavior="${u.behavior}"`),`<RootComponent ${f.join(" ")} />`}).join(`
|
|
10
|
-
`)}
|
|
11
|
-
</RootComponents>`;return`<?xml version="1.0" encoding="utf-8"?>
|
|
12
|
-
<ImportExportXml version="9.1.0.0" SolutionPackageVersion="9.1" languagecode="${a}" generatedBy="CommandBarStudio">
|
|
13
|
-
<SolutionManifest>
|
|
14
|
-
<UniqueName>${O(e.uniqueName)}</UniqueName>
|
|
15
|
-
<LocalizedNames>
|
|
16
|
-
<LocalizedName description="${O(i)}" languagecode="${a}"/>
|
|
17
|
-
</LocalizedNames>
|
|
18
|
-
${Cn(e.details.solutionDescription,a)}
|
|
19
|
-
<Version>${O(e.version)}</Version>
|
|
20
|
-
<Managed>0</Managed>
|
|
21
|
-
<Publisher>
|
|
22
|
-
<UniqueName>${O(n)}</UniqueName>
|
|
23
|
-
<LocalizedNames>
|
|
24
|
-
<LocalizedName description="${O(o)}" languagecode="${a}"/>
|
|
25
|
-
</LocalizedNames>
|
|
26
|
-
${Cn(e.details.publisherDescription,a)}
|
|
27
|
-
<EMailAddress>${O(e.details.publisherEmail)}</EMailAddress>
|
|
28
|
-
<SupportingWebsiteUrl>${O(e.details.publisherWebsite)}</SupportingWebsiteUrl>
|
|
29
|
-
<CustomizationPrefix>${O(r)}</CustomizationPrefix>
|
|
30
|
-
<CustomizationOptionValuePrefix>${e.details.publisherOptionValuePrefix}</CustomizationOptionValuePrefix>
|
|
31
|
-
${_s(e.details.publisherAddresses)}
|
|
32
|
-
</Publisher>
|
|
33
|
-
${d}
|
|
34
|
-
<MissingDependencies/>
|
|
35
|
-
</SolutionManifest>
|
|
36
|
-
</ImportExportXml>`}const Gs=jn({root:{display:"flex",flexDirection:"column",gap:E.spacingVerticalS},box:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:E.spacingHorizontalM,rowGap:E.spacingVerticalXS,padding:`${E.spacingVerticalS} ${E.spacingHorizontalM}`,backgroundColor:E.colorNeutralBackground3,borderRadius:E.borderRadiusMedium},label:{color:E.colorNeutralForeground3},value:{display:"flex",flexWrap:"wrap",alignItems:"center",columnGap:E.spacingHorizontalS,minWidth:0},secondary:{color:E.colorNeutralForeground3,wordBreak:"break-all"}});function Ys({rows:e,confirmWord:n,onConfirmationChange:o,disabled:r}){const a=Gs(),[i,d]=A.useState({status:"loading"}),[u,f]=A.useState(""),$=G(j=>j.environment),S=G(j=>j.connectionUrl),v=G(j=>j.connectionVersion);A.useEffect(()=>{let j=!0;return d({status:"loading"}),Sn().then(q=>j&&d({status:"ready",connection:q})).catch(()=>j&&d({status:"ready",connection:null})),()=>{j=!1}},[$,S,v]);const m=i.status==="ready"?i.connection:null,C=ps(m?.environment),b=i.status==="ready"&&Ve(m?.environment),w=i.status==="ready"&&(!b||bs(u,n)),P=m?.environment;return A.useEffect(()=>{o(w,P)},[w,P,o]),t.jsxs("div",{className:a.root,children:[C&&t.jsx(X,{intent:"warning",children:t.jsxs(V,{children:[t.jsx(xs,{children:"Production environment"}),"This changes the live environment."]})}),t.jsxs("div",{className:a.box,children:[t.jsx(W,{className:a.label,children:"Environment"}),t.jsx("div",{className:a.value,children:i.status==="loading"?t.jsx(W,{children:"Reading the connection…"}):m?t.jsxs(t.Fragment,{children:[t.jsx(W,{weight:"semibold",children:m.name}),m.environment&&t.jsx($n,{size:"small",appearance:C?"filled":"tint",color:C?"warning":"informative",children:m.environment}),t.jsx(W,{size:200,className:a.secondary,children:m.url})]}):t.jsx(W,{children:"Unknown (the tool has no connection)"})}),e.map(j=>t.jsxs("div",{style:{display:"contents"},children:[t.jsx(W,{className:a.label,children:j.label}),t.jsx("div",{className:a.value,children:j.value})]},j.label))]}),b&&t.jsx(Re,{label:t.jsxs(t.Fragment,{children:["Type ",t.jsx("strong",{children:n})," to confirm"]}),hint:"Required on a Production environment.",children:t.jsx(kn,{value:u,onChange:(j,q)=>f(q.value),disabled:r,autoComplete:"off","aria-label":`Type ${n} to confirm`})})]})}const Js=jn({content:{display:"flex",flexDirection:"column",gap:E.spacingVerticalM},progressList:{display:"flex",flexDirection:"column",gap:E.spacingVerticalXS},progressRow:{display:"flex",alignItems:"center",gap:E.spacingHorizontalS}}),vn=({findings:e,showScope:n})=>t.jsx("ul",{style:{margin:`${E.spacingVerticalXS} 0 0`,paddingLeft:20},children:e.map((o,r)=>t.jsxs("li",{children:[n&&t.jsxs("strong",{children:[o.scope,": "]}),o.message]},r))}),ce=["HomepageGrid","SubGrid","Form"],Zs=3e4,rt=()=>{const e=Js(),n=Ue(s=>s.bulkPublishOpen),o=Ue(s=>s.closeBulkPublish),r=Ue(s=>s.openXmlDrawer),a=D(s=>s.ribbons),i=D(s=>s.baseline),d=D(s=>s.commands),u=D(s=>s.displayRules),f=D(s=>s.enableRules),$=D(s=>s.baselineCommands),S=D(s=>s.baselineEnableRules),v=D(s=>s.baselineDisplayRules),m=D(s=>s.locLabels),C=D(s=>s.baselineLocLabels),b=D(s=>s.layers),w=D(s=>s.pendingUnhides),P=D(s=>s.orphans),j=D(s=>s.pendingOrphanDeletes),q=D(s=>s.customisedCommandIds),Z=D(s=>s.uncustomisedCommandIds),K=D(s=>s.baseLanguageCode),Q=D(s=>s.baseLanguageUnknown),Y=D(s=>s.setLayerSnapshot),ee=D(s=>s.markPublished),k=D(s=>s.mutationsSincePublish),c=G(s=>s.activeSolution),g=G(s=>s.activeEntity),L=G(s=>s.connectionUrl),l=G(s=>s.publisherPrefix),h=G(s=>s.solutionRibbonComponentIds),R=Array.isArray(h)&&h.length>0,[y,I]=A.useState(!1),[$e,B]=A.useState({}),[N,ke]=A.useState(!1),[he,Ln]=A.useState(!1),[pe,zn]=A.useState("targeted"),[Ke,Pe]=A.useState({confirmed:!1}),Mn=se.useCallback((s,p)=>Pe({confirmed:s,environment:p}),[]),_e=Ke.confirmed,[On,He]=A.useState(0),[Ge,ae]=A.useState(""),[Ye,Un]=A.useState(""),[be,Je]=A.useState(c?.version??"1.0.0.0"),[fe,ge]=A.useState([]),[Xn,Ze]=A.useState([]),[Vn,ye]=A.useState([]),Qe=se.useMemo(()=>{const p=(be||c?.version||"1.0.0.0").split(".").map(F=>Number.parseInt(F,10)||0);for(;p.length<4;)p.push(0);return p[3]+=1,p.slice(0,4).join(".")},[c?.version,be]);se.useEffect(()=>{Je(c?.version??"1.0.0.0")},[c?.version]);const we=se.useCallback((s,p,F)=>fs({locations:s.map(M=>({current:a[M],baseline:i[M]})),excludeCommandIds:F,locLabels:m,baselineLocLabels:C,layer:b[p]??void 0,unhiddenLayerHideIds:w[p],deletedOrphans:P[p].filter(M=>j[p].includes(M.id)),customisedCommandIds:q,uncustomisedCommandIds:Z[p],commands:d,baselineCommands:$,enableRules:f,baselineEnableRules:S,displayRules:u,baselineDisplayRules:v}),[a,i,d,$,f,S,u,v,m,C,b,w,P,j,q,Z]),_=se.useMemo(()=>g?we(ce,"entity"):null,[g,we]),ne=se.useMemo(()=>{const s=new Set;if(g)for(const p of ce)for(const F of a[p].tabs)for(const M of F.groups)for(const z of Se(M))z.commandId&&s.add(z.commandId);return we(["Application"],"application",s)},[we,g,a]),re=ne.hasChanges&&R,de=[..._?.unsupported??[],...ne.unsupported],en=[..._?.warnings??[],...ne.warnings],H=[...g&&_?.hasChanges?[g.logicalName]:[],...re?["Application ribbon"]:[]],Bn=g&&_?.hasChanges?g.logicalName:"application ribbon",[Ne,xe]=A.useState("idle"),[De,Ae]=A.useState([]),[Fn,Ee]=A.useState(""),te=n&&!!c&&de.length===0&&H.length>0,nn=c?.id,sn=c?.publisherPrefix||l,tn=se.useCallback(async()=>{const s={commands:d,enableRules:f,displayRules:u,locLabels:m,baselineCommands:$,baselineEnableRules:S,baselineDisplayRules:v,publisherPrefix:sn,languageCode:K},p={lookupWebResources:M=>gs(M,nn)},F=[];if(g&&_?.hasChanges){const{findings:M}=await wn({...s,entity:{logicalName:g.logicalName,schemaName:g.schemaName},locations:ce.map(z=>({current:a[z],baseline:i[z]})),plan:_},p);F.push(...M.map(z=>({...z,scope:g.logicalName})))}if(re){const{findings:M}=await wn({...s,entity:null,locations:[{current:a.Application,baseline:i.Application}],plan:ne},p);F.push(...M.map(z=>({...z,scope:"Application ribbon"})))}return F},[g,_,ne,re,a,i,d,f,u,m,$,S,v,sn,nn,K]);se.useEffect(()=>{if(!te||y||N)return;let s=!1;return xe("running"),Ee(""),Ms(tn(),Zs).then(p=>{s||(Ae(p),xe("done"))}).catch(p=>{s||(Ae([]),Ee(p instanceof Error?p.message:String(p)),xe("failed"))}),()=>{s=!0}},[te,y,N,tn]);const le=De.filter(s=>s.severity==="error"),Ce=De.filter(s=>s.severity==="warning"),on=new Set(De.map(s=>s.scope)).size>1,an=te&&(Ne==="running"||le.length>0),qn=()=>We(async()=>{if(!c||de.length>0||H.length===0||an||!_e||Q)return;I(!0);const s=qe(),p=G.getState().connectionVersion,F=()=>G.getState().connectionVersion!==p,M=await Sn().catch(()=>null);if(F()){I(!1);return}if(Ve(M?.environment)&&!Ve(Ke.environment)){Pe({confirmed:!1}),He(x=>x+1),I(!1),Ie.getState().logWarn("publish",`${M?.name??"The connection"} is a Production environment now: type the confirmation to publish.`);return}ae(""),ge([]),ye([]),Ze(H),B(Object.fromEntries(H.map(x=>[x,"pending"])));let z=!1;const oe=[],Le={},ie=[],ve=[],rn=Ie.getState(),ue=x=>x instanceof Error?x.message:String(x),ln={commands:d,enableRules:f,displayRules:u,locLabels:m,baselineCommands:$,baselineEnableRules:S,baselineDisplayRules:v,publishCustomizations:!0,languageCode:K,solution:{uniqueName:c.uniqueName,friendlyName:c.friendlyName,version:he?Qe:be,publisherUniqueName:c.publisherUniqueName,publisherName:c.publisherName,publisherPrefix:c.publisherPrefix||l,publisherOptionValuePrefix:c.publisherOptionValuePrefix}};if(g&&_?.hasChanges){const x=g.logicalName;B(T=>({...T,[x]:"publishing"}));try{const T=await xn({...ln,guard:s,entity:{logicalName:g.logicalName,schemaName:g.schemaName,displayName:g.displayName},locations:ce.map(U=>({current:a[U],baseline:i[U]})),plan:_},U=>ae(U));oe.push(...ce),Le.entity=T.parts,ys(L,g.logicalName,T.changedKeys),T.verification&&ve.push({scope:x,result:T.verification}),B(U=>({...U,[x]:"success"}))}catch(T){z=!0,ie.push({scope:x,message:ue(T)}),rn.logError("publish",`Ribbon publish failed (${x}): ${ue(T)}`),B(U=>({...U,[x]:"error"}))}}else g&&oe.push(...ce);if(re&&!F()){const x="Application ribbon";B(T=>({...T,[x]:"publishing"}));try{const T=await xn({...ln,guard:s,entity:null,locations:[{current:a.Application,baseline:i.Application}],ribbonCustomizationIds:h??[],plan:ne},U=>ae(U));oe.push("Application"),Le.application=T.parts,T.verification&&ve.push({scope:x,result:T.verification}),B(U=>({...U,[x]:"success"}))}catch(T){z=!0,ie.push({scope:x,message:ue(T)}),rn.logError("publish",`Application ribbon publish failed: ${ue(T)}`),B(U=>({...U,[x]:"error"}))}}else ne.hasChanges||oe.push("Application");if(!z&&pe==="allAsync")try{await Fs(x=>ae(x),{guard:s})}catch(x){z=!0,ie.push({scope:"Publish all customizations",message:ue(x)})}if(F()){re&&!ie.some(x=>x.scope==="Application ribbon")&&ie.push({scope:"Application ribbon",message:"Not published: the tool's connection changed during the publish."}),ye(ve),ge(ie),ke(!1),I(!1);return}if(ee(oe,Le),g&&oe.includes("HomepageGrid")&&_?.hasChanges){const x=await mn(g.logicalName);x&&Y("entity",x)}if(oe.includes("Application")&&re){const x=await mn(null);x&&Y("application",x)}z||ae("Done."),ye(ve),ge(ie),ke(!z),I(!1)}),Te=()=>{I(!1),B({}),Ze([]),ke(!1),ae(""),ge([]),ye([]),xe("idle"),Ae([]),Ee(""),Pe({confirmed:!1}),He(s=>s+1),o()};return t.jsx(Cs,{open:n,onOpenChange:()=>!y&&Te(),children:t.jsxs(vs,{style:{maxWidth:"640px",maxHeight:"92vh",display:"flex",flexDirection:"column"},children:[t.jsx(js,{children:"Publish to Dataverse"}),t.jsxs(Rs,{style:{flex:1,minHeight:0,overflow:"hidden"},children:[t.jsx(Ss,{style:{overflowY:"auto",maxHeight:"100%"},children:t.jsxs("div",{className:e.content,children:[!c&&t.jsx(X,{intent:"warning",children:t.jsx(V,{children:"No solution selected. Please select a solution first."})}),Q&&!N&&t.jsx(X,{intent:"error",layout:"multiline",children:t.jsx(V,{children:"The organization's base language couldn't be read when the table loaded, so labels are shown in English. Reload the table before publishing: publishing now could write English texts as the base language's titles."})}),de.length>0&&!N&&t.jsx(X,{intent:"error",layout:"multiline",children:t.jsxs(V,{children:[t.jsx("strong",{children:"These changes can't be published yet. Undo them to publish:"}),t.jsx("ul",{style:{margin:`${E.spacingVerticalXS} 0 0`,paddingLeft:20},children:de.map(s=>t.jsx("li",{children:s},s))})]})}),en.length>0&&!N&&t.jsx(X,{intent:"info",layout:"multiline",children:t.jsxs(V,{children:[t.jsx("strong",{children:"Good to know:"}),t.jsx("ul",{style:{margin:`${E.spacingVerticalXS} 0 0`,paddingLeft:20},children:en.map(s=>t.jsx("li",{children:s},s))})]})}),te&&!N&&!y&&Ne==="running"&&t.jsxs("div",{className:e.progressRow,children:[t.jsx(Is,{size:"tiny"}),t.jsx(W,{children:"Checking the ribbon customizations before publishing…"})]}),te&&!N&&Ne==="failed"&&t.jsx(X,{intent:"warning",layout:"multiline",children:t.jsxs(V,{children:["The pre-publish check couldn't complete (",Fn,"). Publishing runs the check again before anything is imported."]})}),te&&!N&&le.length>0&&t.jsx(X,{intent:"error",layout:"multiline",children:t.jsxs(V,{children:[t.jsxs("strong",{children:["Publishing is blocked: the pre-publish check found ",le.length," error",le.length!==1?"s":"",". Fix"," ",le.length!==1?"them":"it",", then reopen this dialog:"]}),t.jsx(vn,{findings:le,showScope:on})]})}),te&&!N&&Ce.length>0&&t.jsx(X,{intent:"warning",layout:"multiline",children:t.jsxs(V,{children:[t.jsxs("strong",{children:[Ce.length," warning",Ce.length!==1?"s":""," — you can still publish:"]}),t.jsx(vn,{findings:Ce,showScope:on})]})}),ne.hasChanges&&!R&&!N&&t.jsx(X,{intent:"warning",layout:"multiline",children:t.jsxs(V,{children:["You changed the Application ribbon, but this solution doesn't include the Application Ribbons component, so those changes stay pending. In make.powerapps.com open the solution, choose ",t.jsx("strong",{children:"Add existing → Application Ribbons"}),", then reload here."]})}),t.jsx(X,{intent:"info",layout:"multiline",children:t.jsxs(V,{children:["Publishing writes this table's complete ribbon customization: what is already published, plus your changes. Ribbon changes on this table that were imported elsewhere but ",t.jsx("strong",{children:"not published"})," are published first, so they are kept. Publishing takes about 1–4 minutes (the ribbon is imported twice so Unified Interface picks up the change). Users may need to refresh the page, or navigate away and back, to see the update. You have ",t.jsx("strong",{children:k})," change(s) since the last publish."]})}),fe.length>0&&t.jsx(X,{intent:"error",layout:"multiline",children:t.jsxs(V,{children:[t.jsxs("strong",{children:["Publish failed (",fe.length," error",fe.length!==1?"s":"",")"]}),t.jsx("ul",{style:{margin:`${E.spacingVerticalXS} 0 0`,paddingLeft:20},children:fe.map((s,p)=>t.jsxs("li",{style:{fontFamily:E.fontFamilyMonospace},children:[t.jsxs("strong",{children:[s.scope,":"]})," ",s.message]},p))}),t.jsxs("div",{style:{marginTop:E.spacingVerticalS},children:["Full details are in the ",t.jsx("strong",{children:"Console"})," tab of the bottom panel."]})]})}),!y&&!N&&t.jsxs(t.Fragment,{children:[t.jsx(Ys,{rows:[{label:"Solution",value:c?t.jsx(W,{weight:"semibold",children:c.friendlyName||c.uniqueName}):t.jsx(W,{children:"None selected"})},{label:"Will publish",value:t.jsx(W,{weight:"semibold",children:H.length>0?H.join(", "):"nothing (there are no changes to publish)"})},{label:"Writes",value:t.jsxs(W,{children:["Publishes ",H.length===1?"it":"them"," first (keeps changes imported elsewhere but not published),"," ",H.length===1?"imports its":"imports each one's"," ribbon customization twice, replacing what the solution's layer has, then publishes"," ",pe==="allAsync"?"every unpublished customization in the environment":H.length===1?"it":"them","."]})}],confirmWord:Bn,onConfirmationChange:Mn},On),t.jsx(Re,{label:"Afterwards",children:t.jsxs($s,{value:pe==="targeted"?"Publish only these ribbons":"Also publish all customizations (PublishAllXmlAsync)",selectedOptions:[pe],onOptionSelect:(s,p)=>{(p.optionValue==="targeted"||p.optionValue==="allAsync")&&zn(p.optionValue)},children:[t.jsx(hn,{value:"targeted",children:"Publish only these ribbons"}),t.jsx(hn,{value:"allAsync",children:"Also publish all customizations (PublishAllXmlAsync)"})]})}),t.jsx(Re,{label:"Solution version",children:t.jsx(kn,{size:"small",value:he?Qe:be,onChange:(s,p)=>Je(p.value),disabled:he})}),t.jsx(ks,{label:"Increment solution version",checked:he,onChange:(s,p)=>Ln(p.checked===!0)}),t.jsx(Re,{label:"Publish comment",children:t.jsx(Ps,{resize:"vertical",value:Ye,onChange:(s,p)=>Un(p.value)})}),t.jsx(Xe,{appearance:"subtle",onClick:()=>{r(),Te()},children:"View RibbonDiffXml"})]}),N&&t.jsx(X,{intent:"info",layout:"multiline",children:t.jsx(V,{children:"Unified Interface caches command bars by metadata version, and publishing a ribbon doesn't always change that version. If the app still shows the old command bar, hard-refresh the page (Ctrl+F5) or sign out and back in; it can take several minutes to appear for users who already had the table open."})}),Vn.map(s=>t.jsx(X,{intent:s.result.ok?"success":"warning",layout:"multiline",children:t.jsxs(V,{children:[t.jsxs("strong",{children:[s.scope,":"]})," ",s.result.message]})},s.scope)),(y||N)&&t.jsxs("div",{className:e.progressList,children:[Xn.map(s=>{const p=$e[s]??"pending";return t.jsxs("div",{className:e.progressRow,children:[t.jsx($n,{appearance:"filled",color:p==="success"?"success":p==="error"?"danger":p==="publishing"?"informative":"subtle",size:"small",children:p}),t.jsx(W,{children:s}),p==="publishing"&&t.jsx(Ns,{thickness:"large",style:{flex:1}})]},s)}),Ge&&t.jsx(X,{intent:"info",children:t.jsx(V,{children:Ge})})]})]})}),t.jsxs(Ds,{children:[t.jsx(Xe,{appearance:"secondary",onClick:Te,disabled:y,children:N?"Close":"Cancel"}),!N&&t.jsx(Xe,{appearance:"primary",onClick:()=>{qn()},disabled:y||!c||H.length===0||de.length>0||an||!_e||Q,children:y?"Publishing...":"Publish"})]})]})]})})};export{rt as BulkPublishModal,rt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as e,h as R,z as Ae,cq as de}from"./fluent-icons-DUgjkNjy.js";import{a as N,u as x,i as Pe,b as Be,d as We,C as $e,w as Le,E as Te,e as Oe,f as Ve,h as He,j as Ue,k as _e}from"./index-DUEHURiA.js";import{a as m}from"./monaco-BIO15LCS.js";import{C as ue}from"./CrmParameterEditor-CQD0gNNH.js";import{M as Xe}from"./MonacoEditor-DGzdcWNE.js";import{ai as Je,aj as qe,ak as Ge,b as d,t as n,d as u,al as Ye,ac as Ke,ad as S,a7 as _,F as j,S as X,B as M,M as y,f as C,I as B}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";import"./crmParameters-rgfZhhzN.js";const Qe=Ae({drawer:{width:"640px",maxWidth:"90vw"},body:{display:"flex",flexDirection:"column",gap:n.spacingVerticalS,padding:n.spacingVerticalM,overflowY:"auto"},actionCard:{border:`1px solid ${n.colorNeutralStroke2}`,borderRadius:n.borderRadiusMedium,padding:n.spacingVerticalM,display:"flex",flexDirection:"column",gap:n.spacingVerticalS},actionHeader:{display:"flex",alignItems:"center",justifyContent:"space-between"},row:{display:"flex",gap:n.spacingHorizontalS,alignItems:"flex-end"},ruleRow:{display:"inline-flex",alignItems:"center",gap:n.spacingHorizontalXS},ruleRemoveBtn:{minWidth:"20px",width:"20px",height:"20px"},ruleChip:{cursor:"pointer"},rulePills:{display:"flex",flexWrap:"wrap",gap:n.spacingHorizontalXS},versionsList:{display:"flex",flexDirection:"column",gap:n.spacingVerticalXS},versionRow:{border:`1px solid ${n.colorNeutralStroke2}`,borderRadius:n.borderRadiusMedium,padding:n.spacingVerticalXS,display:"flex",justifyContent:"space-between",gap:n.spacingHorizontalS},versionMeta:{fontSize:n.fontSizeBase100,color:n.colorNeutralForeground3},securityNote:{fontSize:n.fontSizeBase100},readOnly:{border:"none",margin:0,padding:0,minWidth:0,display:"flex",flexDirection:"column",gap:n.spacingVerticalS},codePanel:{border:`1px solid ${n.colorNeutralStroke2}`,borderRadius:n.borderRadiusMedium,padding:n.spacingVerticalS,display:"flex",flexDirection:"column",gap:n.spacingVerticalS}}),os=()=>{const r=Qe(),W=N(s=>s.commandEditorOpen),z=N(s=>s.commandEditorId),I=N(s=>s.closeCommandEditor),me=N(s=>s.openCommandEditor),J=N(s=>s.openRuleEditor),pe=N(s=>s.openWebResourceBrowser),$=x(s=>s.commands),he=x(s=>s.upsertCommand),xe=x(s=>s.renameCommandId),q=x(s=>s.ribbons),G=x(s=>s.displayRules),Y=x(s=>s.enableRules),be=x(s=>s.past),je=x(s=>s.upsertEnableRule),fe=x(s=>s.upsertDisplayRule),[f,ge]=m.useState("actions"),[p,K]=m.useState(""),[ve,Q]=m.useState(""),[ye,Z]=m.useState(""),[ee,L]=m.useState(null),[E,se]=m.useState(!1),[ae,k]=m.useState(!1),[T,g]=m.useState(null),[ne,O]=m.useState(null),[re,F]=m.useState(""),[Ce,D]=m.useState(!1),[w,le]=m.useState(null),l=$.find(s=>s.id===z),we=Pe(Be(l?.id)),Re=s=>{const a=s.trim();return a.startsWith("$webresource:")?a.slice(13).trim():a},Ne=s=>{if(!s)return"";const a=Uint8Array.from(atob(s),o=>o.charCodeAt(0));return new TextDecoder().decode(a)},Se=s=>{const a=new TextEncoder().encode(s);let o="";for(let i=0;i<a.length;i+=1)o+=String.fromCharCode(a[i]);return btoa(o)},ze=s=>{const a=s.split(".").pop()?.toLowerCase()??"";return{html:1,css:2,js:3,xml:4,png:5,jpg:6,gif:7,xsl:9,ico:10,svg:11,resx:12}[a]??3};m.useEffect(()=>{l&&K(l.id)},[l]),m.useEffect(()=>{W&&z&&!l&&I()},[W,z,l,I]);const A=m.useMemo(()=>l?p.trim()?/\s/.test(p)?"Command ID cannot contain whitespace.":p!==l.id&&$.some(s=>s.id.toLowerCase()===p.toLowerCase())?"A command with this ID already exists.":"":"Command ID is required.":"",[p,l,$]),V=m.useMemo(()=>Object.entries(q).flatMap(([s,a])=>a.tabs.flatMap(o=>o.groups.flatMap(i=>We(i).filter(c=>c.commandId===z).map(c=>({location:s,tab:o,group:i,button:c}))))),[q,z]),ie=V.length;if(!l)return null;const oe=async(s,a)=>{const o=l.actions[s];if(!o||o.kind!=="javascript")return;const i=Re(o.library);if(!i){g("JavaScript library must be a valid $webresource path."),L(s),se(a),F(""),le(null);return}L(s),se(a),k(!0),g(null),O(null),D(!1),le(i);try{const c=await Ve(i);if(!c){F(""),g(`Web resource not found: ${i}`);return}const t=await He(c.id);F(Ne(t))}catch(c){g(c instanceof Error?c.message:"Failed to load web resource content."),F("")}finally{k(!1)}},Ee=async()=>{if(!E||ee===null||!w)return;const s=_e();k(!0),g(null),O(null);try{const a=await Ue(w,Se(re),ze(w),{displayName:w.split("/").pop(),guard:s});O(a.solutionWarning??null),D(!1)}catch(a){g(a instanceof Error?a.message:"Failed to save web resource content.")}finally{k(!1)}},v=s=>{he({...l,...s})},b=(s,a)=>{const o=[...l.actions];o[s]=a,v({actions:o})},P=s=>{v({actions:l.actions.filter((a,o)=>o!==s)})},H=s=>{const a=s==="javascript"?{kind:"javascript",library:"",functionName:"",params:[]}:{kind:"url",address:"https://",params:[]};v({actions:[...l.actions,a]})},Fe=(s,a)=>{const o=ee===a;if(s.kind==="javascript")return e.jsxs("div",{className:r.actionCard,children:[e.jsxs("div",{className:r.actionHeader,children:[e.jsx(M,{appearance:"filled",color:"success",size:"small",children:"JavaScript"}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(R,{}),onClick:()=>P(a),"aria-label":"Remove action"})]}),e.jsx(j,{label:"Library (Web Resource)",children:e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsx(B,{style:{flex:1},value:s.library,onChange:(i,c)=>b(a,{...s,library:c.value.replace(/^(\s*\$webresource:\s*)+/i,"$webresource:")}),placeholder:"$webresource:publisher_/scripts/myfile.js"}),e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{Le.set(i=>{b(a,{...s,library:`$webresource:${i.name}`})}),pe()},children:"Browse…"})]})}),e.jsx(j,{label:"Function name",children:e.jsx(B,{value:s.functionName,onChange:(i,c)=>b(a,{...s,functionName:c.value}),placeholder:"MyNamespace.myFunction"})}),e.jsx(y,{intent:"info",children:e.jsx(C,{children:"Read-only function preview and Monaco editing are available in the web resource browser integration path."})}),e.jsx(_,{children:"Parameters (positional)"}),e.jsx(ue,{params:s.params,onChange:i=>b(a,{...s,params:i}),urlMode:!1}),e.jsxs("div",{className:r.row,children:[e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{oe(a,!1)},children:"Function preview"}),e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{oe(a,!0)},children:"Open in Monaco"})]}),o&&e.jsxs("div",{className:r.codePanel,children:[e.jsxs("div",{className:r.row,children:[e.jsx(d,{weight:"semibold",children:E?"Monaco Editor":"Function Preview"}),w&&e.jsx(d,{size:200,style:{fontFamily:n.fontFamilyMonospace},children:w})]}),T&&e.jsx(y,{intent:"error",children:e.jsx(C,{children:T})}),ne&&e.jsx(y,{intent:"warning",children:e.jsx(C,{children:ne})}),ae?e.jsx(d,{style:{color:n.colorNeutralForeground3},children:"Loading source…"}):e.jsx("div",{style:{height:240},children:e.jsx(Xe,{language:"javascript",value:re,readOnly:!E,onChange:i=>{F(i),D(!0)},options:{wordWrap:"on"}})}),e.jsxs("div",{className:r.row,children:[e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{L(null),g(null),D(!1)},children:"Close"}),E&&e.jsx(Te,{prefix:"Saves to"}),E&&e.jsx(u,{appearance:"primary",size:"small",onClick:()=>{Ee()},disabled:!Ce||ae||!!T,children:"Save Web Resource"})]})]})]},a);if(s.kind==="url"){const i=s.address.trim().startsWith("https://");return e.jsxs("div",{className:r.actionCard,children:[e.jsxs("div",{className:r.actionHeader,children:[e.jsx(M,{appearance:"filled",color:"informative",size:"small",children:"URL"}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(R,{}),onClick:()=>P(a),"aria-label":"Remove action"})]}),e.jsx(y,{intent:"warning",children:e.jsx(C,{children:e.jsx(d,{className:r.securityNote,children:"⚠ Ampersands in URLs are automatically escaped as & in the generated XML."})})}),e.jsx(j,{label:"Address",validationState:i?"none":"error",validationMessage:i?void 0:"URL must start with https://",children:e.jsx(B,{value:s.address,onChange:(c,t)=>b(a,{...s,address:t.value}),placeholder:"https://..."})}),e.jsx(j,{label:"Open in (WinMode)",children:e.jsxs(X,{value:String(s.winMode??0),onChange:(c,t)=>b(a,{...s,winMode:parseInt(t.value)}),children:[e.jsx("option",{value:"0",children:"Navigate (0)"}),e.jsx("option",{value:"1",children:"Dialog (1)"}),e.jsx("option",{value:"2",children:"Popup (2)"})]})}),e.jsx(j,{children:e.jsxs(u,{appearance:s.passParams?"primary":"subtle",size:"small",onClick:()=>b(a,{...s,passParams:s.passParams?void 0:!0}),children:[s.passParams?"✓ PassParams ON":"PassParams OFF"," — appends typename, type, id, orgname…"]})}),e.jsx(_,{children:"Parameters (named)"}),e.jsx(ue,{params:s.params,onChange:c=>b(a,{...s,params:c}),urlMode:!0})]},a)}return s.kind==="powerFx"||s.kind==="customApi"?e.jsxs("div",{className:r.actionCard,children:[e.jsxs("div",{className:r.actionHeader,children:[e.jsxs(M,{appearance:"filled",color:"danger",size:"small",children:[s.kind==="powerFx"?"Power Fx":"Custom API"," — not supported"]}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(R,{}),onClick:()=>P(a),"aria-label":"Remove action"})]}),e.jsx(y,{intent:"error",children:e.jsxs(C,{children:["Classic ribbon commands can't run"," ",s.kind==="powerFx"?"Power Fx":"Custom API"," actions, so this command can't be published while it has one. Remove it and use a JavaScript function instead (for example, call the API with ",e.jsx("code",{children:"Xrm.WebApi.online.execute"}),"), or build the command with modern commanding in the app designer."]})})]},a):s.kind==="outlookCommand"||s.kind==="raw"?e.jsxs("div",{className:r.actionCard,children:[e.jsxs("div",{className:r.actionHeader,children:[e.jsx(M,{appearance:"outline",size:"small",children:s.kind==="outlookCommand"?"Outlook command":s.tagName}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(R,{}),onClick:()=>P(a),"aria-label":"Remove action"})]}),e.jsx(d,{size:200,style:{color:n.colorNeutralForeground3},children:s.kind==="outlookCommand"?`ActionType="${s.actionType}"${s.data?` Data="${s.data}"`:""}`:s.xml})]},a):null},Me=()=>e.jsxs(e.Fragment,{children:[l.actions.map((s,a)=>Fe(s,a)),l.actions.length===0&&e.jsx(d,{italic:!0,style:{color:n.colorNeutralForeground3},children:"No actions defined — button will do nothing when clicked."}),e.jsxs("div",{className:r.row,children:[e.jsx(j,{label:"Action type",style:{minWidth:"220px"},children:e.jsxs(X,{onChange:(s,a)=>{const o=a.value;o&&H(o)},value:"",children:[e.jsx("option",{value:"",children:"Add action..."}),e.jsx("option",{value:"javascript",children:"JavaScript function"}),e.jsx("option",{value:"url",children:"URL action"})]})}),e.jsx(u,{icon:e.jsx(de,{}),appearance:"secondary",size:"small",onClick:()=>H("javascript"),children:"Add JavaScript function"}),e.jsx(u,{icon:e.jsx(de,{}),appearance:"secondary",size:"small",onClick:()=>H("url"),children:"Add URL action"})]})]}),Ie=()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{label:"Command ID",children:e.jsx(B,{value:p,onChange:(s,a)=>K(a.value),style:{fontFamily:n.fontFamilyMonospace}})}),A&&e.jsx(d,{style:{color:n.colorPaletteRedForeground1,fontSize:n.fontSizeBase100},children:A}),e.jsx(u,{appearance:"secondary",size:"small",disabled:!p.trim()||!!A||p===l.id,onClick:()=>{if(!p.trim()||A)return;const s=p.trim();xe(l.id,s)&&me(s)},children:"Apply ID change"}),e.jsx(d,{style:{color:n.colorNeutralForeground3,fontSize:n.fontSizeBase200},children:"Naming convention: Publisher.EntityName.ButtonName.Command"}),e.jsx(y,{intent:"warning",children:e.jsx(C,{children:e.jsxs(d,{className:r.securityNote,children:["⚠ ",e.jsx("strong",{children:"Security:"})," All command definitions are visible in browser source regardless of button visibility. Do not embed sensitive logic, credentials, or privileged information in command parameters or function names."]})})})]}),te=s=>{const a=s==="enable"?l.enableRules:l.displayRules,o=(s==="enable"?Y:G).map(t=>t.id).filter(t=>!a.includes(t)),i=s==="enable"?ve:ye,c=()=>{const t=new Set([...Y.map(U=>U.id),...G.map(U=>U.id)]),h=Oe("New",s==="enable"?"Enable":"Display",t);s==="enable"?je({id:h,steps:[]}):fe({id:h,steps:[]}),J(h,s)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:r.rulePills,children:[a.map(t=>e.jsxs("div",{className:r.ruleRow,children:[e.jsx(M,{appearance:"outline",size:"medium",className:r.ruleChip,onClick:()=>J(t,s),role:"button",tabIndex:0,children:t}),e.jsx(u,{appearance:"subtle",size:"small",className:r.ruleRemoveBtn,icon:e.jsx(R,{}),"aria-label":`Unbind ${t}`,onClick:()=>{v(s==="enable"?{enableRules:l.enableRules.filter(h=>h!==t)}:{displayRules:l.displayRules.filter(h=>h!==t)})}})]},t)),a.length===0&&e.jsxs(d,{italic:!0,style:{color:n.colorNeutralForeground3},children:["No ",s," rules — always ",s==="enable"?"enabled":"visible","."]})]}),e.jsxs("div",{className:r.row,children:[e.jsx(j,{label:`Bind existing ${s} rule`,style:{minWidth:"260px"},children:e.jsxs(X,{value:i,onChange:(t,h)=>s==="enable"?Q(h.value):Z(h.value),children:[e.jsx("option",{value:"",children:"Select a rule…"}),o.map(t=>e.jsx("option",{value:t,children:t},t))]})}),e.jsx(u,{appearance:"secondary",size:"small",disabled:!i,onClick:()=>{i&&(s==="enable"?(v({enableRules:[...l.enableRules,i]}),Q("")):(v({displayRules:[...l.displayRules,i]}),Z("")))},children:"Bind selected"}),e.jsxs(u,{appearance:"subtle",size:"small",onClick:c,children:["Create new ",s," rule"]})]}),s==="enable"&&e.jsx(y,{intent:"info",children:e.jsxs(C,{children:["Disabled buttons are ",e.jsx("strong",{children:"hidden"})," in the modern command bar (Unified Interface). In the classic ribbon, disabled buttons remain visible but do not respond to clicks."]})})]})},ke=()=>e.jsxs(e.Fragment,{children:[e.jsxs(d,{children:["Referenced by ",e.jsx("strong",{children:ie})," button(s)."]}),V.length>0&&e.jsx("div",{className:r.versionsList,children:V.map(s=>e.jsx("div",{className:r.versionRow,children:e.jsxs("div",{children:[e.jsx(d,{weight:"semibold",style:{fontFamily:n.fontFamilyMonospace},children:s.button.id}),e.jsxs(d,{className:r.versionMeta,children:[s.location," → ",s.tab.label," → ",s.group.label]})]})},`${s.location}:${s.tab.id}:${s.group.id}:${s.button.id}`))})]}),ce=be.filter(s=>s.target===l.id||s.detail.includes(l.id)).slice().reverse(),De=()=>e.jsx(e.Fragment,{children:ce.length===0?e.jsx(d,{style:{color:n.colorNeutralForeground3},children:"No command-specific history entries yet."}):e.jsx("div",{className:r.versionsList,children:ce.map((s,a)=>e.jsxs("div",{className:r.versionRow,children:[e.jsxs("div",{children:[e.jsx(d,{weight:"semibold",children:s.op}),e.jsx(d,{className:r.versionMeta,children:s.detail})]}),e.jsx(d,{className:r.versionMeta,children:new Date(s.ts).toLocaleString()})]},`${s.ts}-${a}`))})});return e.jsxs(Je,{position:"end",open:W,onOpenChange:()=>I(),className:r.drawer,children:[e.jsx(qe,{children:e.jsx(Ge,{action:e.jsx(u,{appearance:"subtle",icon:e.jsx(R,{}),onClick:I,"aria-label":"Close command editor"}),children:e.jsx(d,{size:400,weight:"semibold",style:{fontFamily:n.fontFamilyMonospace},children:l.id})})}),e.jsxs(Ye,{className:r.body,children:[e.jsxs(Ke,{selectedValue:f,onTabSelect:(s,a)=>ge(a.value),children:[e.jsx(S,{value:"actions",children:"Actions"}),e.jsx(S,{value:"enableRules",children:"Enable rules"}),e.jsx(S,{value:"displayRules",children:"Display rules"}),e.jsx(S,{value:"settings",children:"Settings"}),e.jsxs(S,{value:"references",children:["References (",ie,")"]}),e.jsx(S,{value:"versions",children:"Versions"})]}),e.jsx(_,{}),e.jsx($e,{commandId:l.id}),e.jsxs("fieldset",{disabled:we,className:r.readOnly,children:[f==="actions"&&Me(),f==="enableRules"&&te("enable"),f==="displayRules"&&te("display"),f==="settings"&&Ie()]}),f==="references"&&ke(),f==="versions"&&De()]})]})};export{os as CommandEditorPanel,os as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as a,E as te,z as oe}from"./fluent-icons-DUgjkNjy.js";import{a as u}from"./monaco-BIO15LCS.js";import{a as s,u as c,Y as ae,am as ne,aa as f,ah as se,an as ie,d as le}from"./index-DUEHURiA.js";import{t,B as re,b as C}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const ce=oe({backdrop:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.5)",zIndex:1e3,display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:"10vh"},palette:{width:"640px",maxWidth:"90vw",backgroundColor:t.colorNeutralBackground1,borderRadius:t.borderRadiusLarge,boxShadow:t.shadow64,overflow:"hidden"},searchRow:{display:"flex",alignItems:"center",padding:`${t.spacingVerticalM} ${t.spacingHorizontalM}`,borderBottom:`1px solid ${t.colorNeutralStroke1}`,gap:t.spacingHorizontalS},searchInput:{flex:1,border:"none",outline:"none",fontSize:t.fontSizeBase400,backgroundColor:"transparent"},results:{maxHeight:"400px",overflowY:"auto"},group:{paddingTop:t.spacingVerticalXS},groupLabel:{padding:`${t.spacingVerticalXXS} ${t.spacingHorizontalM}`,color:t.colorNeutralForeground3,fontSize:t.fontSizeBase100,fontWeight:t.fontWeightSemibold,textTransform:"uppercase",letterSpacing:"0.08em"},item:{display:"flex",alignItems:"center",gap:t.spacingHorizontalS,padding:`${t.spacingVerticalXS} ${t.spacingHorizontalM}`,cursor:"pointer","&:hover":{backgroundColor:t.colorNeutralBackground1Hover}},itemSelected:{backgroundColor:t.colorNeutralBackground1Hover},itemLabel:{flex:1},itemSub:{color:t.colorNeutralForeground3,fontSize:t.fontSizeBase200},footer:{padding:`${t.spacingVerticalXS} ${t.spacingHorizontalM}`,borderTop:`1px solid ${t.colorNeutralStroke1}`,color:t.colorNeutralForeground3,fontSize:t.fontSizeBase100,display:"flex",gap:t.spacingHorizontalL}}),he=()=>{const i=ce(),x=s(e=>e.commandPaletteOpen),N=s(e=>e.setCommandPaletteOpen),X=s(e=>e.openBulkPublish),D=s(e=>e.openXmlDrawer),p=s(e=>e.openImportXml),T=s(e=>e.openCommandEditor),v=s(e=>e.openRuleEditor),H=s(e=>e.openNewGroup),O=s(e=>e.openNewButton),P=s(e=>e.openLocalizationEditor),$=s(e=>e.themeMode),W=s(e=>e.setThemeMode),G=c(e=>e.undo),V=c(e=>e.redo),F=c(e=>e.commands),U=c(e=>e.displayRules),q=c(e=>e.enableRules),I=c(e=>e.ribbons),K=ae(e=>e.entities),A=ne(e=>e.requestEntitySwitch),Q=f(e=>e.location),Y=f(e=>e.tabId),b=f(e=>e.selectedButtonId),j=f(e=>e.selectedGroupId),[l,z]=u.useState(""),[k,d]=u.useState(0),E=u.useRef(null),n=u.useCallback(()=>{N(!1),z(""),d(0)},[N]);u.useEffect(()=>{x&&setTimeout(()=>E.current?.focus(),50)},[x]);const Z=()=>{const e=[],r=I[Q].tabs.find(o=>o.id===Y),_=r?.groups[0]?.id??null,w=j??_,R=se(ie(r?.groups.find(o=>o.id===j),b)?.kind),ee=[{id:"publish",label:"Publish all",subtitle:"Save and publish changes to Dataverse",kind:"action",action:()=>{X(),n()}},{id:"view-xml",label:"View RibbonDiffXml",subtitle:"Open XML drawer",kind:"action",action:()=>{D(),n()}},{id:"import-xml",label:"Import XML",subtitle:"Import RibbonDiffXml from clipboard",kind:"action",action:()=>{n();const o="Couldn't read the clipboard here: paste the XML into the editor (Ctrl+V).",h=navigator.clipboard?.readText?.();if(!h)return p("",o);h.then(g=>g.trim().startsWith("<")?p(g):p("","The clipboard doesn't hold XML: paste the XML into the editor."),()=>p("",o))}},{id:"new-group",label:"New group",subtitle:"Create a new ribbon group in current tab",kind:"action",action:()=>{H(),n()}},{id:"new-button",label:"New button",subtitle:w?"Create a new button in selected/current group":"Select a tab/group with at least one group first",kind:"action",action:()=>{w&&(O(w),n())}},{id:"edit-labels",label:"Edit localized labels",subtitle:R?"The selected control is shown read-only":b?"Open localization editor for selected button":"Select a button first",kind:"action",action:()=>{!b||R||(P(b),n())}},{id:"toggle-theme",label:`Toggle theme (${$==="dark"?"Dark":"Light"})`,subtitle:"Switch between light and dark",kind:"action",action:()=>{W($==="dark"?"light":"dark"),n()}},{id:"undo",label:"Undo",subtitle:"Ctrl+Z",kind:"action",action:()=>{G(),n()}},{id:"redo",label:"Redo",subtitle:"Ctrl+Shift+Z",kind:"action",action:()=>{V(),n()}}];if(e.push(...ee),!l.startsWith("@")&&!l.startsWith("/")){const o=Object.entries(I).flatMap(([h,g])=>g.tabs.flatMap(B=>B.groups.flatMap(L=>le(L).map(y=>({id:`btn-${y.id}`,label:y.label||y.id,subtitle:`${h} → ${B.label} → ${L.label}`,kind:"button",action:()=>{n()}})))));e.push(...o.slice(0,20))}return F.forEach(o=>{e.push({id:`cmd-${o.id}`,label:o.id,subtitle:`${o.actions.length} action(s)`,kind:"command",action:()=>{T(o.id),n()}})}),U.forEach(o=>{e.push({id:`dr-${o.id}`,label:o.id,subtitle:`Display rule — ${o.steps.length} step(s)`,kind:"rule",action:()=>{v(o.id,"display"),n()}})}),q.forEach(o=>{e.push({id:`er-${o.id}`,label:o.id,subtitle:`Enable rule — ${o.steps.length} step(s)`,kind:"rule",action:()=>{v(o.id,"enable"),n()}})}),(l.startsWith("@")||!l)&&K.slice(0,30).forEach(o=>{e.push({id:`ent-${o.logicalName}`,label:o.displayName,subtitle:o.logicalName,kind:"entity",action:()=>{A(o),n()}})}),e},S=l.startsWith("@")||l.startsWith("/")?l.slice(1):l,M=Z(),m=S?M.filter(e=>e.label.toLowerCase().includes(S.toLowerCase())||(e.subtitle??"").toLowerCase().includes(S.toLowerCase())):M,J=e=>{e.key==="ArrowDown"?(e.preventDefault(),d(r=>Math.min(r+1,m.length-1))):e.key==="ArrowUp"?(e.preventDefault(),d(r=>Math.max(r-1,0))):e.key==="Enter"?m[k]?.action():e.key==="Escape"&&n()};return x?a.jsx("div",{className:i.backdrop,onClick:n,role:"presentation",children:a.jsxs("div",{className:i.palette,onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[a.jsxs("div",{className:i.searchRow,children:[a.jsx(te,{style:{color:t.colorNeutralForeground3,flexShrink:0}}),a.jsx("input",{ref:E,className:i.searchInput,value:l,onChange:e=>{z(e.target.value),d(0)},onKeyDown:J,placeholder:"Search commands, buttons, entities… Use @ for entities, / for actions","aria-label":"Command palette search"})]}),a.jsxs("div",{className:i.results,role:"listbox",children:[m.map((e,r)=>a.jsxs("div",{className:`${i.item} ${r===k?i.itemSelected:""}`,onClick:e.action,role:"option","aria-selected":r===k,onMouseEnter:()=>d(r),children:[a.jsx(re,{appearance:"outline",size:"small",children:e.kind}),a.jsxs("div",{className:i.itemLabel,children:[a.jsx(C,{children:e.label}),e.subtitle&&a.jsx(C,{className:i.itemSub,block:!0,children:e.subtitle})]})]},e.id)),m.length===0&&a.jsx("div",{className:i.item,children:a.jsx(C,{style:{color:t.colorNeutralForeground3},children:"No results"})})]}),a.jsxs("div",{className:i.footer,children:[a.jsx("span",{children:"↑↓ navigate"}),a.jsx("span",{children:"↵ select"}),a.jsx("span",{children:"Esc close"}),a.jsx("span",{children:"@ entities"}),a.jsx("span",{children:"/ actions"})]})]})}):null};export{he as CommandPalette,he as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as e,s as h,A as P,h as g,cq as y,z as f}from"./fluent-icons-DUgjkNjy.js";import{U as j}from"./crmParameters-rgfZhhzN.js";import{S as v,F as I,I as S,an as k,B as b,d as u,b as R,t as o}from"./fluent-ui-Dde22_ZN.js";const N=f({root:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS},param:{display:"flex",gap:o.spacingHorizontalS,alignItems:"flex-end",padding:o.spacingVerticalXS,border:`1px solid ${o.colorNeutralStroke2}`,borderRadius:o.borderRadiusMedium},typeSelect:{width:"140px",flexShrink:0},valueField:{flex:1},actions:{display:"flex",gap:o.spacingHorizontalXS,flexShrink:0},addButton:{alignSelf:"flex-start"},hint:{color:o.colorNeutralForeground3,fontSize:o.fontSizeBase100}}),A=[{label:"Context",values:["PrimaryControl","PrimaryControlId","SelectedControl","CommandProperties"]},{label:"Record",values:["PrimaryEntityTypeCode","PrimaryEntityTypeName","FirstPrimaryItemId","PrimaryItemIds"]},{label:"Selection context",values:["SelectedEntityTypeCode","SelectedEntityTypeName","FirstSelectedItemId"]},{label:"Grid selection",values:["SelectedControlSelectedItemCount","SelectedControlSelectedItemIds","SelectedControlSelectedItemReferences","SelectedControlAllItemCount","SelectedControlAllItemIds","SelectedControlAllItemReferences","SelectedControlUnselectedItemCount","SelectedControlUnselectedItemIds","SelectedControlUnselectedItemReferences"]},{label:"Org/User",values:["OrgName","OrgLcid","UserLcid"]}],B=({params:c,onChange:d,urlMode:m=!1})=>{const i=N(),s=(l,t)=>{const r=[...c];r[l]=t,d(r)},C=l=>{d(c.filter((t,r)=>r!==l))},x=(l,t)=>{const r=[...c],a=l+t;a<0||a>=r.length||([r[l],r[a]]=[r[a],r[l]],d(r))},p=()=>{d([...c,{kind:"CrmParameter",value:"PrimaryControl"}])};return e.jsxs("div",{className:i.root,children:[c.map((l,t)=>e.jsxs("div",{className:i.param,children:[e.jsx("div",{className:i.typeSelect,children:e.jsxs(v,{value:l.kind,onChange:(r,a)=>{const n=a.value;n==="CrmParameter"?s(t,{kind:n,value:"PrimaryControl"}):n==="BoolParameter"?s(t,{kind:n,value:!1}):n==="IntParameter"||n==="DecimalParameter"?s(t,{kind:n,value:0}):s(t,{kind:"StringParameter",value:""})},children:[e.jsx("option",{value:"CrmParameter",children:"CrmParameter"}),e.jsx("option",{value:"StringParameter",children:"String"}),e.jsx("option",{value:"BoolParameter",children:"Boolean"}),e.jsx("option",{value:"IntParameter",children:"Integer"}),e.jsx("option",{value:"DecimalParameter",children:"Decimal"})]})}),m&&e.jsx(I,{label:"Name (querystring key)",style:{width:"130px",flexShrink:0},children:e.jsx(S,{value:l.name??"",onChange:(r,a)=>s(t,{...l,name:a.value||void 0}),placeholder:"key"})}),e.jsx("div",{className:i.valueField,children:l.kind==="CrmParameter"?e.jsx(v,{value:l.value,onChange:(r,a)=>s(t,{...l,value:a.value}),children:A.map(r=>r.values.filter(a=>!m||!j.has(a)).map(a=>e.jsx("option",{value:a,children:a},a)))}):l.kind==="BoolParameter"?e.jsx(k,{checked:l.value,onChange:(r,a)=>s(t,{...l,value:a.checked}),label:"true"}):e.jsx(S,{type:l.kind==="StringParameter"?"text":"number",value:String(l.value),onChange:(r,a)=>{const n=l.kind==="StringParameter"?a.value:l.kind==="IntParameter"?parseInt(a.value):parseFloat(a.value);s(t,{...l,value:n})}})}),m&&l.kind==="CrmParameter"&&!l.name&&e.jsx(b,{appearance:"filled",color:"warning",size:"small",title:"Name required for URL actions"}),e.jsxs("div",{className:i.actions,children:[e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(h,{}),onClick:()=>x(t,-1),disabled:t===0,"aria-label":"Move up"}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(P,{}),onClick:()=>x(t,1),disabled:t===c.length-1,"aria-label":"Move down"}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(g,{}),onClick:()=>C(t),"aria-label":"Remove parameter"})]})]},t)),m&&e.jsxs(R,{className:i.hint,children:["For URL actions, each CrmParameter must have a ",e.jsx("code",{children:"name"})," attribute (querystring key)."]}),e.jsx(u,{className:i.addButton,appearance:"secondary",size:"small",icon:e.jsx(y,{}),onClick:p,children:"Add parameter"})]})};export{B as C};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as r}from"./fluent-icons-DUgjkNjy.js";import{a as i,u as n,aD as u,aE as c,an as b}from"./index-DUEHURiA.js";import"./monaco-BIO15LCS.js";import"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const h=()=>{const o=i(e=>e.hideInsteadOfDelete),a=i(e=>e.closeHideInsteadOfDelete),s=i(e=>e.announce),t=n(e=>o?b(e.ribbons[o.location].tabs.find(d=>d.id===o.tabId)?.groups.find(d=>d.id===o.groupId),o.buttonId):void 0),l=n(e=>o?e.baseline[o.location]:void 0);return!o||!t||!l?null:r.jsx(u,{open:!0,buttonLabel:t.label,commandId:t.commandId,deleteBlockedReason:c(t,l),onConfirmHide:()=>{n.getState().hideOobButton(o.location,o.tabId,o.groupId,o.buttonId),s("Button hidden"),a()},onConfirmDisplayRule:()=>{n.getState().hideWithDisplayRules(t.commandId)&&s("Button hidden"),a()},onCancel:a})};export{h as HideInsteadOfDeleteModal,h as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as o,h as ge,E as Y,L as pe,z as me}from"./fluent-icons-DUgjkNjy.js";import{u as he}from"./useReplaceWebResourceConfirm-Mb36NTI7.js";import{a as Z,u as be,aa as j,Y as Q,l as K,as as fe,at as J,au as ye,E as we,j as Se,av as xe,O as D,aw as ke,ax as Ce,ay as ve,k as L}from"./index-DUEHURiA.js";import{a as l,R as ee}from"./monaco-BIO15LCS.js";import{D as Re,i as je,k as Ie,j as Be,aa as Ae,d as I,l as Ne,ac as Pe,ad as W,I as M,C as $e,O as Te,a1 as Ee,t as r,b as p,B as Fe,m as ze}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const De=[{category:"Actions",keywords:["Add","Delete","Edit","Save","Copy","Paste","Undo","Redo","Send","Print","Refresh"]},{category:"Communication",keywords:["Mail","Chat","Phone","Call","Message"]},{category:"Navigation",keywords:["Arrow","Chevron","Navigation","Home","Back","Forward"]},{category:"System",keywords:["Settings","Info","Warning","Dismiss","Question","Checkmark","Error"]},{category:"Security",keywords:["Lock","Shield","Key","Fingerprint"]},{category:"People",keywords:["Person","People","Contact","User"]},{category:"Business",keywords:["Building","Briefcase","Money","Credit","Cart","Tag","Receipt"]},{category:"Files",keywords:["Document","Folder","Attach","Upload","Download","File"]},{category:"Web",keywords:["Globe","Link","Open","Browser","World"]},{category:"Time",keywords:["Calendar","Clock","Timer","History"]},{category:"Rating",keywords:["Star","Heart","Thumb"]},{category:"View",keywords:["Eye","Zoom","View","Window","Preview"]},{category:"Layout",keywords:["Grid","List","Table","Panel","Column","Row"]},{category:"Development",keywords:["Code","Bug","Branch","Wrench","Tool","Terminal"]},{category:"Media",keywords:["Play","Pause","Stop","Video","Audio","Camera"]},{category:"Analytics",keywords:["Chart","Data","Poll","Graph","Trend"]}],Le=["Add","Delete","Edit","Save","Copy","Cut","ClipboardPaste","Share","Mail","Chat","Phone","Search","Filter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","ChevronDown","ChevronUp","Navigation","Home","Settings","Info","Warning","Checkmark","Dismiss","QuestionCircle","LockClosed","LockOpen","Shield","Person","People","PersonAdd","Building","Briefcase","Money","CreditCard","Cart","Tag","Document","DocumentBulletList","Folder","FolderOpen","Attach","ArrowDownload","ArrowUpload","Globe","Link","Open","Calendar","Clock","Timer","Star","Heart","ThumbLike","ThumbDislike","Eye","EyeOff","ZoomIn","ZoomOut","Maximize","Minimize","Grid","List","Table","TableSimple","Code","Bug","Play","Pause","Stop","Refresh","ArrowSync","ArrowUndo","ArrowRedo","Printer","Send","Rocket","Sparkle","Trophy","Lightbulb","Bot","DataBar","ChartMultiple","Poll"];function We(n){for(const y of De)if(y.keywords.some(m=>n.includes(m)))return y.category;return"General"}const oe=Le.map(n=>({name:n,category:We(n)})),Me=["All",...Array.from(new Set(oe.map(n=>n.category))).sort()],He=me({surface:{width:"720px",maxWidth:"95vw",height:"min(580px, 90vh)",maxHeight:"90vh",overflow:"hidden"},dialogBody:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},body:{display:"flex",flexDirection:"column",flex:1,minHeight:0,overflow:"hidden",gap:r.spacingHorizontalS},toolbar:{display:"flex",alignItems:"center",gap:r.spacingHorizontalS,flexWrap:"wrap",flexShrink:0},categoryPicker:{minWidth:"180px",maxWidth:"220px"},iconGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(72px, 1fr))",gap:r.spacingHorizontalXS,overflowY:"auto",flex:1,minHeight:0,padding:r.spacingHorizontalXS},iconTile:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",padding:r.spacingHorizontalXS,borderRadius:r.borderRadiusMedium,border:"1px solid transparent",cursor:"pointer",minHeight:"64px",":hover":{backgroundColor:r.colorNeutralBackground3,border:`1px solid ${r.colorNeutralStroke1}`}},iconTileSelected:{backgroundColor:r.colorBrandBackground2,border:`1px solid ${r.colorBrandStroke1}`},iconLabel:{fontSize:r.fontSizeBase100,textAlign:"center",lineHeight:1.2,wordBreak:"break-word",color:r.colorNeutralForeground2},webResourceList:{flex:1,overflowY:"auto"},webResourceRow:{display:"flex",alignItems:"center",gap:r.spacingHorizontalS,padding:`${r.spacingHorizontalXS} ${r.spacingHorizontalS}`,cursor:"pointer",borderRadius:r.borderRadiusMedium,":hover":{backgroundColor:r.colorNeutralBackground3}},uploadArea:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:r.spacingHorizontalM,border:`2px dashed ${r.colorNeutralStroke2}`,borderRadius:r.borderRadiusMedium,color:r.colorNeutralForeground3}}),Xe=()=>{const n=He(),y=he(),m=Z(e=>e.iconPickerOpen),w=Z(e=>e.closeIconPicker),H=be(e=>e.setButtonProp),C=j(e=>e.selectedButtonId),v=j(e=>e.selectedGroupId),U=j(e=>e.tabId),G=j(e=>e.location),B=Q(e=>e.publisherPrefix),S=Q(e=>e.activeSolution),[O,c]=l.useState(null),[V,A]=l.useState(null),[u,_]=l.useState("fluent"),[N,re]=l.useState(""),[R,ae]=l.useState("All"),[x,se]=l.useState("regular"),[i,ne]=l.useState(null),[g,P]=l.useState(""),[$,T]=l.useState([]),[q,X]=l.useState(!1),[E,te]=l.useState(""),[b,f]=l.useState(!1);ee.useEffect(()=>{m||(c(null),A(null))},[m]),ee.useEffect(()=>{!m||u!=="webresource"||(X(!0),K("svg").then(e=>T(e)).catch(()=>T([])).finally(()=>X(!1)))},[m,u]);const le=l.useMemo(()=>{const e=E.toLowerCase();return $.filter(a=>!e||a.name.toLowerCase().includes(e))},[E,$]),ie=l.useMemo(()=>{const e=N.toLowerCase();return oe.filter(a=>(R==="All"||a.category===R)&&(e===""||a.name.toLowerCase().includes(e)))},[N,R]),ce=async()=>{if(!i||!C||!v)return;const e=L(),a=D.getState();if(c(null),!S||S.isManaged){c("Select an unmanaged solution first — the icon is added to it as an SVG web resource.");return}f(!0);try{const s=await ke(i,x,B,Ce,{busy:{onProgress:t=>a.logInfo("webresource",t)},guard:e});s.publishError&&a.logWarn("webresource",`Publishing icon web resource ${s.name} failed: ${s.publishError}. Pick the icon again or publish customizations before using the button.`),H(G,U,v,C,{icon:J(i),image16:`$webresource:${s.name}`,image32:`$webresource:${s.name}`}),a.logInfo("webresource",`${s.created?"Uploaded":"Reusing"} icon web resource ${s.name} (solution ${S.uniqueName}).`),w()}catch(s){const t=s instanceof Error?s.message:String(s);a.logError("webresource",`Fluent icon "${i}" could not be added as a web resource: ${t}`),c(`Could not add the icon as a web resource: ${t}`)}finally{f(!1)}},de=async()=>{if(!g||!C||!v)return;const e=L(),a=D.getState();c(null),A(null);const s=g.startsWith("$webresource:")?g.slice(13).trim():null;let t=null;if(s){f(!0);try{const h=$.find(F=>F.name===s),d=await ve(s,h,e);d.solutionUniqueName&&a.logInfo("webresource",`Added web resource ${s} to solution ${d.solutionUniqueName}.`),t=d.solutionWarning??null}catch(h){const d=h instanceof Error?h.message:String(h);if(/^No web resource named /.test(d)){c(d);return}t=`The icon was set, but ${s} could not be added to the solution: ${d}`,a.logError("webresource",t)}finally{f(!1)}}if(H(G,U,v,C,{image16:g,image32:g}),t){A(t);return}w()},ue=async e=>{const a=L();if(!S||S.isManaged){c("Select an unmanaged solution first — the SVG is added to it as a web resource.");return}c(null),f(!0);try{const s=await new Promise((d,F)=>{const k=new FileReader;k.onerror=()=>F(k.error??new Error("Failed to read SVG")),k.onload=()=>{const z=String(k.result??"");d(z.includes(",")?z.split(",")[1]??"":z)},k.readAsDataURL(e)}),t=`${B||"new"}_/icons/${e.name}`;await Se(t,s,11,{displayName:e.name,guard:a,onExisting:y.onExisting}),P(`$webresource:${t}`),_("webresource");const h=await K("svg");T(h)}catch(s){if(s instanceof xe)return;const t=s instanceof Error?s.message:String(s);D.getState().logError("webresource",`SVG upload failed: ${t}`),c(`Upload failed: ${t}`)}finally{f(!1)}};return o.jsxs(o.Fragment,{children:[y.dialog,o.jsx(Re,{open:m,onOpenChange:(e,a)=>!a.open&&w(),children:o.jsx(je,{className:n.surface,children:o.jsxs(Ie,{className:n.dialogBody,children:[o.jsx(Be,{action:o.jsx(I,{appearance:"subtle",icon:o.jsx(ge,{}),onClick:w,"aria-label":"Close"}),children:o.jsx(Ae,{children:"Choose Icon"})}),o.jsxs(Ne,{className:n.body,children:[o.jsxs(Pe,{selectedValue:u,onTabSelect:(e,a)=>_(a.value),size:"small",children:[o.jsx(W,{value:"fluent",children:"Fluent icons"}),o.jsx(W,{value:"webresource",children:"Web resources"}),o.jsx(W,{value:"upload",children:"Upload SVG"})]}),u==="fluent"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:n.toolbar,children:[o.jsx(M,{contentBefore:o.jsx(Y,{}),placeholder:"Search icons…",value:N,onChange:(e,a)=>re(a.value),size:"small",style:{flex:1}}),o.jsx($e,{className:n.categoryPicker,placeholder:"Category",value:R,onOptionSelect:(e,a)=>ae(String(a.optionValue??"All")),children:Me.map(e=>o.jsx(Te,{value:e,text:e,children:e},e))}),o.jsx(Ee,{label:x==="regular"?"Regular":"Filled",checked:x==="filled",onChange:(e,a)=>se(a.checked?"filled":"regular")})]}),o.jsx("div",{className:n.iconGrid,children:ie.map(e=>o.jsxs("div",{className:`${n.iconTile} ${i===e.name?n.iconTileSelected:""}`,onClick:()=>ne(e.name),role:"option","aria-selected":i===e.name,title:`${e.name} — ${e.category}`,children:[o.jsx(fe,{name:J(e.name),size:24,variant:x}),o.jsx("span",{className:n.iconLabel,children:e.name})]},e.name))}),i&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:r.spacingHorizontalS,padding:r.spacingHorizontalXS,backgroundColor:r.colorNeutralBackground3,borderRadius:r.borderRadiusMedium,flexShrink:0},children:[o.jsxs(p,{size:200,style:{fontFamily:r.fontFamilyMonospace},children:['ModernImage="$webresource:',ye(B||"new",i,x),'"']}),o.jsx(Fe,{appearance:"tint",color:"success",children:"Selected"})]})]}),u==="webresource"&&o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:r.spacingHorizontalS,flex:1},children:[o.jsx(M,{contentBefore:o.jsx(Y,{}),placeholder:"Search SVG web resources...",value:E,onChange:(e,a)=>te(a.value),size:"small"}),o.jsxs("div",{className:n.webResourceList,children:[q&&o.jsx(p,{size:200,style:{color:r.colorNeutralForeground3},children:"Loading web resources..."}),!q&&le.slice(0,200).map(e=>{const a=`$webresource:${e.name}`,s=g===a;return o.jsx("div",{className:n.webResourceRow,onClick:()=>P(a),style:{backgroundColor:s?r.colorBrandBackground2:void 0},children:o.jsx(p,{size:200,style:{fontFamily:r.fontFamilyMonospace},children:a})},e.id)})]}),o.jsx(M,{placeholder:"$webresource:publisher_/icons/…",value:g,onChange:(e,a)=>P(a.value)}),o.jsx(p,{size:100,style:{color:r.colorNeutralForeground3},children:"Both image16 and image32 will be set to this path. Use SVG for best results across all DPI levels."})]}),u==="upload"&&o.jsxs("div",{className:n.uploadArea,children:[o.jsx(pe,{fontSize:48,style:{opacity:.4}}),o.jsx(p,{children:"Drag an SVG file here, or click to browse"}),o.jsx(p,{size:200,style:{color:r.colorNeutralForeground3},children:"The file will be uploaded as a web resource in the active solution."}),o.jsx("input",{type:"file",accept:".svg",style:{display:"none"},id:"icon-upload-input",disabled:b,onChange:e=>{const a=e.target.files?.[0];e.target.value="",a&&ue(a)}}),o.jsx("label",{htmlFor:"icon-upload-input",style:{display:"inline-block",cursor:"pointer",padding:"6px 12px",background:r.colorBrandBackground,color:r.colorNeutralForegroundOnBrand,borderRadius:r.borderRadiusMedium,fontSize:r.fontSizeBase300},children:b?"Uploading...":"Browse for SVG"})]}),O&&o.jsx(p,{role:"alert",size:200,style:{color:r.colorPaletteRedForeground1,flexShrink:0},children:O}),V&&o.jsxs(p,{role:"status",size:200,style:{color:r.colorPaletteMarigoldForeground1,flexShrink:0},children:["Icon applied. ",V]})]}),o.jsxs(ze,{children:[o.jsx(we,{prefix:"Saves to"}),o.jsx("div",{style:{flex:1}}),o.jsx(I,{appearance:"secondary",onClick:w,children:"Cancel"}),u==="fluent"&&o.jsx(I,{appearance:"primary",disabled:!i||b,onClick:()=>{ce()},children:b?"Adding icon…":`Use ${i??"icon"}`}),u==="webresource"&&o.jsx(I,{appearance:"primary",disabled:!g||b,onClick:()=>{de()},children:b?"Adding icon…":"Use web resource"})]})]})})})]})};export{Xe as IconPickerModal,Xe as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as t,h as q,cq as G,co as J,z as V,cB as Y}from"./fluent-icons-DUgjkNjy.js";import{R as N,a as L}from"./monaco-BIO15LCS.js";import{a as T,u as v,d as Q,ao as I,ap as Z,aq as ee,ar as te}from"./index-DUEHURiA.js";import{D as ae,i as le,k as oe,j as ne,aa as ie,B as F,d as z,l as se,I as re,b as O,t as i,T as X,m as de}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const S={1033:{name:"English (US)",flag:"🇺🇸"},1031:{name:"German",flag:"🇩🇪"},1034:{name:"Spanish",flag:"🇪🇸"},1036:{name:"French",flag:"🇫🇷"},1040:{name:"Italian",flag:"🇮🇹"},1041:{name:"Japanese",flag:"🇯🇵"},1042:{name:"Korean",flag:"🇰🇷"},1043:{name:"Dutch",flag:"🇳🇱"},1044:{name:"Norwegian",flag:"🇳🇴"},1045:{name:"Polish",flag:"🇵🇱"},1046:{name:"Portuguese (Brazil)",flag:"🇧🇷"},1049:{name:"Russian",flag:"🇷🇺"},1053:{name:"Swedish",flag:"🇸🇪"},1054:{name:"Thai",flag:"🇹🇭"},1055:{name:"Turkish",flag:"🇹🇷"},1057:{name:"Indonesian",flag:"🇮🇩"},1058:{name:"Ukrainian",flag:"🇺🇦"},1066:{name:"Vietnamese",flag:"🇻🇳"},2052:{name:"Chinese (Simplified)",flag:"🇨🇳"},3082:{name:"Spanish (Spain)",flag:"🇪🇸"}},ce=Object.keys(S).map(Number),ge=V({surface:{width:"760px",maxWidth:"95vw",maxHeight:"80vh"},body:{display:"flex",flexDirection:"column",gap:i.spacingHorizontalM,overflowY:"auto"},chipRow:{display:"flex",flexWrap:"wrap",gap:i.spacingHorizontalXS,alignItems:"center"},chip:{cursor:"pointer",userSelect:"none"},table:{width:"100%",borderCollapse:"collapse"},th:{textAlign:"left",fontSize:i.fontSizeBase100,fontWeight:i.fontWeightSemibold,color:i.colorNeutralForeground3,paddingBottom:i.spacingHorizontalXS,borderBottom:`1px solid ${i.colorNeutralStroke2}`},td:{verticalAlign:"top",paddingTop:i.spacingHorizontalXS,paddingBottom:i.spacingHorizontalXS,paddingRight:i.spacingHorizontalS,borderBottom:`1px solid ${i.colorNeutralStroke3}`},langCell:{whiteSpace:"nowrap",width:"160px"},actionCell:{width:"40px"},insertBreakBtn:{fontSize:i.fontSizeBase100,height:"20px",minWidth:"unset",padding:`0 ${i.spacingHorizontalXS}`},noteBar:{backgroundColor:i.colorNeutralBackground3,borderRadius:i.borderRadiusMedium,padding:`${i.spacingHorizontalXS} ${i.spacingHorizontalS}`,fontSize:i.fontSizeBase100,color:i.colorNeutralForeground3}}),xe=()=>{const n=ge(),u=T(e=>e.localizationEditorOpen),h=T(e=>e.localizationEditorButtonId),f=T(e=>e.closeLocalizationEditor),g=v(e=>e.locLabels),C=v(e=>e.upsertLocLabel),U=v(e=>e.batch),w=v(e=>e.ribbons),s=v(e=>e.baseLanguageCode),r=N.useMemo(()=>{if(h){for(const e of Object.values(w))for(const a of e.tabs)for(const l of a.groups)for(const d of Q(l))if(d.id===h)return d}},[w,h]),m=r?.source,b=r?I(m?.labelToken,Z(r.id),r.label,g,s):null,x=r?I(m?.tooltipTitleToken,ee(r.id),r.tooltipTitle,g,s):null,j=r?I(m?.tooltipBodyToken,te(r.id),r.tooltipBody,g,s):null,y=r?[[b,m?.labelToken],[x,m?.tooltipTitleToken],[j,m?.tooltipBodyToken]].filter(([e,a])=>e===null&&a).map(([,e])=>e.slice(11)).filter((e,a,l)=>l.indexOf(e)===a):[],R=L.useCallback(()=>{const e=g.find(o=>o.id===b),a=g.find(o=>o.id===x),l=g.find(o=>o.id===j),d=new Set([s]);return e?.titles.forEach(o=>d.add(o.languageCode)),a?.titles.forEach(o=>d.add(o.languageCode)),l?.titles.forEach(o=>d.add(o.languageCode)),Array.from(d).sort((o,c)=>o===s?-1:c===s?1:o-c).map(o=>({lcid:o,label:e?.titles.find(c=>c.languageCode===o)?.description??"",tooltipTitle:a?.titles.find(c=>c.languageCode===o)?.description??"",tooltipBody:l?.titles.find(c=>c.languageCode===o)?.description??""}))},[g,b,x,j,s]),[p,B]=L.useState([]),[D,E]=L.useState("");N.useEffect(()=>{u&&B(R())},[u,R]);const k=(e,a,l)=>{B(d=>d.map(o=>o.lcid===e?{...o,[a]:l}:o))},$=(e,a,l)=>{if(!l)return;const d=l.selectionStart??l.value.length,o=l.selectionEnd??l.value.length,c=p.find(P=>P.lcid===e)?.[a]??"",M=c.slice(0,d)+""+c.slice(o);k(e,a,M)},H=()=>{const e=parseInt(D,10);!e||p.find(a=>a.lcid===e)||(B(a=>[...a,{lcid:e,label:"",tooltipTitle:"",tooltipBody:""}]),E(""))},A=e=>{e!==s&&B(a=>a.filter(l=>l.lcid!==e))},_=()=>{if(!r)return;const e=a=>p.filter(l=>l[a]).map(l=>({languageCode:l.lcid,description:l[a]}));U(()=>{b&&e("label").length>0&&C({id:b,titles:e("label")}),x&&e("tooltipTitle").length>0&&C({id:x,titles:e("tooltipTitle")}),j&&e("tooltipBody").length>0&&C({id:j,titles:e("tooltipBody")})}),f()},K=p.find(e=>e.lcid===s);return t.jsx(ae,{open:u,onOpenChange:(e,a)=>!a.open&&f(),children:t.jsx(le,{className:n.surface,children:t.jsxs(oe,{children:[t.jsxs(ne,{action:t.jsx(z,{appearance:"subtle",icon:t.jsx(q,{}),onClick:f,"aria-label":"Close"}),children:[t.jsxs(ie,{children:["Translations — ",K?.label||h||"Button"]}),t.jsxs(F,{appearance:"tint",size:"small",style:{marginLeft:8},children:[p.length," language",p.length!==1?"s":""]})]}),t.jsxs(se,{className:n.body,children:[t.jsxs("div",{className:n.chipRow,children:[p.map(e=>{const a=S[e.lcid];return t.jsxs(F,{className:n.chip,appearance:e.label?"filled":"outline",color:e.label?"brand":"informative",size:"medium",children:[a?.flag??"🌐"," ",a?.name??`LCID ${e.lcid}`,e.lcid!==s&&t.jsx("span",{style:{marginLeft:4,cursor:"pointer",opacity:.7},onClick:()=>A(e.lcid),"aria-label":`Remove ${a?.name}`,children:"×"})]},e.lcid)}),t.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[t.jsx(re,{size:"small",style:{width:"180px"},placeholder:"LCID or language…",value:D,onChange:(e,a)=>E(a.value),list:"lcid-list",onKeyDown:e=>e.key==="Enter"&&H()}),t.jsx("datalist",{id:"lcid-list",children:ce.filter(e=>!p.find(a=>a.lcid===e)).map(e=>t.jsxs("option",{value:String(e),children:[S[e]?.flag," ",S[e]?.name," (",e,")"]},e))}),t.jsx(z,{size:"small",appearance:"subtle",icon:t.jsx(G,{}),onClick:H,"aria-label":"Add language"})]})]}),t.jsxs("div",{className:n.noteBar,children:["💡 LCID ",s," (",S[s]?.name??"base language",`) is the organisation's base language and cannot be removed. Use "Insert " to force a line break in long labels.`]}),y.length>0&&t.jsxs("div",{className:n.noteBar,children:[y.join(", ")," ",y.length===1?"is a label":"are labels"," of another solution, shared with the controls that use ",y.length===1?"it":"them",", so ",y.length===1?"it isn't":"they aren't"," edited here. Change the text in Properties to give this button a label of its own, then add translations."]}),t.jsxs("table",{className:n.table,children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:n.th,style:{width:"160px"},children:"Language"}),t.jsx("th",{className:n.th,children:"Label"}),t.jsx("th",{className:n.th,children:"Tooltip title"}),t.jsx("th",{className:n.th,children:"Tooltip body"}),t.jsx("th",{className:n.th,style:{width:"40px"}})]})}),t.jsx("tbody",{children:p.map(e=>{const a=S[e.lcid];return t.jsxs("tr",{children:[t.jsxs("td",{className:`${n.td} ${n.langCell}`,children:[t.jsxs(O,{size:200,children:[a?.flag??"🌐"," ",a?.name??`LCID ${e.lcid}`]}),t.jsx("br",{}),t.jsx(O,{size:100,style:{color:i.colorNeutralForeground3},children:e.lcid})]}),t.jsx("td",{className:n.td,children:t.jsx(W,{value:e.label,disabled:!b,onChange:l=>k(e.lcid,"label",l),onInsertBreak:l=>$(e.lcid,"label",l)})}),t.jsx("td",{className:n.td,children:t.jsx(W,{value:e.tooltipTitle,disabled:!x,onChange:l=>k(e.lcid,"tooltipTitle",l),onInsertBreak:l=>$(e.lcid,"tooltipTitle",l)})}),t.jsx("td",{className:n.td,children:t.jsx(pe,{value:e.tooltipBody,disabled:!j,onChange:l=>k(e.lcid,"tooltipBody",l)})}),t.jsx("td",{className:`${n.td} ${n.actionCell}`,children:e.lcid!==s&&t.jsx(X,{content:"Remove this language",relationship:"label",children:t.jsx(z,{appearance:"subtle",size:"small",icon:t.jsx(J,{}),onClick:()=>A(e.lcid),"aria-label":"Remove language"})})})]},e.lcid)})})]})]}),t.jsxs(de,{children:[t.jsx(z,{appearance:"secondary",onClick:f,children:"Cancel"}),t.jsx(z,{appearance:"primary",onClick:_,children:"Save translations"})]})]})})})};function W({value:n,disabled:u,onChange:h,onInsertBreak:f}){const g=N.useRef(null);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("input",{ref:g,style:{width:"100%",fontFamily:"inherit",fontSize:13,padding:"3px 6px",border:"1px solid var(--colorNeutralStroke1)",borderRadius:4,boxSizing:"border-box"},value:n,disabled:u,onChange:C=>h(C.target.value)}),t.jsx(X,{content:"Insert Dataverse line break ()",relationship:"label",children:t.jsxs("button",{type:"button",disabled:u,onClick:()=>f(g.current),style:{fontSize:11,border:"none",background:"none",color:"var(--colorNeutralForeground3)",cursor:"pointer",padding:0,textAlign:"left",display:"flex",alignItems:"center",gap:2},children:[t.jsx(Y,{fontSize:12})," Insert ⏎"]})})]})}function pe({value:n,disabled:u,onChange:h}){return t.jsx("textarea",{style:{width:"100%",fontFamily:"inherit",fontSize:13,padding:"3px 6px",border:"1px solid var(--colorNeutralStroke1)",borderRadius:4,boxSizing:"border-box",resize:"vertical",minHeight:"42px"},value:n,disabled:u,onChange:f=>h(f.target.value),rows:2})}export{xe as LocalizationEditor,xe as default};
|
|
@@ -1 +0,0 @@
|
|
|
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-DUEHURiA.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:"Modern"};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:"Modern",children:"Modern (Unified Interface: web, tablets and phones)"}),e.jsx("option",{value:"Refresh",children:"Refresh (legacy updated web client)"}),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"Unified Interface";case"Refresh":return"legacy updated web client";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 +0,0 @@
|
|
|
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,aa as w,u as F}from"./index-DUEHURiA.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 +0,0 @@
|
|
|
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,Y as re,l as L,az as ne,aA as te,aB as _,aC as ie,w as z,E as ce,j as de,av as ue,O as ge,k as xe}from"./index-DUEHURiA.js";import{a as t}from"./monaco-BIO15LCS.js";import{u as pe}from"./useReplaceWebResourceConfirm-Mb36NTI7.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 A,f as G,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),P=re(e=>e.publisherPrefix),E=t.useRef(null),[F,H]=t.useState([]),[v,p]=t.useState(!1),[W,M]=t.useState(!1),[$,g]=t.useState(null),[O,C]=t.useState(null),[R,X]=t.useState(""),[h,Y]=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,q=[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=>H(e)).catch(e=>g(e instanceof Error?e.message:String(e))).finally(()=>p(!1)))},[w]);const J=async()=>{p(!0),g(null);try{H(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`${P||"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)=>Y(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(A,{intent:"error",children:s.jsx(G,{children:$})}),O&&s.jsx(A,{intent:"warning",children:s.jsx(G,{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:q,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:W,onClick:()=>E.current?.click(),children:W?"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};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{y as t,Z as H,h as O,cj as V,be as z,cA as G,bc as U,z as W}from"./fluent-icons-DUgjkNjy.js";import{a as s}from"./monaco-BIO15LCS.js";import{u as p,a as v,l as _,g as K,c as Z,s as Q}from"./index-DUEHURiA.js";import{M as q}from"./MonacoEditor-DGzdcWNE.js";import{ai as J,aj as Y,ak as ee,t as d,d as ne,al as te,M,f as $,ac as re,ad as ae,am as y}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const oe=["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 A(r,g){const b=[];return b.push(r.languages.registerCompletionItemProvider("xml",{triggerCharacters:[":","$"],provideCompletionItems(l,n){const a=l.getValueInRange({startLineNumber:n.lineNumber,startColumn:1,endLineNumber:n.lineNumber,endColumn:n.column});if(!a.includes("$LocLabels:"))return{suggestions:[]};const C=a.lastIndexOf("$LocLabels:")+11,c=a.slice(C),u={startLineNumber:n.lineNumber,startColumn:n.column-c.length,endLineNumber:n.lineNumber,endColumn:n.column};return{suggestions:p.getState().locLabels.map(m=>({label:m.id,kind:r.languages.CompletionItemKind.Reference,insertText:m.id,range:u,detail:"LocLabel reference"}))}}})),b.push(r.languages.registerCompletionItemProvider("xml",{triggerCharacters:[":","$"],provideCompletionItems(l,n){const a=l.getValueInRange({startLineNumber:n.lineNumber,startColumn:1,endLineNumber:n.lineNumber,endColumn:n.column});if(!a.includes("$webresource:"))return{suggestions:[]};const C=a.lastIndexOf("$webresource:")+13,c=a.slice(C),u={startLineNumber:n.lineNumber,startColumn:n.column-c.length,endLineNumber:n.lineNumber,endColumn:n.column};return{suggestions:g().map(m=>({label:m,kind:r.languages.CompletionItemKind.File,insertText:m,range:u,detail:"Web resource"}))}}})),b.push(r.languages.registerCompletionItemProvider("xml",{triggerCharacters:['"'],provideCompletionItems(l,n){const a=l.getValueInRange({startLineNumber:n.lineNumber,startColumn:1,endLineNumber:n.lineNumber,endColumn:n.column});if(!/Command\s*=\s*"[^"]*$/.test(a))return{suggestions:[]};const c=a.match(/Command\s*=\s*"([^"]*)$/)?.[1]??"",u={startLineNumber:n.lineNumber,startColumn:n.column-c.length,endLineNumber:n.lineNumber,endColumn:n.column};return{suggestions:p.getState().commands.map(m=>({label:m.id,kind:r.languages.CompletionItemKind.Function,insertText:m.id,range:u,detail:"CommandDefinition"}))}}})),b.push(r.languages.registerCompletionItemProvider("xml",{triggerCharacters:['"'],provideCompletionItems(l,n){const a=l.getValueInRange({startLineNumber:n.lineNumber,startColumn:1,endLineNumber:n.lineNumber,endColumn:n.column});if(!/ModernImage\s*=\s*"[^"]*$/.test(a))return{suggestions:[]};const c=a.match(/ModernImage\s*=\s*"([^"]*)$/)?.[1]??"",u={startLineNumber:n.lineNumber,startColumn:n.column-c.length,endLineNumber:n.lineNumber,endColumn:n.column};return{suggestions:oe.map(i=>({label:i,kind:r.languages.CompletionItemKind.Color,insertText:i,range:u,detail:"Fluent icon (ModernImage)",documentation:`Renders the ${i}_20_Regular Fluent icon`}))}}})),b}function I(r){r.forEach(g=>g.dispose())}const se=W({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"}}),le=[{label:"Home Grid",value:"HomepageGrid"},{label:"Sub Grid",value:"SubGrid"},{label:"Form",value:"Form"},{label:"Application",value:"Application"}],Ce=()=>{const r=se(),g=v(e=>e.xmlDrawerOpen),b=v(e=>e.closeXmlDrawer),l=p(e=>e.ribbons),n=p(e=>e.baseline),a=p(e=>e.commands),C=p(e=>e.displayRules),c=p(e=>e.enableRules),u=p(e=>e.locLabels),N=v(e=>e.openImportXml),[i,m]=s.useState("HomepageGrid"),[S,h]=s.useState(null),[E,T]=s.useState(!1),f=s.useRef(0);s.useEffect(()=>{f.current++,h(null)},[i,g]);const[w,D]=s.useState([]),j=s.useRef(null),R=s.useRef(null),x=s.useRef([]);s.useEffect(()=>{g&&_().then(e=>D(e.map(o=>o.name))).catch(()=>D([]))},[g]),s.useEffect(()=>()=>{I(x.current),x.current=[]},[]);const X=s.useCallback((e,o)=>{j.current=e,R.current=o,I(x.current),x.current=A(o,()=>w)},[w]);s.useEffect(()=>{R.current&&(I(x.current),x.current=A(R.current,()=>w))},[w]);const B=()=>{j.current?.getAction("editor.action.formatDocument")?.run()},k=s.useCallback(e=>{try{return`<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
${K({location:e,current:l[e],baseline:n[e],commands:a,displayRules:C,enableRules:c,locLabels:u,entityLogicalName:l[e].entityLogicalName})}`}catch(o){return`<!-- Error generating XML: ${String(o)} -->`}},[l,n,a,C,c,u])(i);s.useEffect(()=>{f.current++,h(null)},[k]);const F=async()=>{const e=f.current,o=await Z(k);e===f.current&&h(o.ok?{intent:"success",text:"Copied the XML to the clipboard."}:{intent:"error",text:`Couldn't copy (${o.error}). Click in the XML, press Ctrl+A, then Ctrl+C.`})},P=async()=>{const e=f.current,o=`RibbonDiffXml_${i}.xml`;T(!0);try{const L=await Q(o,k,[{name:"XML",extensions:["xml"]}]);if(e!==f.current)return;L.ok&&L.path?h({intent:"success",text:`Saved to ${L.path}.`}):L.ok?h({intent:"success",text:`Started downloading ${o}. If no file appears, use Copy.`}):L.canceled?h(null):h({intent:"error",text:`Couldn't save the file (${L.error}). Use Copy instead.`})}finally{T(!1)}};return t.jsxs(J,{position:"end",open:g,onOpenChange:()=>b(),className:r.drawer,children:[t.jsx(Y,{children:t.jsxs(ee,{action:t.jsx(ne,{appearance:"subtle",icon:t.jsx(O,{}),onClick:b,"aria-label":"Close XML drawer"}),children:[t.jsx(H,{style:{marginRight:d.spacingHorizontalS}}),"RibbonDiffXml"]})}),t.jsxs(te,{className:r.body,children:[t.jsx(M,{className:r.infoBar,intent:"info",children:t.jsxs($,{children:["This is the ",t.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."]})}),t.jsx("div",{className:r.tabRow,children:t.jsx(re,{selectedValue:i,onTabSelect:(e,o)=>m(o.value),children:le.map(e=>t.jsx(ae,{value:e.value,children:e.label},e.value))})}),t.jsxs("div",{className:r.toolbar,children:[t.jsx(y,{icon:t.jsx(V,{}),onClick:()=>{F()},children:"Copy"}),t.jsx(y,{icon:t.jsx(z,{}),disabled:E,onClick:()=>{P()},children:"Download"}),t.jsx(y,{icon:t.jsx(G,{}),onClick:B,children:"Format XML"}),t.jsx(y,{icon:t.jsx(U,{}),onClick:()=>N(k),children:"Import this XML"})]}),S&&t.jsx(M,{intent:S.intent,className:r.infoBar,role:"status",children:t.jsx($,{children:S.text})}),t.jsx("div",{className:r.editorContainer,children:t.jsx(q,{language:"xml",value:k,readOnly:!0,height:"100%",onMount:X})})]})]})};export{Ce as XmlDrawer,Ce as default};
|