@mohsinonxrm/pptb-commandbar-studio 0.7.0-beta.1 → 0.7.0-beta.2
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 +48 -0
- package/README.md +7 -0
- package/dist/assets/BulkPublishModal-dGiT6nNQ.js +36 -0
- package/dist/assets/{CommandEditorPanel-1tDOtoTt.js → CommandEditorPanel-BfcpfNps.js} +1 -1
- package/dist/assets/CommandPalette-C4NOIuA3.js +1 -0
- package/dist/assets/{ConflictDrawer-CjObt6DP.js → ConflictDrawer-CW1NLdAD.js} +1 -1
- package/dist/assets/{DiffViewer-Dfu_9b4v.js → DiffViewer-R0g0dxLc.js} +1 -1
- package/dist/assets/{HideInsteadOfDeleteModal-C64qc-fw.js → HideInsteadOfDeleteModal-DbfHSKmm.js} +1 -1
- package/dist/assets/{IconPickerModal-D6hQ_Aqx.js → IconPickerModal-B1AgGWq0.js} +1 -1
- package/dist/assets/ImportXmlModal-DImDI43_.js +1 -0
- package/dist/assets/LocalizationEditor-CeAgqq85.js +1 -0
- package/dist/assets/{MonacoEditor-CBUJNFgC.js → MonacoEditor-BRCY30rO.js} +1 -1
- package/dist/assets/{NewButtonModal-B_ugATAS.js → NewButtonModal-DqdSshXe.js} +1 -1
- package/dist/assets/{NewGroupModal-Dvg8CSJr.js → NewGroupModal-VysrEsbU.js} +1 -1
- package/dist/assets/{NewTabModal-CjMNMXb5.js → NewTabModal-ChEmOjmh.js} +1 -1
- package/dist/assets/{RuleEditorPanel-B5or3M9d.js → RuleEditorPanel-C26e1gMH.js} +1 -1
- package/dist/assets/{ScalingEditorPanel-CzQtkicj.js → ScalingEditorPanel-f2Rmk9AG.js} +1 -1
- package/dist/assets/{TabDisplayRulesPanel-BqzSpzqp.js → TabDisplayRulesPanel-DR-c2-Km.js} +1 -1
- package/dist/assets/{UrlComposerModal-BDP57HQn.js → UrlComposerModal-DFwPOYL1.js} +1 -1
- package/dist/assets/{WebResourceBrowser-BK_G_Q_c.js → WebResourceBrowser-D2RMaFeZ.js} +1 -1
- package/dist/assets/XmlDrawer-DXyRtGs1.js +2 -0
- package/dist/assets/index-CKs2IGe0.js +136 -0
- package/dist/assets/{useReplaceWebResourceConfirm-Dx7RdpEN.js → useReplaceWebResourceConfirm-C4vg9hxg.js} +1 -1
- package/dist/assets/xmlValidator-TOuV4jko.js +3 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/BulkPublishModal-CF7sSmBT.js +0 -29
- package/dist/assets/CommandPalette-BBM1PJH0.js +0 -1
- package/dist/assets/ImportXmlModal-DXwUce5n.js +0 -1
- package/dist/assets/LocalizationEditor-DXqbD2ZN.js +0 -1
- package/dist/assets/XmlDrawer-C4lJ7_MF.js +0 -2
- package/dist/assets/index-CL8TmfXp.js +0 -139
- package/dist/assets/xmlValidator-DvDaU5OO.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{y as e}from"./fluent-icons-DUgjkNjy.js";import{a as r}from"./monaco-BIO15LCS.js";import{
|
|
1
|
+
import{y as e}from"./fluent-icons-DUgjkNjy.js";import{a as r}from"./monaco-BIO15LCS.js";import{Y as u,E as g}from"./index-CKs2IGe0.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-Dde22_ZN.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,3 @@
|
|
|
1
|
+
import{a5 as T,a6 as ee,a7 as te,a8 as B,a9 as ne,p as oe}from"./index-CKs2IGe0.js";import{D as se,E as ae}from"./ruleKinds-B9hACGaq.js";import{C as ie,i as re}from"./crmParameters-rgfZhhzN.js";const le=["Mscrm.HideOnModern","Mscrm.ShowOnlyOnModern"];function R(c,l){const b=c.indexOf(l);return b<0?void 0:`Line ${c.slice(0,b).split(/\r?\n/).length}`}function we(c,l,b){const d=[],y=new DOMParser().parseFromString(c,"application/xml"),$=y.querySelector("parsererror");if($){const i=$.textContent?.trim()??"Unknown",u=i.match(/line\s+(\d+)/i);return d.push({message:`XML parse error: ${i}`,lineHint:u?`Line ${u[1]}`:void 0}),d}const f=new Set([]);return y.querySelectorAll("[Id]").forEach(i=>{const u=i.getAttribute("Id")??"";if(/\s/.test(u)){const A=R(c,`Id="${u}"`);d.push({message:`Element ID "${u}" contains invalid whitespace characters`,elementId:u,lineHint:A})}}),y.querySelectorAll("[LabelText]").forEach(i=>{const u=i.getAttribute("LabelText")??"",A=u.match(/^\$LocLabels:(.+)$/);if(A&&f.size>0&&!f.has(A[1])){const g=i.getAttribute("Id")??"",I=R(c,g?`Id="${g}"`:`LabelText="${u}"`);d.push({message:`Button label reference "$LocLabels:${A[1]}" has no matching LocLabel entry`,elementId:g||void 0,lineHint:I})}}),(c.includes("& ")||c.includes(`&
|
|
2
|
+
`))&&d.push({message:'URL may contain an unescaped "&" — all ampersands in XML must be written as &',lineHint:R(c,"& ")??R(c,`&
|
|
3
|
+
`)}),y.querySelectorAll("Group").forEach(i=>{const u=[];i.querySelectorAll(":scope > Controls > Button, :scope > Controls > FlyoutAnchor, :scope > Controls > SplitButton").forEach(A=>{const g=parseInt(A.getAttribute("Sequence")??"0",10);if(u.includes(g)){const I=i.getAttribute("Id")??"?";d.push({message:`Two elements share Sequence "${g}" in group "${I}"`,elementId:I,lineHint:R(c,`Sequence="${g}"`)})}u.push(g)})}),d.push(...ce(y,c)),d}const H=new Set(["BoolParameter","CrmParameter","DecimalParameter","IntParameter","StringParameter"]);function p(c){return Array.from(c.children)}function X(c,l){return l==="enable"?se.has(c):ae.has(c)}function ce(c,l){const b=[],d=(f,i,u)=>b.push({message:f,elementId:u,lineHint:R(l,i)}),w=(f,i,u)=>b.push({message:f,elementId:u,lineHint:R(l,i),severity:"warning"}),y=c.querySelector("RibbonDiffXml > RuleDefinitions"),$=[{tag:"EnableRule",label:"Enable",container:"enable"},{tag:"DisplayRule",label:"Display",container:"display"}];for(const{tag:f,label:i,container:u}of $)y?.querySelectorAll(`:scope > ${f}s > ${f}`).forEach(A=>{const g=A.getAttribute("Id")??"",I=p(A);I.length===0&&d(`${i} rule "${g}" has no steps — the schema requires at least one`,`Id="${g}"`,g);const M=S=>{X(S.tagName,u)&&w(`${i} rule "${g}" contains ${S.tagName}, which RibbonTypes.xsd only allows in ${u==="enable"?"display":"enable"} rules`,`<${S.tagName}`,g)};for(const S of I){if(S.tagName!=="OrRule"){M(S);continue}const L=p(S);L.filter(N=>N.tagName==="Or").length<2&&d(`OrRule in ${i.toLowerCase()} rule "${g}" needs at least 2 <Or> children (found ${L.filter(N=>N.tagName==="Or").length})`,"<OrRule",g);for(const N of L){const E=p(N);E.length===0&&d(`Empty <Or> in rule "${g}"`,"<Or",g);for(const v of E)v.tagName==="OrRule"?d(`Rule "${g}": an <Or> cannot contain another OrRule`,"<OrRule",g):M(v)}}});return y||c.querySelectorAll("OrRule").forEach(f=>{const i=f.querySelectorAll(":scope > Or").length;i<2&&d(`OrRule requires at least 2 <Or> children (found ${i})`,"<OrRule")}),c.querySelectorAll("JavaScriptFunction, CustomRule").forEach(f=>{for(const i of p(f)){if(!H.has(i.tagName))continue;i.hasAttribute("Name")&&d(`${i.tagName} inside <${f.tagName}> must not have a Name attribute (only <Url> parameters are named)`,`<${i.tagName} Name=`);const u=i.getAttribute("Value")??"";i.tagName==="CrmParameter"&&!ie.has(u)&&d(`CrmParameter Value "${u}" is not a valid CrmParameterValue`,`Value="${u}"`)}}),c.querySelectorAll("Url").forEach(f=>{for(const i of p(f)){if(!H.has(i.tagName))continue;i.getAttribute("Name")||d(`${i.tagName} inside <Url> requires a Name (the query-string key)`,`<${i.tagName}`);const u=i.getAttribute("Value")??"";i.tagName==="CrmParameter"&&!re(u)&&d(`CrmParameter Value "${u}" is not allowed in a <Url> action (CrmNamedParameterValue)`,`Value="${u}"`)}}),c.querySelector("RibbonDiffXml > Scalings")&&d('<Scalings> is not allowed in RibbonDiffXml — scaling changes are CustomActions with Location="{tabId}.Scaling._children"',"<Scalings"),c.querySelectorAll("CustomAction > CommandUIDefinition > Tab").forEach(f=>{const i=f.getAttribute("Id")??"",u=p(f).map(I=>I.tagName),A=u.indexOf("Scaling"),g=u.indexOf("Groups");(A<0||g>=0&&A>g)&&d(`Tab "${i}" needs a <Scaling Id> element before <Groups>`,`Id="${i}"`,i)}),c.querySelectorAll("TabDisplayRule > DisplayRules").forEach(()=>{d("TabDisplayRule rules must be direct children — remove the <DisplayRules> wrapper","<TabDisplayRule")}),b}const ue=["LabelText","ToolTipTitle","ToolTipDescription","Alt","Title","Description"],de=new Set(["powerFx","customApi"]),fe={powerFx:"Power Fx",customApi:"Custom API"};function me(c){return[...new Set(c.actions.map(l=>l.kind).filter(l=>de.has(l)))]}const x=/^\$LocLabels:(.+)$/,Y=/^\$webresource:([^?#]+)/i,he=new Set(["ModernImage","Image16by16","Image32by32"]),F=new Set(["Tab","Group"]),Q=new Set(["main_system_library.js"]),ge=new Set(["FlyoutAnchor","SplitButton"]),pe=new Set(["Button","FlyoutAnchor","SplitButton","TextBox","ComboBox","CheckBox"]),V=/^(.+)\.Scaling\._children$/,W=c=>/^(Mscrm|Microsoft)\./.test(c);function J(c){const l=[],b=[],d=new DOMParser;for(const w of Object.keys(c))for(const[y,$]of c[w]){const f=d.parseFromString($,"application/xml");if(f.querySelector("parsererror")){b.push({severity:"error",code:"xml-parse",message:`${w} element ${y} is not well-formed XML`,elementId:y});continue}l.push({part:w,key:`${w}:${y}`,el:f.documentElement})}return{elements:l,errors:b}}function C(c){return[c,...Array.from(c.getElementsByTagName("*"))]}function Z(c){return typeof c=="string"?oe(c):c}function $e(c){let l;try{l=Z(c)}catch{return[]}const b=new Map;for(const{el:d}of J(l).elements)for(const w of C(d))for(const y of Array.from(w.attributes)){const $=Y.exec(y.value.trim())?.[1],f=$?.toLowerCase();$&&f&&!Q.has(f)&&!b.has(f)&&b.set(f,$)}return[...b.values()]}const K=c=>{const l=c.trim();return l&&!l.includes(".")?`Mscrm.Templates.${l}`:l};function Ie(c,l={}){let b;try{b=Z(c)}catch(e){return[{severity:"error",code:"xml-parse",message:e instanceof Error?e.message:String(e)}]}const{elements:d,errors:w}=J(b),y=l.changedKeys?new Set(l.changedKeys):null,$=e=>!y||y.has(e),f=new Set(l.newKeys??[]),i=(e,o,t,a,n=!1)=>{const s=(Array.isArray(o)?o:[o]).some($);w.push({severity:n||!s?"warning":"error",code:e,message:s?t:`${t} (already in the published customizations)`,elementId:a})},u=d.filter(e=>e.part==="customActions"),A=d.filter(e=>e.part==="commandDefinitions"),g=new Map((l.commands??[]).map(e=>[e.id,e]));for(const{key:e,el:o}of A){const t=o.getAttribute("Id")??"",a=g.get(t);if(!a||!$(e))continue;const n=me(a);n.length!==0&&i("dropped-action",e,`Command ${t} has a ${n.map(s=>fe[s]??s).join(" / ")} action — classic ribbon commands can't run it, so it would be dropped; remove the action`,t)}const I=new Set;for(const{el:e}of u)if(e.tagName==="CustomAction")for(const o of Array.from(e.getElementsByTagName("*")))o.getAttribute("Command")===T&&I.add(o.getAttribute("Id")??"");for(const{key:e,el:o}of u){if(o.tagName!=="HideCustomAction")continue;const t=o.getAttribute("Location")??"";!I.has(t)&&!ee({id:t,commandId:T})||i("open-record-hidden",e,`${t} is hidden, but it carries the record open override (${T}) — 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:o}of A){if(o.getAttribute("Id")!==T)continue;const t=p(o).filter(n=>n.tagName==="DisplayRules").flatMap(n=>p(n).map(s=>s.getAttribute("Id")??s.tagName));if(t.length===0)continue;const a=le.filter(n=>t.includes(n));i("open-record-hidden",e,`${T} 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`,T,!0)}for(const{key:e,el:o}of u)for(const t of Array.from(o.getElementsByTagName("*"))){if(!ge.has(t.tagName)||p(t).some(n=>n.tagName==="Menu"))continue;const a=t.getAttribute("Id")??"";if(te(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 M=new Set(l.menuControlsIds??[]);for(const{key:e,el:o}of u){const t=o.getAttribute("Location")??"",a=t.endsWith("._children")&&M.has(t.slice(0,-10));for(const n of Array.from(o.getElementsByTagName("*"))){const s=a||!!n.parentElement?.closest("Menu");for(const r of ue){const h=n.getAttribute(r);if(!h?.startsWith("$LocLabels:"))continue;const m=h.slice(11);m.length<=B||i("label-id-length",e,`${n.tagName} ${n.getAttribute("Id")??""} uses label ${m} (${m.length} characters)`+(s?`: a menu item's label id may have at most ${B} characters, or the publish fails after the import — give the control a shorter id`:`: label ids over ${B} characters fail inside menus; consider a shorter control id`),n.getAttribute("Id")??void 0,!s)}}}if(l.known?.commandIds){const e=new Set([...b.commandDefinitions.keys(),...l.known.commandIds]);for(const{key:o,el:t}of u)for(const a of Array.from(t.getElementsByTagName("*"))){const n=a.getAttribute("Command");if(!n||e.has(n)||F.has(a.tagName))continue;const s=a.getAttribute("Id")??"";i("undefined-command",o,`${a.tagName} ${s} uses command ${n}, which is defined neither in the customizations nor in the loaded ribbon`,s,W(n))}}const S={EnableRule:l.known?.enableRuleIds?new Set([...b.enableRules.keys(),...l.known.enableRuleIds]):null,DisplayRule:l.known?.displayRuleIds?new Set([...b.displayRules.keys(),...l.known.displayRuleIds]):null};for(const{key:e,el:o}of A){const t=o.getAttribute("Id")??"",a=p(o).filter(n=>n.tagName==="EnableRules"||n.tagName==="DisplayRules").flatMap(p);for(const n of a){const s=S[n.tagName],r=n.getAttribute("Id");!s||!r||s.has(r)||i("undefined-rule",e,`Command ${t} uses ${n.tagName==="EnableRule"?"enable":"display"} rule ${r}, which is defined neither in the customizations nor in the loaded ribbon`,t,W(r))}}for(const{part:e,key:o,el:t}of d){if(e!=="enableRules"&&e!=="displayRules")continue;const a=e==="enableRules"?"enable":"display",n=t.getAttribute("Id")??"",s=p(t).flatMap(r=>r.tagName==="OrRule"?p(r).filter(h=>h.tagName==="Or").flatMap(p):[r]);for(const r of s)X(r.tagName,a)&&i("rule-placement",o,`${a==="enable"?"Enable":"Display"} rule ${n} contains ${r.tagName}, which the ribbon schema only allows in ${a==="enable"?"display":"enable"} rules`,n,!0)}const L=new Set;for(const e of Object.values(l.loadedAttributes??{}))for(const o of Object.values(e))x.test(o)&&L.add(o);for(const{key:e,el:o}of d)if(o.tagName!=="LocLabel")for(const t of C(o))for(const a of Array.from(t.attributes)){const n=x.exec(a.value)?.[1];if(!n||b.locLabels.has(n))continue;const s=t.getAttribute("Id")??void 0;s&&l.loadedAttributes?.[s]?.[a.name]===a.value||L.has(a.value)||i("loclabel-missing",e,`${[t.tagName,s,a.name].filter(Boolean).join(" ")} references $LocLabels:${n}, which has no <LocLabel> in these customizations — the text won't resolve unless another solution defines the label`,s,!0)}if(l.webResources){const e=new Set;for(const{el:o}of d)for(const t of C(o))for(const a of Array.from(t.attributes)){const n=Y.exec(a.value.trim())?.[1],s=n?.toLowerCase();if(!n||!s||Q.has(s)||e.has(s))continue;const r=l.webResources[s];if(!r)continue;const h=t.getAttribute("Id")??void 0;r.exists?!r.inSolution&&!r.managed&&(e.add(s),w.push({severity:"warning",code:"webresource-not-in-solution",message:`Web resource ${n} isn't in the selected solution — the ribbon won't import into another environment without it`,elementId:h})):(e.add(s),w.push({severity:"warning",code:"webresource-missing",message:`Web resource ${n} (${t.tagName} ${a.name}) doesn't exist in this environment — ${he.has(a.name)?"the button will show no icon":"the action or rule that loads it will fail when it runs"}`,elementId:h}))}}const N=new Map,E=e=>{let o=N.get(e);return o||N.set(e,o=new Map),o};for(const[e,o]of Object.entries(l.tabScaling??{})){for(const t of o.maxSizes)E(e).set(t.id,{...t,tag:"MaxSize"});for(const t of o.scales)E(e).set(t.id,{...t,tag:"Scale"})}const v=new Map(Object.entries(l.groupTemplates??{}).map(([e,o])=>[e,K(o)])),U=new Map(Object.entries(l.templateLayouts??{}));for(const{part:e,el:o}of d)if(e==="templates")for(const t of C(o).filter(a=>a.tagName==="GroupTemplate")){const a=p(t).filter(n=>n.tagName==="Layout").map(n=>n.getAttribute("Title")??"");U.set(t.getAttribute("Id")??"",a)}const z=[];for(const{key:e,el:o}of u){for(const s of Array.from(o.getElementsByTagName("Group"))){const r=s.getAttribute("Template");r&&v.set(s.getAttribute("Id")??"",K(r))}const t=[],a=V.exec(o.getAttribute("Location")??"")?.[1],n=p(o).find(s=>s.tagName==="CommandUIDefinition");if(a&&n)for(const s of p(n))t.push([a,s]);for(const s of Array.from(o.getElementsByTagName("Tab")))for(const r of p(s).filter(h=>h.tagName==="Scaling"))for(const h of p(r))t.push([s.getAttribute("Id")??"",h]);for(const[s,r]of t){if(r.tagName!=="MaxSize"&&r.tagName!=="Scale")continue;const h={id:r.getAttribute("Id")??"",tag:r.tagName,groupId:r.getAttribute("GroupId")??"",size:r.getAttribute("Size")??"",sequence:parseInt(r.getAttribute("Sequence")??"",10),key:e};E(s).set(h.id,h),z.push(h)}}for(const[e,o]of N){const t=new Map;for(const a of o.values())Number.isNaN(a.sequence)||t.set(a.sequence,[...t.get(a.sequence)??[],a]);for(const[a,n]of t){const s=[...new Set(n.flatMap(m=>m.key?[m.key]:[]))];if(n.length<2||s.length===0)continue;const r=n.find(m=>m.key&&m.tag==="MaxSize"&&m.id===`${m.groupId}.MaxSize`),h=r?`move group ${r.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",s,`Scaling of tab ${e}: ${n.map(m=>`${m.tag} ${m.id}`).join(" and ")} have the same Sequence ${a} — Unified Interface then drops every custom control of the table; ${h}`,n.find(m=>m.key)?.id)}}for(const e of z){const o=v.get(e.groupId),t=o?U.get(o):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 ${o} used by group ${e.groupId} (${t.join(", ")})`,e.id,!0)}const G=new Set(l.known?.elementIds??[]),k=new Map;for(const{key:e,el:o}of u){if(!(o.getAttribute("Location")??"").endsWith("._children"))continue;const t=p(o).find(n=>n.tagName==="CommandUIDefinition"),a=t?p(t)[0]:void 0;if(!(!a||a.tagName==="MaxSize"||a.tagName==="Scale"))for(const n of C(a)){const s=n.getAttribute("Id");if(!s||n.closest("Scaling"))continue;const r=k.get(s)??[];r.includes(e)||k.set(s,[...r,e])}}for(const[e,o]of k)o.length>1?i("duplicate-id",o,`Id ${e} is added by more than one CustomAction (${o.map(t=>t.replace(/^customActions:ca:/,"")).join(", ")})`,e):f.has(o[0])&&G.has(e)&&i("duplicate-id",o,`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:o}=l.places,t=new Set(["Mscrm.Tabs",`Mscrm.SubGrid.${e}.ContextualTabs`]);for(const{key:a,el:n}of u){const s=n.getAttribute("Location")??"",r=/^(.+)\._children$/.exec(s)?.[1];if(!r||V.test(s)||!$(a))continue;const h=p(n).find(D=>D.tagName==="CommandUIDefinition"),m=h?p(h)[0]:void 0,O=m?.getAttribute("Id")??"";if(!m||!O||!(pe.has(m.tagName)||F.has(m.tagName)))continue;const P=r.split("{!EntityLogicalName}").join(e),q=o[P];if(q!==void 0){ne(q)&&i("orphan-location",a,`${m.tagName} ${O} is added to ${r}, on the tab ${q}: 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`,O,!0);continue}const j=D=>D.replace(/\.(Controls|Groups)$/,"");t.has(P)||[r,P,j(r),j(P)].some(D=>k.has(D))||i("orphan-location",a,`${m.tagName} ${O} is added at ${s}, but this table's ribbon has no ${r} — it won't show anywhere (check the Location, or move it to an existing group)`,O,!0)}}const _=l.publisherPrefix?.trim().toLowerCase();if(_&&f.size>0){const e=new Set([...G,...l.known?.commandIds??[],...l.known?.enableRuleIds??[],...l.known?.displayRuleIds??[]]),o=n=>{const s=n.split(".");for(let r=s.length;r>0;r--)if(e.has(s.slice(0,r).join(".")))return!0;return!1},t=n=>{const s=n.toLowerCase();return s.startsWith(`${_}.`)||s.startsWith(`${_}_`)},a=new Set;for(const{part:n,key:s,el:r}of d)if(!(!f.has(s)||n==="templates"||n==="tabDisplayRules"))for(const h of C(r)){if(h!==r&&h.closest("Actions, EnableRules, DisplayRules, EnableRule, DisplayRule"))continue;const m=h.getAttribute("Id")??h.getAttribute("HideActionId");!m||a.has(m)||t(m)||o(m)||(a.add(m),w.push({severity:"warning",code:"id-prefix",message:`${h.tagName} id ${m} doesn't start with the publisher prefix "${_}." — ids without it can collide with other solutions`,elementId:m}))}}return w}export{we as a,Ie as v,$e as w};
|
package/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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-CKs2IGe0.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/monaco-BIO15LCS.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/fluent-icons-DUgjkNjy.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="./assets/fluent-ui-Dde22_ZN.js">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mohsinonxrm/pptb-commandbar-studio",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.2",
|
|
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,29 +0,0 @@
|
|
|
1
|
-
import{y as s,z as Cn}from"./fluent-icons-DUgjkNjy.js";import{p as je,j as Bn,g as Fn,m as Le,k as Wn,n as qn,o as Kn,q as Hn,r as _n,t as Be,v as Gn,x as Yn,y as Jn,z as Zn,c as Ie,A as Qn,B as es,D as ns,F as rn,G as ss,H as ts,I as ze,J as os,K as is,L as K,h as Fe,M as Se,N as as,O as ls,P as cn,Q as rs,R as Me,S as cs,T as dn,U as ds,V as vn,W as G,X as jn,Y as us,Z as Ue,_ as ms,a as Xe,u as P,$ as hs,a0 as ps,a1 as bs,a2 as un}from"./index-CL8TmfXp.js";import{a as N,R as ne}from"./monaco-BIO15LCS.js";import{w as fs,v as Rn}from"./xmlValidator-DvDaU5OO.js";import{M as F,f as W,ae as gs,b as q,B as In,F as Re,I as Sn,t as D,D as ys,i as ws,j as xs,k as Cs,l as vs,a5 as js,ao as Rs,O as mn,a1 as Is,a6 as Ss,d as Oe,ap as $s,m as ks}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";import"./ruleKinds-B9hACGaq.js";import"./crmParameters-rgfZhhzN.js";let hn=0;async function We(e){const t=typeof window<"u"?window.toolboxAPI:void 0;hn++===0&&await pn(()=>t?.preventClose?.());try{return await e()}finally{--hn===0&&await pn(()=>t?.releasePreventClose?.())}}const Ps=2e3;async function pn(e){let t;try{await Promise.race([e(),new Promise(a=>t=setTimeout(a,Ps))])}catch{}finally{clearTimeout(t)}}function me(e,t){const a=e.match(new RegExp(`\\s${t}="([^"]*)"`));return a?a[1]:null}function bn(e,t,a){const c=e.indexOf(a,t);return e.slice(t,c===-1?void 0:c).match(/<result\s[^>]*>/g)??[]}function fn(e){const t=e.find(a=>me(a,"result")!=="success");if(t){const a=me(t,"errorcode")??"",c=me(t,"errortext")??"unknown error";return{ok:!1,message:`Dataverse rejected the ribbon (${a}): ${c}`}}return null}function Ns(e,t){if(!e)return{ok:!1,message:"The import job returned no result data, so the ribbon import could not be verified."};if(t.kind==="application"){const o=e.search(/<ribbon\s[^>]*processed="true"/);return o===-1?{ok:!1,message:"Import completed, but Dataverse did not process the application ribbon."}:fn(bn(e,o,"</ribbon>"))??{ok:!0,message:"Application ribbon imported."}}const a=new Set(t.names.filter(Boolean).map(o=>o.toLowerCase())),c=/<entityRibbon\s[^>]*>/g;let r;for(;r=c.exec(e);){const o=(me(r[0],"id")??"").toLowerCase();if(a.has(o))return me(r[0],"processed")!=="true"?{ok:!1,message:`Dataverse did not process the ribbon for ${o}.`}:fn(bn(e,r.index,"</entityRibbon>"))??{ok:!0,message:`Ribbon for ${o} imported.`}}return{ok:!1,message:`Import completed, but Dataverse did not apply a ribbon for ${t.names.join(" / ")} (no entityRibbon result in the import job). Nothing was changed.`}}const se=window.dataverseAPI;async function Ds(e,t,a){return await a("The import"),se.execute({operationName:"ImportSolution",operationType:"action",parameters:{CustomizationFile:e,ImportJobId:t,OverwriteUnmanagedCustomizations:!0,PublishWorkflows:!1}})}async function As(e,t){await t("Publishing");const a=e.map(c=>`<entity>${K(c)}</entity>`).join("");return se.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:`<importexportxml><entities>${a}</entities></importexportxml>`}})}function gn(e){const t=e.data?.progress;return!!(typeof t=="object"&&t!==null&&t.completed===!0||typeof e.progress=="number"&&e.progress>=100||typeof t=="number"&&t>=100||e.completedon||e.data?.completedon||e.statuscode===30)}function Es(e){const t=e.titles.map(a=>`<Title languagecode="${a.languageCode}" description="${K(a.description)}"/>`).join("");return`<LocLabel Id="${K(e.id)}"><Titles>${t}</Titles></LocLabel>`}async function $n(e){const t=e.entity?.logicalName??"{!EntityLogicalName}",a={deletedContainerIds:e.plan.deletedContainerIds??[],movedButtons:e.plan.movedButtons??[],editedLocLabelIds:e.plan.editedLocLabelIds??[],editedTabIds:e.plan.editedTabIds??[]},c=e.locLabels.filter(i=>a.editedLocLabelIds.includes(i.id)),r=e.languageCode??1033;for(const i of e.plan.renamedLabels??[]){const g=c.find(z=>z.id===i.id)??e.locLabels.find(z=>z.id===i.id),y=[{languageCode:r,description:i.text},...(g?.titles??[]).filter(z=>z.languageCode!==r)],w=c.findIndex(z=>z.id===i.id);w>=0?c[w]={id:i.id,titles:y}:c.push({id:i.id,titles:y})}let o=c.length?je(`<RibbonDiffXml><LocLabels>${c.map(Es).join("")}</LocLabels></RibbonDiffXml>`):Bn();for(const i of e.locations){const g=Fn({current:i.current,baseline:i.baseline,commands:e.commands,enableRules:e.enableRules,displayRules:e.displayRules,locLabels:e.locLabels,entityLogicalName:t,location:i.current.location,languageCode:e.languageCode});o=Le(o,je(g))}const u=[],m=[];for(const i of e.locations)for(const g of i.current.tabs){if(!a.editedTabIds.includes(g.id))continue;if(g.tabDisplayRules.length>0){const w=Wn(g,e.entity===null);w&&m.push(w)}const y=new Set(g.tabDisplayRules.map(w=>w.tabCommand));for(const w of i.baseline.tabs.find(z=>z.id===g.id)?.tabDisplayRules??[])y.has(w.tabCommand)||u.push(w.tabCommand)}m.length>0&&(o=Le(o,je(`<RibbonDiffXml><RuleDefinitions><TabDisplayRules>${m.join("")}</TabDisplayRules></RuleDefinitions></RibbonDiffXml>`)));const p=[...e.commands.filter(i=>e.plan.editedCommandIds.includes(i.id)).map(qn)],S={enable:e.enableRules.filter(i=>e.plan.editedEnableRuleIds.includes(i.id)).map(Hn),display:e.displayRules.filter(i=>e.plan.editedDisplayRuleIds.includes(i.id)).map(Kn)};(p.length||S.enable.length||S.display.length)&&(o=Le(o,je(`<RibbonDiffXml><CommandDefinitions>${p.join("")}</CommandDefinitions><RuleDefinitions><DisplayRules>${S.display.join("")}</DisplayRules><EnableRules>${S.enable.join("")}</EnableRules></RuleDefinitions></RibbonDiffXml>`)));const I=(i,g)=>{for(const y of Array.from(i.keys()))g.includes(y)||i.delete(y)},j=e.locations.flatMap(i=>i.current.tabs.filter(g=>!i.baseline.tabs.some(y=>y.id===g.id)).map(_n));I(o.commandDefinitions,[...e.plan.editedCommandIds,...j]),I(o.enableRules,e.plan.editedEnableRuleIds),I(o.displayRules,e.plan.editedDisplayRuleIds);const d=await Be(e.entity?.logicalName??null),b=Gn(d),v=e.plan.deletedButtonIds.filter(i=>!b.has(i));if(v.length>0)throw new Error(`Can't delete ${v.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 C=Yn(d),$=a.deletedContainerIds.filter(i=>!C.has(i));if($.length>0)throw new Error(`Can't delete ${$.join(", ")}: not added by this table's unmanaged customizations (it comes from a managed solution or the platform). Undo the delete.`);const R=a.movedButtons.filter(i=>!b.has(i.id)).map(i=>i.id);if(R.length>0)throw new Error(`Can't move ${R.join(", ")}: not defined in this table's unmanaged customizations. Undo the move.`);const U=Jn(d),Y=(e.plan.uncustomisedCommandIds??[]).filter(i=>d.commandDefinitions.has(i)&&!Zn(i,U));if(Y.length>0)throw new Error(`Can't uncustomise ${Y.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 J=new Set;for(const i of e.locations)for(const g of i.current.tabs)for(const y of g.groups)for(const w of Ie(y))for(const z of Qn(w))J.add(z);const Z=e.plan.uncustomisedCommandIds??[],Q=new Set,X=new Set;for(const i of e.commands)if(!(!J.has(i.id)||Z.includes(i.id))){i.enableRules.forEach(g=>Q.add(g)),i.displayRules.forEach(g=>X.add(g));for(const g of i.rawRuleRefs??[]){const y=/^\s*<(EnableRule|DisplayRule)\b[^>]*?\sId="([^"]+)"/.exec(g.xml);y&&(y[1]==="EnableRule"?Q:X).add(y[2])}}let l=es(d,o,{retainedCommandIds:J,editedCommandIds:e.plan.editedCommandIds,editedEnableRuleIds:e.plan.editedEnableRuleIds,editedDisplayRuleIds:e.plan.editedDisplayRuleIds,deletedControlIds:e.plan.deletedButtonIds,unhiddenControlIds:e.plan.unhiddenButtonIds,deletedContainerIds:a.deletedContainerIds,movedControls:a.movedButtons,removedTabCommands:u,uncustomisedCommandIds:Z,retainedEnableRuleIds:Q,retainedDisplayRuleIds:X});for(const i of e.plan.renamedLabels??[])i.newLabel&&(l=ns(l,i.containerId,`$LocLabels:${i.id}`));const f=new Set([...rn(d),...rn(l)].map(i=>i.id)),L={};for(const i of e.locations)for(const[g,y]of Object.entries(i.baseline.scalingByTab??{}))L[g]={maxSizes:y.maxSizes.filter(w=>!f.has(w.id)).map(w=>w.sequence),scales:y.scales.filter(w=>!f.has(w.id)).map(w=>w.sequence)};const E=ss(l,L);if(E.problems.length>0)throw new Error(`Not published: ${E.problems.join("; ")}.`);return l=E.parts,{scalingChanges:E.changes,xml:os(l),parts:l,elementCount:ze(l),preservedCount:ze(d),changedCount:ze(o),changedKeys:ts(d,l),newKeys:Object.keys(l).flatMap(i=>Array.from(l[i].keys()).filter(g=>!d[i].has(g)).map(g=>`${i}:${g}`)),layerDefinitionIds:{commandIds:Array.from(d.commandDefinitions.keys()),enableRuleIds:Array.from(d.enableRules.keys()),displayRuleIds:Array.from(d.displayRules.keys())},layer:d}}function kn(e,t){const a=[],c={},r={},o={},u={},m=new Set,p=new Set,S=new Set;for(const{current:d,baseline:b}of e.locations)for(const v of[b,d])for(const C of v.tabs)for(const $ of C.groups)for(const R of Ie($))for(const U of R.menu?.sections??[])S.add(U.controlsId);for(const{current:d,baseline:b}of e.locations){Object.assign(o,b.templateLayouts);for(const v of b.tabs){a.push(v.id),v.label&&(u[v.id]={Title:v.label});for(const C of v.groups){m.add(C.id),a.push(C.id),C.label&&(u[C.id]={Title:C.label,Label:C.label});for(const $ of Ie(C))a.push($.id),$.source&&(u[$.id]=$.source.attributes)}}for(const v of d.tabs)for(const C of v.groups)p.add(C.id);for(const v of[b,d])for(const C of v.tabs)for(const $ of C.groups)$.template&&(r[$.id]=$.template)}const I=d=>m.has(d.groupId)&&!p.has(d.groupId);for(const{baseline:d}of e.locations)for(const[b,v]of Object.entries(d.scalingByTab??{}))c[b]={...v,maxSizes:v.maxSizes.filter(C=>!I(C)),scales:v.scales.filter(C=>!I(C))};const j=(d,b)=>{if(!d)return;const v=new Set(b??[]);return d.map(C=>C.id).filter(C=>!v.has(C))};return{changedKeys:t.changedKeys,newKeys:t.newKeys,commands:e.commands,known:{commandIds:j(e.baselineCommands,t.layerDefinitionIds?.commandIds),enableRuleIds:j(e.baselineEnableRules,t.layerDefinitionIds?.enableRuleIds),displayRuleIds:j(e.baselineDisplayRules,t.layerDefinitionIds?.displayRuleIds),elementIds:a},loadedAttributes:u,publisherPrefix:e.publisherPrefix,tabScaling:c,groupTemplates:r,templateLayouts:o,menuControlsIds:S,...e.entity?{places:{entityLogicalName:e.entity.logicalName,tabByCollection:Object.fromEntries(is(e.locations.map(d=>d.baseline),e.entity.logicalName))}}:{}}}function Ts(e,t){return new Promise((a,c)=>{const r=setTimeout(()=>c(new Error(`it didn't finish within ${Math.round(t/1e3)} s`)),t);e.then(o=>{clearTimeout(r),a(o)},o=>{clearTimeout(r),c(o)})})}async function yn(e,t={}){const a=await $n(e),c=kn(e,a),r=[],o=fs(a.parts);if(t.lookupWebResources&&o.length>0)try{c.webResources=await t.lookupWebResources(o)}catch(u){r.push({severity:"warning",code:"webresource-lookup",message:`Couldn't check the ${o.length} referenced web resource(s): ${u instanceof Error?u.message:String(u)}`})}return{findings:[...Rn(a.parts,c),...r],xml:a.xml}}async function Ls(e,t,a={}){const c=a.attempts??3,r=a.contentKeys??[];let o={missing:[],unexpected:[],differing:[]};for(let m=0;m<c;m++){m>0&&await new Promise(p=>setTimeout(p,a.delayMs??5e3));try{o=vn(t,await Be(e),{contentKeys:r})}catch(p){return{ok:!1,missing:[],unexpected:[],differing:[],message:`Couldn't read the published ribbon layer to verify it (${p instanceof Error?p.message:String(p)}).`}}if(o.missing.length===0&&o.unexpected.length===0&&o.differing.length===0){const p=r.length;return{ok:!0,...o,message:"Verified: the published ribbon layer has every element that was imported"+(p>0?`, and the ${p} element(s) this publish changed have the imported content.`:".")}}}const u=m=>m.slice(0,5).join(", ")+(m.length>5?", …":"");return{ok:!1,...o,message:"The published ribbon layer doesn't match what was imported"+(o.missing.length?`; missing: ${u(o.missing)}`:"")+(o.unexpected.length?`; unexpected: ${u(o.unexpected)}`:"")+(o.differing.length?`; different content: ${u(o.differing)}`:"")+". Reload the table and check before publishing again."}}class Ve extends Error{constructor(t,a,c=!1){const r=c?"another solution import ran in the environment meanwhile, and what it changed may not be published yet":Pn(a);super(c?`${t}'s ribbon customizations may have changed in Dataverse since you started publishing: ${r}. Importing could overwrite that change, so nothing was imported. Publish again: the table is published first, so the change is kept.`:`${t}'s ribbon customizations changed in Dataverse since you started publishing (${r}): 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=t,this.changes=a,this.importRan=c,this.name="RibbonLayerChangedError",this.summary=r}scopeLabel;changes;importRan;summary}function Pn(e){const t=a=>a.slice(0,5).join(", ")+(a.length>5?", …":"");return[e.unexpected.length?`added: ${t(e.unexpected)}`:"",e.missing.length?`removed: ${t(e.missing)}`:"",e.differing.length?`changed: ${t(e.differing)}`:""].filter(Boolean).join("; ")}function zs(e){const t=e instanceof Error?e.message:String(e);return/there is (?:another|a previous) \[(\w+)\] running/i.exec(t)?.[1]??null}const Ms=e=>Object.keys(e).flatMap(t=>Array.from(e[t].keys()).map(a=>`${t}:${a}`));function Nn(e,t){const a=[],c=[],r=[];for(const o of Object.keys(e)){for(const[u,m]of e[o]){const p=t[o].get(u);p===void 0?a.push(`${o}:${u}`):p!==m&&r.push(`${o}:${u}`)}for(const u of t[o].keys())e[o].has(u)||c.push(`${o}:${u}`)}return{missing:a,unexpected:c,differing:r}}const Dn=e=>e.missing.length+e.unexpected.length+e.differing.length>0;async function Xs(e,t,a,c){const r=c.kind==="imported"?c.attempts??3:1;let o={missing:[],unexpected:[],differing:[]};for(let u=0;u<r;u++){u>0&&c.kind==="imported"&&await new Promise(p=>setTimeout(p,c.delayMs??5e3));const m=await Be(e);if(o=c.kind==="read"?Nn(a,m):vn(a,m,{contentKeys:Ms(a)}),!Dn(o))return}throw new Ve(t,o)}function wn(e,t){return We(()=>Os(e,t))}async function Os(e,t){const a=e.guard??Fe(),c=Se.getState(),r=e.entity?e.entity.logicalName:"Application ribbon",o={onProgress:t,...e.busy},u=e.entity===null;if(u&&!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 m=async(l="Publishing customizations…")=>{t?.(l),await dn("Publish",async()=>{u?(await a("Publishing"),await se.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:"<importexportxml><ribbons><ribbon></ribbon></ribbons></importexportxml>"}})):await As([e.entity.logicalName],a)},o)},p=e.languageCode??await as(),S=async l=>{t?.(`Reading existing ribbon customizations for ${r}…`),l&&c.logInfo("publish",`Reading unmanaged ribbon layer for ${r}.`);const f=await $n({...e,languageCode:p}),L=Rn(f.parts,kn({...e,publisherPrefix:e.solution.publisherPrefix},f)),E=L.filter(i=>i.severity==="error");if(l||E.length>0){c.logInfo("publish",`RibbonDiffXml for ${r}: ${f.preservedCount} existing element(s) preserved, ${f.changedCount} element(s) from this session, ${f.elementCount} total.`);for(const i of f.scalingChanges)c.logWarn("publish",cs(i));for(const i of L)i.severity==="warning"&&c.logWarn("publish",i.message)}if(E.length>0){for(const i of E)c.logError("publish",i.message);throw new Error(`The pre-publish check found ${E.length} error(s), so nothing was imported: `+E.map(i=>i.message).join("; "))}return f},I=e.publishCustomizations!==!1?await S(!1):null;t?.("Checking that no other solution operation is running…"),await ls(o);let j=!1;const d=l=>(I&&!j&&l instanceof Error&&(l.message+=` (${r} was published first, so customizations imported elsewhere for it and not yet published are now published.)`),l);if(I){c.logInfo("publish",`Publishing ${r} first, so ribbon changes imported elsewhere but not yet published are kept.`);try{await m(`Publishing ${r} first (keeps changes imported elsewhere but not published)…`)}catch(l){throw l instanceof Error&&(l.message=`Publishing ${r} first failed, so nothing was imported: ${l.message}`),l}}let b;try{b=await S(!0)}catch(l){throw I&&l instanceof Error&&!l.message.startsWith("The pre-publish check")&&(l.message=`${r}'s customizations changed when it was published first (changes imported elsewhere and not yet published): ${l.message} Reload the table to get them, then publish again.`),d(l)}if(I){const l=Nn(I.layer,b.layer);Dn(l)&&c.logInfo("publish",`Publishing ${r} first published ribbon changes imported elsewhere (${Pn(l)}); they are kept.`)}const v=e.entity?.schemaName||e.entity?.logicalName||"",C=u?cn({applicationRibbonDiffXml:b.xml}):cn({entities:[{schemaName:v,localizedName:e.entity?.displayName||v,ribbonDiffXml:b.xml}]}),$=u?[{type:50,schemaName:":RibbonDiffXml",behavior:0}]:[{type:1,schemaName:e.entity.logicalName,behavior:2}],R=Bs({...e.solution,languageCode:p,rootComponents:$});t?.("Packaging solution ZIP…");const U=rs({"customizations.xml":Me(C),"solution.xml":Me(R),"[Content_Types].xml":Me('<?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 Y="";for(let l=0;l<U.length;l++)Y+=String.fromCharCode(U[l]);const J=btoa(Y),Z=async(l,f)=>{t?.(`Importing ${r} ribbon${l}…`);const L=crypto.randomUUID();c.logInfo("publish",`Importing solution${l} (import job ${L})…`);let E=!1;await dn("Import",async()=>{if(await a("Importing"),E)throw new Ve(r,{missing:[],unexpected:[],differing:[]},!0);await Xs(e.entity?.logicalName??null,r,f.layer,f.as);try{await Ds(J,L,a)}catch(k){throw ds(k)&&zs(k)?.toLowerCase()==="import"&&(E=!0),k}j=!0},o);const i=150,g=2e3;let y=await se.getImportJobStatus(L),w=0;for(;!gn(y)&&w<i;)await new Promise(k=>setTimeout(k,g)),y=await se.getImportJobStatus(L),w++,w%10===0&&t?.(`Still importing… (${w*2}s elapsed)`);if(!gn(y))throw new Error(`Solution import did not complete within ${i*g/1e3} seconds. Check Solutions › History for import job ${L}.`);t?.("Verifying the import…");const z=await se.retrieve("importjob",L,["data"]),V=Ns(z.data,u?{kind:"application"}:{kind:"entity",names:[v,e.entity.logicalName]});if(!V.ok)throw c.logError("publish",V.message),new Error(V.message);return c.logInfo("publish",V.message),L};let Q;try{Q=await Z("",{layer:b.layer,as:{kind:"read"}})}catch(l){throw d(l)}let X;if(e.publishCustomizations!==!1){await m();{c.logInfo("publish","Refreshing Unified Interface command-bar metadata (second import of the same package)…");try{await Z(" (refreshing Unified Interface metadata)",{layer:b.parts,as:{kind:"imported",delayMs:e.verifyDelayMs}}),await m()}catch(l){if(l instanceof Ve)X={ok:!1,...l.changes,message:`Your changes were imported and published, but ${r}'s ribbon customizations changed in Dataverse after that (${l.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.`},c.logWarn("publish",X.message);else throw new Error(`Your changes were imported and published, but refreshing Unified Interface's command-bar metadata failed (${l instanceof Error?l.message:String(l)}). New or changed buttons may not appear in the app until you publish again.`)}}X||(t?.("Verifying the published ribbon…"),X=await Ls(e.entity?.logicalName??null,b.parts,{delayMs:e.verifyDelayMs,contentKeys:b.changedKeys}),X.ok?c.logInfo("publish",X.message):c.logWarn("publish",X.message))}else c.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 t?.(e.publishCustomizations!==!1?`${r} ribbon published.`:`${r} ribbon imported (not published).`),{elementCount:b.elementCount,preservedCount:b.preservedCount,importJobId:Q,verification:X,parts:b.parts,changedKeys:b.changedKeys}}function Us(e,t){return We(()=>Vs(e,t))}async function Vs(e,t){const a=t?.guard??Fe(),c=Se.getState(),r=t?.pollIntervalMs??2e3,o=t?.timeoutMs??600*1e3;e?.("Starting asynchronous publish (PublishAllXmlAsync)..."),c.logInfo("publish","Calling PublishAllXmlAsync action."),await a("Publishing");const m=(await se.execute({operationName:"PublishAllXmlAsync",operationType:"action"}))?.AsyncOperationId;if(!m)throw new Error("PublishAllXmlAsync did not return AsyncOperationId.");c.logInfo("publish",`PublishAllXmlAsync job id: ${m}`),e?.("Async publish job started. Waiting for completion...");const p=Date.now();let S=0,I;for(;Date.now()-p<o;){S+=1;const j=await se.retrieve("asyncoperation",m,["asyncoperationid","statecode","statuscode","name","message","friendlymessage","completedon"]);if(I=j.statuscode,j.statecode===3||!!j.completedon){if(typeof j.statuscode=="number"&&j.statuscode!==30){const b=j.friendlymessage||j.message||`statuscode=${j.statuscode}`;throw new Error(`Asynchronous publish failed: ${b}`)}return e?.("Asynchronous publish completed successfully."),c.logInfo("publish",`PublishAllXmlAsync completed in ${S} poll(s).`),{asyncOperationId:m,statusCode:j.statuscode}}e?.(`Waiting for async publish job... (poll ${S})`),await new Promise(b=>setTimeout(b,r))}throw new Error(`Asynchronous publish timed out after ${Math.round(o/1e3)} seconds (last status: ${I??"unknown"}).`)}function Bs(e){const t=e.publisherUniqueName?.trim()||"DefaultPublisher",a=e.publisherName?.trim()||t,c=e.publisherPrefix?.trim()||"new",r=e.languageCode||1033,o=e.friendlyName?.trim()||e.uniqueName,u=e.rootComponents.length===0?"<RootComponents/>":`<RootComponents>
|
|
2
|
-
${e.rootComponents.map(m=>{const p=[`type="${m.type}"`];return m.schemaName&&p.push(`schemaName="${K(m.schemaName)}"`),m.id&&p.push(`id="{${K(m.id)}}"`),p.push(`behavior="${m.behavior}"`),`<RootComponent ${p.join(" ")} />`}).join(`
|
|
3
|
-
`)}
|
|
4
|
-
</RootComponents>`;return`<?xml version="1.0" encoding="utf-8"?>
|
|
5
|
-
<ImportExportXml version="9.1.0.0" SolutionPackageVersion="9.1" languagecode="${r}" generatedBy="CommandBarStudio">
|
|
6
|
-
<SolutionManifest>
|
|
7
|
-
<UniqueName>${K(e.uniqueName)}</UniqueName>
|
|
8
|
-
<LocalizedNames>
|
|
9
|
-
<LocalizedName description="${K(o)}" languagecode="${r}"/>
|
|
10
|
-
</LocalizedNames>
|
|
11
|
-
<Descriptions/>
|
|
12
|
-
<Version>${K(e.version)}</Version>
|
|
13
|
-
<Managed>0</Managed>
|
|
14
|
-
<Publisher>
|
|
15
|
-
<UniqueName>${K(t)}</UniqueName>
|
|
16
|
-
<LocalizedNames>
|
|
17
|
-
<LocalizedName description="${K(a)}" languagecode="${r}"/>
|
|
18
|
-
</LocalizedNames>
|
|
19
|
-
<Descriptions/>
|
|
20
|
-
<EMailAddress/>
|
|
21
|
-
<SupportingWebsiteUrl/>
|
|
22
|
-
<CustomizationPrefix>${K(c)}</CustomizationPrefix>
|
|
23
|
-
<CustomizationOptionValuePrefix>${e.publisherOptionValuePrefix??1e4}</CustomizationOptionValuePrefix>
|
|
24
|
-
<Addresses/>
|
|
25
|
-
</Publisher>
|
|
26
|
-
${u}
|
|
27
|
-
<MissingDependencies/>
|
|
28
|
-
</SolutionManifest>
|
|
29
|
-
</ImportExportXml>`}const Fs=Cn({root:{display:"flex",flexDirection:"column",gap:D.spacingVerticalS},box:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:D.spacingHorizontalM,rowGap:D.spacingVerticalXS,padding:`${D.spacingVerticalS} ${D.spacingHorizontalM}`,backgroundColor:D.colorNeutralBackground3,borderRadius:D.borderRadiusMedium},label:{color:D.colorNeutralForeground3},value:{display:"flex",flexWrap:"wrap",alignItems:"center",columnGap:D.spacingHorizontalS,minWidth:0},secondary:{color:D.colorNeutralForeground3,wordBreak:"break-all"}});function Ws({rows:e,confirmWord:t,onConfirmationChange:a,disabled:c}){const r=Fs(),[o,u]=N.useState({status:"loading"}),[m,p]=N.useState(""),S=G(R=>R.environment),I=G(R=>R.connectionUrl),j=G(R=>R.connectionVersion);N.useEffect(()=>{let R=!0;return u({status:"loading"}),jn().then(U=>R&&u({status:"ready",connection:U})).catch(()=>R&&u({status:"ready",connection:null})),()=>{R=!1}},[S,I,j]);const d=o.status==="ready"?o.connection:null,b=us(d?.environment),v=o.status==="ready"&&Ue(d?.environment),C=o.status==="ready"&&(!v||ms(m,t)),$=d?.environment;return N.useEffect(()=>{a(C,$)},[C,$,a]),s.jsxs("div",{className:r.root,children:[b&&s.jsx(F,{intent:"warning",children:s.jsxs(W,{children:[s.jsx(gs,{children:"Production environment"}),"This changes the live environment."]})}),s.jsxs("div",{className:r.box,children:[s.jsx(q,{className:r.label,children:"Environment"}),s.jsx("div",{className:r.value,children:o.status==="loading"?s.jsx(q,{children:"Reading the connection…"}):d?s.jsxs(s.Fragment,{children:[s.jsx(q,{weight:"semibold",children:d.name}),d.environment&&s.jsx(In,{size:"small",appearance:b?"filled":"tint",color:b?"warning":"informative",children:d.environment}),s.jsx(q,{size:200,className:r.secondary,children:d.url})]}):s.jsx(q,{children:"Unknown (the tool has no connection)"})}),e.map(R=>s.jsxs("div",{style:{display:"contents"},children:[s.jsx(q,{className:r.label,children:R.label}),s.jsx("div",{className:r.value,children:R.value})]},R.label))]}),v&&s.jsx(Re,{label:s.jsxs(s.Fragment,{children:["Type ",s.jsx("strong",{children:t})," to confirm"]}),hint:"Required on a Production environment.",children:s.jsx(Sn,{value:m,onChange:(R,U)=>p(U.value),disabled:c,autoComplete:"off","aria-label":`Type ${t} to confirm`})})]})}const qs=Cn({content:{display:"flex",flexDirection:"column",gap:D.spacingVerticalM},progressList:{display:"flex",flexDirection:"column",gap:D.spacingVerticalXS},progressRow:{display:"flex",alignItems:"center",gap:D.spacingHorizontalS}}),xn=({findings:e,showScope:t})=>s.jsx("ul",{style:{margin:`${D.spacingVerticalXS} 0 0`,paddingLeft:20},children:e.map((a,c)=>s.jsxs("li",{children:[t&&s.jsxs("strong",{children:[a.scope,": "]}),a.message]},c))}),ce=["HomepageGrid","SubGrid","Form"],Ks=3e4,nt=()=>{const e=qs(),t=Xe(n=>n.bulkPublishOpen),a=Xe(n=>n.closeBulkPublish),c=Xe(n=>n.openXmlDrawer),r=P(n=>n.ribbons),o=P(n=>n.baseline),u=P(n=>n.commands),m=P(n=>n.displayRules),p=P(n=>n.enableRules),S=P(n=>n.baselineCommands),I=P(n=>n.baselineEnableRules),j=P(n=>n.baselineDisplayRules),d=P(n=>n.locLabels),b=P(n=>n.baselineLocLabels),v=P(n=>n.layers),C=P(n=>n.pendingUnhides),$=P(n=>n.orphans),R=P(n=>n.pendingOrphanDeletes),U=P(n=>n.customisedCommandIds),Y=P(n=>n.uncustomisedCommandIds),J=P(n=>n.baseLanguageCode),Z=P(n=>n.setLayerSnapshot),Q=P(n=>n.markPublished),X=P(n=>n.mutationsSincePublish),l=G(n=>n.activeSolution),f=G(n=>n.activeEntity),L=G(n=>n.connectionUrl),E=G(n=>n.publisherPrefix),i=G(n=>n.solutionRibbonComponentIds),g=Array.isArray(i)&&i.length>0,[y,w]=N.useState(!1),[z,V]=N.useState({}),[k,$e]=N.useState(!1),[he,An]=N.useState(!1),[pe,En]=N.useState("targeted"),[qe,ke]=N.useState({confirmed:!1}),Tn=ne.useCallback((n,h)=>ke({confirmed:n,environment:h}),[]),Ke=qe.confirmed,[Ln,He]=N.useState(0),[_e,ae]=N.useState(""),[Ge,zn]=N.useState(""),[be,Ye]=N.useState(l?.version??"1.0.0.0"),[fe,ge]=N.useState([]),[Mn,Je]=N.useState([]),[Xn,ye]=N.useState([]),Ze=ne.useMemo(()=>{const h=(be||l?.version||"1.0.0.0").split(".").map(B=>Number.parseInt(B,10)||0);for(;h.length<4;)h.push(0);return h[3]+=1,h.slice(0,4).join(".")},[l?.version,be]);ne.useEffect(()=>{Ye(l?.version??"1.0.0.0")},[l?.version]);const we=ne.useCallback((n,h,B)=>hs({locations:n.map(M=>({current:r[M],baseline:o[M]})),excludeCommandIds:B,locLabels:d,baselineLocLabels:b,layer:v[h]??void 0,unhiddenLayerHideIds:C[h],deletedOrphans:$[h].filter(M=>R[h].includes(M.id)),customisedCommandIds:U,uncustomisedCommandIds:Y[h],commands:u,baselineCommands:S,enableRules:p,baselineEnableRules:I,displayRules:m,baselineDisplayRules:j}),[r,o,u,S,p,I,m,j,d,b,v,C,$,R,U,Y]),H=ne.useMemo(()=>f?we(ce,"entity"):null,[f,we]),ee=ne.useMemo(()=>{const n=new Set;if(f)for(const h of ce)for(const B of r[h].tabs)for(const M of B.groups)for(const T of Ie(M))T.commandId&&n.add(T.commandId);return we(["Application"],"application",n)},[we,f,r]),le=ee.hasChanges&&g,de=[...H?.unsupported??[],...ee.unsupported],Qe=[...H?.warnings??[],...ee.warnings],_=[...f&&H?.hasChanges?[f.logicalName]:[],...le?["Application ribbon"]:[]],On=f&&H?.hasChanges?f.logicalName:"application ribbon",[Pe,xe]=N.useState("idle"),[Ne,De]=N.useState([]),[Un,Ae]=N.useState(""),te=t&&!!l&&de.length===0&&_.length>0,en=l?.id,nn=l?.publisherPrefix||E,sn=ne.useCallback(async()=>{const n={commands:u,enableRules:p,displayRules:m,locLabels:d,baselineCommands:S,baselineEnableRules:I,baselineDisplayRules:j,publisherPrefix:nn,languageCode:J},h={lookupWebResources:M=>ps(M,en)},B=[];if(f&&H?.hasChanges){const{findings:M}=await yn({...n,entity:{logicalName:f.logicalName,schemaName:f.schemaName},locations:ce.map(T=>({current:r[T],baseline:o[T]})),plan:H},h);B.push(...M.map(T=>({...T,scope:f.logicalName})))}if(le){const{findings:M}=await yn({...n,entity:null,locations:[{current:r.Application,baseline:o.Application}],plan:ee},h);B.push(...M.map(T=>({...T,scope:"Application ribbon"})))}return B},[f,H,ee,le,r,o,u,p,m,d,S,I,j,nn,en,J]);ne.useEffect(()=>{if(!te||y||k)return;let n=!1;return xe("running"),Ae(""),Ts(sn(),Ks).then(h=>{n||(De(h),xe("done"))}).catch(h=>{n||(De([]),Ae(h instanceof Error?h.message:String(h)),xe("failed"))}),()=>{n=!0}},[te,y,k,sn]);const re=Ne.filter(n=>n.severity==="error"),Ce=Ne.filter(n=>n.severity==="warning"),tn=new Set(Ne.map(n=>n.scope)).size>1,on=te&&(Pe==="running"||re.length>0),Vn=()=>We(async()=>{if(!l||de.length>0||_.length===0||on||!Ke)return;w(!0);const n=Fe(),h=G.getState().connectionVersion,B=()=>G.getState().connectionVersion!==h,M=await jn().catch(()=>null);if(B()){w(!1);return}if(Ue(M?.environment)&&!Ue(qe.environment)){ke({confirmed:!1}),He(x=>x+1),w(!1),Se.getState().logWarn("publish",`${M?.name??"The connection"} is a Production environment now: type the confirmation to publish.`);return}ae(""),ge([]),ye([]),Je(_),V(Object.fromEntries(_.map(x=>[x,"pending"])));let T=!1;const oe=[],Te={},ie=[],ve=[],an=Se.getState(),ue=x=>x instanceof Error?x.message:String(x),ln={commands:u,enableRules:p,displayRules:m,locLabels:d,baselineCommands:S,baselineEnableRules:I,baselineDisplayRules:j,publishCustomizations:!0,solution:{uniqueName:l.uniqueName,friendlyName:l.friendlyName,version:he?Ze:be,publisherUniqueName:l.publisherUniqueName,publisherName:l.publisherName,publisherPrefix:l.publisherPrefix||E,publisherOptionValuePrefix:l.publisherOptionValuePrefix}};if(f&&H?.hasChanges){const x=f.logicalName;V(A=>({...A,[x]:"publishing"}));try{const A=await wn({...ln,guard:n,entity:{logicalName:f.logicalName,schemaName:f.schemaName,displayName:f.displayName},locations:ce.map(O=>({current:r[O],baseline:o[O]})),plan:H},O=>ae(O));oe.push(...ce),Te.entity=A.parts,bs(L,f.logicalName,A.changedKeys),A.verification&&ve.push({scope:x,result:A.verification}),V(O=>({...O,[x]:"success"}))}catch(A){T=!0,ie.push({scope:x,message:ue(A)}),an.logError("publish",`Ribbon publish failed (${x}): ${ue(A)}`),V(O=>({...O,[x]:"error"}))}}else f&&oe.push(...ce);if(le&&!B()){const x="Application ribbon";V(A=>({...A,[x]:"publishing"}));try{const A=await wn({...ln,guard:n,entity:null,locations:[{current:r.Application,baseline:o.Application}],ribbonCustomizationIds:i??[],plan:ee},O=>ae(O));oe.push("Application"),Te.application=A.parts,A.verification&&ve.push({scope:x,result:A.verification}),V(O=>({...O,[x]:"success"}))}catch(A){T=!0,ie.push({scope:x,message:ue(A)}),an.logError("publish",`Application ribbon publish failed: ${ue(A)}`),V(O=>({...O,[x]:"error"}))}}else ee.hasChanges||oe.push("Application");if(!T&&pe==="allAsync")try{await Us(x=>ae(x),{guard:n})}catch(x){T=!0,ie.push({scope:"Publish all customizations",message:ue(x)})}if(B()){le&&!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),$e(!1),w(!1);return}if(Q(oe,Te),f&&oe.includes("HomepageGrid")&&H?.hasChanges){const x=await un(f.logicalName);x&&Z("entity",x)}if(oe.includes("Application")&&le){const x=await un(null);x&&Z("application",x)}T||ae("Done."),ye(ve),ge(ie),$e(!T),w(!1)}),Ee=()=>{w(!1),V({}),Je([]),$e(!1),ae(""),ge([]),ye([]),xe("idle"),De([]),Ae(""),ke({confirmed:!1}),He(n=>n+1),a()};return s.jsx(ys,{open:t,onOpenChange:()=>!y&&Ee(),children:s.jsxs(ws,{style:{maxWidth:"640px",maxHeight:"92vh",display:"flex",flexDirection:"column"},children:[s.jsx(xs,{children:"Publish to Dataverse"}),s.jsxs(Cs,{style:{flex:1,minHeight:0,overflow:"hidden"},children:[s.jsx(vs,{style:{overflowY:"auto",maxHeight:"100%"},children:s.jsxs("div",{className:e.content,children:[!l&&s.jsx(F,{intent:"warning",children:s.jsx(W,{children:"No solution selected. Please select a solution first."})}),de.length>0&&!k&&s.jsx(F,{intent:"error",layout:"multiline",children:s.jsxs(W,{children:[s.jsx("strong",{children:"These changes can't be published yet. Undo them to publish:"}),s.jsx("ul",{style:{margin:`${D.spacingVerticalXS} 0 0`,paddingLeft:20},children:de.map(n=>s.jsx("li",{children:n},n))})]})}),Qe.length>0&&!k&&s.jsx(F,{intent:"info",layout:"multiline",children:s.jsxs(W,{children:[s.jsx("strong",{children:"Good to know:"}),s.jsx("ul",{style:{margin:`${D.spacingVerticalXS} 0 0`,paddingLeft:20},children:Qe.map(n=>s.jsx("li",{children:n},n))})]})}),te&&!k&&!y&&Pe==="running"&&s.jsxs("div",{className:e.progressRow,children:[s.jsx(js,{size:"tiny"}),s.jsx(q,{children:"Checking the ribbon customizations before publishing…"})]}),te&&!k&&Pe==="failed"&&s.jsx(F,{intent:"warning",layout:"multiline",children:s.jsxs(W,{children:["The pre-publish check couldn't complete (",Un,"). Publishing runs the check again before anything is imported."]})}),te&&!k&&re.length>0&&s.jsx(F,{intent:"error",layout:"multiline",children:s.jsxs(W,{children:[s.jsxs("strong",{children:["Publishing is blocked: the pre-publish check found ",re.length," error",re.length!==1?"s":"",". Fix"," ",re.length!==1?"them":"it",", then reopen this dialog:"]}),s.jsx(xn,{findings:re,showScope:tn})]})}),te&&!k&&Ce.length>0&&s.jsx(F,{intent:"warning",layout:"multiline",children:s.jsxs(W,{children:[s.jsxs("strong",{children:[Ce.length," warning",Ce.length!==1?"s":""," — you can still publish:"]}),s.jsx(xn,{findings:Ce,showScope:tn})]})}),ee.hasChanges&&!g&&!k&&s.jsx(F,{intent:"warning",layout:"multiline",children:s.jsxs(W,{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 ",s.jsx("strong",{children:"Add existing → Application Ribbons"}),", then reload here."]})}),s.jsx(F,{intent:"info",layout:"multiline",children:s.jsxs(W,{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 ",s.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 ",s.jsx("strong",{children:X})," change(s) since the last publish."]})}),fe.length>0&&s.jsx(F,{intent:"error",layout:"multiline",children:s.jsxs(W,{children:[s.jsxs("strong",{children:["Publish failed (",fe.length," error",fe.length!==1?"s":"",")"]}),s.jsx("ul",{style:{margin:`${D.spacingVerticalXS} 0 0`,paddingLeft:20},children:fe.map((n,h)=>s.jsxs("li",{style:{fontFamily:D.fontFamilyMonospace},children:[s.jsxs("strong",{children:[n.scope,":"]})," ",n.message]},h))}),s.jsxs("div",{style:{marginTop:D.spacingVerticalS},children:["Full details are in the ",s.jsx("strong",{children:"Console"})," tab of the bottom panel."]})]})}),!y&&!k&&s.jsxs(s.Fragment,{children:[s.jsx(Ws,{rows:[{label:"Solution",value:l?s.jsx(q,{weight:"semibold",children:l.friendlyName||l.uniqueName}):s.jsx(q,{children:"None selected"})},{label:"Will publish",value:s.jsx(q,{weight:"semibold",children:_.length>0?_.join(", "):"nothing (there are no changes to publish)"})},{label:"Writes",value:s.jsxs(q,{children:["Publishes ",_.length===1?"it":"them"," first (keeps changes imported elsewhere but not published),"," ",_.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":_.length===1?"it":"them","."]})}],confirmWord:On,onConfirmationChange:Tn},Ln),s.jsx(Re,{label:"Afterwards",children:s.jsxs(Rs,{value:pe==="targeted"?"Publish only these ribbons":"Also publish all customizations (PublishAllXmlAsync)",selectedOptions:[pe],onOptionSelect:(n,h)=>{(h.optionValue==="targeted"||h.optionValue==="allAsync")&&En(h.optionValue)},children:[s.jsx(mn,{value:"targeted",children:"Publish only these ribbons"}),s.jsx(mn,{value:"allAsync",children:"Also publish all customizations (PublishAllXmlAsync)"})]})}),s.jsx(Re,{label:"Solution version",children:s.jsx(Sn,{size:"small",value:he?Ze:be,onChange:(n,h)=>Ye(h.value),disabled:he})}),s.jsx(Is,{label:"Increment solution version",checked:he,onChange:(n,h)=>An(h.checked===!0)}),s.jsx(Re,{label:"Publish comment",children:s.jsx(Ss,{resize:"vertical",value:Ge,onChange:(n,h)=>zn(h.value)})}),s.jsx(Oe,{appearance:"subtle",onClick:()=>{c(),Ee()},children:"View RibbonDiffXml"})]}),k&&s.jsx(F,{intent:"info",layout:"multiline",children:s.jsx(W,{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."})}),Xn.map(n=>s.jsx(F,{intent:n.result.ok?"success":"warning",layout:"multiline",children:s.jsxs(W,{children:[s.jsxs("strong",{children:[n.scope,":"]})," ",n.result.message]})},n.scope)),(y||k)&&s.jsxs("div",{className:e.progressList,children:[Mn.map(n=>{const h=z[n]??"pending";return s.jsxs("div",{className:e.progressRow,children:[s.jsx(In,{appearance:"filled",color:h==="success"?"success":h==="error"?"danger":h==="publishing"?"informative":"subtle",size:"small",children:h}),s.jsx(q,{children:n}),h==="publishing"&&s.jsx($s,{thickness:"large",style:{flex:1}})]},n)}),_e&&s.jsx(F,{intent:"info",children:s.jsx(W,{children:_e})})]})]})}),s.jsxs(ks,{children:[s.jsx(Oe,{appearance:"secondary",onClick:Ee,disabled:y,children:k?"Close":"Cancel"}),!k&&s.jsx(Oe,{appearance:"primary",onClick:()=>{Vn()},disabled:y||!l||_.length===0||de.length>0||on||!Ke,children:y?"Publishing...":"Publish"})]})]})]})})};export{nt as BulkPublishModal,nt 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,W as ae,ak as ne,a8 as h,af as se,al as le,c as ie}from"./index-CL8TmfXp.js";import{t,B as re,b as y}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 l=ce(),g=s(e=>e.commandPaletteOpen),N=s(e=>e.setCommandPaletteOpen),L=s(e=>e.openBulkPublish),D=s(e=>e.openXmlDrawer),f=s(e=>e.openImportXml),X=s(e=>e.openCommandEditor),C=s(e=>e.openRuleEditor),T=s(e=>e.openNewGroup),H=s(e=>e.openNewButton),W=s(e=>e.openLocalizationEditor),v=s(e=>e.themeMode),O=s(e=>e.setThemeMode),P=c(e=>e.undo),G=c(e=>e.redo),V=c(e=>e.commands),F=c(e=>e.displayRules),U=c(e=>e.enableRules),$=c(e=>e.ribbons),q=ae(e=>e.entities),K=ne(e=>e.requestEntitySwitch),A=h(e=>e.location),Q=h(e=>e.tabId),p=h(e=>e.selectedButtonId),I=h(e=>e.selectedGroupId),[i,j]=u.useState(""),[k,d]=u.useState(0),z=u.useRef(null),n=u.useCallback(()=>{N(!1),j(""),d(0)},[N]);u.useEffect(()=>{g&&setTimeout(()=>z.current?.focus(),50)},[g]);const Z=()=>{const e=[],r=$[A].tabs.find(o=>o.id===Q),J=r?.groups[0]?.id??null,S=I??J,R=se(le(r?.groups.find(o=>o.id===I),p)?.kind),_=[{id:"publish",label:"Publish all",subtitle:"Save and publish changes to Dataverse",kind:"action",action:()=>{L(),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=navigator.clipboard?.readText?.();if(!o)return f();o.then(m=>f(m.trim().startsWith("<")?m:""),()=>f())}},{id:"new-group",label:"New group",subtitle:"Create a new ribbon group in current tab",kind:"action",action:()=>{T(),n()}},{id:"new-button",label:"New button",subtitle:S?"Create a new button in selected/current group":"Select a tab/group with at least one group first",kind:"action",action:()=>{S&&(H(S),n())}},{id:"edit-labels",label:"Edit localized labels",subtitle:R?"The selected control is shown read-only":p?"Open localization editor for selected button":"Select a button first",kind:"action",action:()=>{!p||R||(W(p),n())}},{id:"toggle-theme",label:`Toggle theme (${v==="dark"?"Dark":"Light"})`,subtitle:"Switch between light and dark",kind:"action",action:()=>{O(v==="dark"?"light":"dark"),n()}},{id:"undo",label:"Undo",subtitle:"Ctrl+Z",kind:"action",action:()=>{P(),n()}},{id:"redo",label:"Redo",subtitle:"Ctrl+Shift+Z",kind:"action",action:()=>{G(),n()}}];if(e.push(..._),!i.startsWith("@")&&!i.startsWith("/")){const o=Object.entries($).flatMap(([m,ee])=>ee.tabs.flatMap(B=>B.groups.flatMap(M=>ie(M).map(w=>({id:`btn-${w.id}`,label:w.label||w.id,subtitle:`${m} → ${B.label} → ${M.label}`,kind:"button",action:()=>{n()}})))));e.push(...o.slice(0,20))}return V.forEach(o=>{e.push({id:`cmd-${o.id}`,label:o.id,subtitle:`${o.actions.length} action(s)`,kind:"command",action:()=>{X(o.id),n()}})}),F.forEach(o=>{e.push({id:`dr-${o.id}`,label:o.id,subtitle:`Display rule — ${o.steps.length} step(s)`,kind:"rule",action:()=>{C(o.id,"display"),n()}})}),U.forEach(o=>{e.push({id:`er-${o.id}`,label:o.id,subtitle:`Enable rule — ${o.steps.length} step(s)`,kind:"rule",action:()=>{C(o.id,"enable"),n()}})}),(i.startsWith("@")||!i)&&q.slice(0,30).forEach(o=>{e.push({id:`ent-${o.logicalName}`,label:o.displayName,subtitle:o.logicalName,kind:"entity",action:()=>{K(o),n()}})}),e},x=i.startsWith("@")||i.startsWith("/")?i.slice(1):i,E=Z(),b=x?E.filter(e=>e.label.toLowerCase().includes(x.toLowerCase())||(e.subtitle??"").toLowerCase().includes(x.toLowerCase())):E,Y=e=>{e.key==="ArrowDown"?(e.preventDefault(),d(r=>Math.min(r+1,b.length-1))):e.key==="ArrowUp"?(e.preventDefault(),d(r=>Math.max(r-1,0))):e.key==="Enter"?b[k]?.action():e.key==="Escape"&&n()};return g?a.jsx("div",{className:l.backdrop,onClick:n,role:"presentation",children:a.jsxs("div",{className:l.palette,onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[a.jsxs("div",{className:l.searchRow,children:[a.jsx(te,{style:{color:t.colorNeutralForeground3,flexShrink:0}}),a.jsx("input",{ref:z,className:l.searchInput,value:i,onChange:e=>{j(e.target.value),d(0)},onKeyDown:Y,placeholder:"Search commands, buttons, entities… Use @ for entities, / for actions","aria-label":"Command palette search"})]}),a.jsxs("div",{className:l.results,role:"listbox",children:[b.map((e,r)=>a.jsxs("div",{className:`${l.item} ${r===k?l.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:l.itemLabel,children:[a.jsx(y,{children:e.label}),e.subtitle&&a.jsx(y,{className:l.itemSub,block:!0,children:e.subtitle})]})]},e.id)),b.length===0&&a.jsx("div",{className:l.item,children:a.jsx(y,{style:{color:t.colorNeutralForeground3},children:"No results"})})]}),a.jsxs("div",{className:l.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 l}from"./fluent-icons-DUgjkNjy.js";import{a as X}from"./monaco-BIO15LCS.js";import{ae as Te,A as Be,af as He,ag as ze,ah as Fe,ai as _e,aj as Pe,a as ae,u as Ue,a8 as We,W as Je}from"./index-CL8TmfXp.js";import{a as Ye}from"./xmlValidator-DvDaU5OO.js";import{M as Ke}from"./MonacoEditor-CBUJNFgC.js";import{D as Ve,i as Qe,j as Ze,k as et,l as tt,b as De,M,f as q,ae as le,m as ot,d as Z}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";import"./ruleKinds-B9hACGaq.js";import"./crmParameters-rgfZhhzN.js";const he=["HomepageGrid","SubGrid","Form"],ce=[...he,"Application"],de=new Set(["Button","FlyoutAnchor","SplitButton","TextBox","ComboBox","CheckBox"]),ue=new Set(["flyout","splitButton"]),pe=/^Mscrm\.(HomepageGrid|SubGrid|Form)\.([^.]+)\./,Ie="._children",nt=/<(EnableRule|DisplayRule)\b[^>]*?\sId="([^"]+)"/,me=/\$LocLabels:([^"'\s<]+)/g,Le="cbs.import.Tab",st="cbs.import.Group",ve=(a,g)=>JSON.stringify(a)===JSON.stringify(g);function O(a){return a?Array.from(a.children):[]}function it(a){return Object.fromEntries(Array.from(a.attributes).map(g=>[g.name,g.value]))}function rt(a,g,c){const m=a.documentElement;if(m.tagName==="RibbonDiffXml")return m;const S=Array.from(a.getElementsByTagName("RibbonDiffXml")),A=Array.from(a.querySelectorAll("Entities > Entity")).flatMap(r=>{const $=O(r),N=$.find(L=>L.tagName==="RibbonDiffXml"),w=$.find(L=>L.tagName==="Name")?.textContent?.trim()??"";return N?[{name:w,rdx:N}]:[]}),R=S.find(r=>r.parentElement===m);if(A.length===0&&!R){if(S.length===1)return S[0];throw new Error(S.length===0?"No <RibbonDiffXml> element found.":`The XML has ${S.length} <RibbonDiffXml> elements and none belongs to a table or the application ribbon — paste just one.`)}const I=[...A.map(r=>r.name||"(unnamed table)"),...R?["the application ribbon"]:[]].join(", ");if(c){if(R)return R;throw new Error(`The XML has no application ribbon RibbonDiffXml (it has: ${I}). Open that table's ribbon to import its customizations.`)}const y=A.find(r=>r.name.toLowerCase()===g.toLowerCase());if(y)return y.rdx;throw new Error(`The XML has no RibbonDiffXml for ${g||"the loaded table"} (it has: ${I}). Load that table, or open the application ribbon for the application ribbon's customizations.`)}function at(a){switch(a){case"HomePageGrid":return"HomepageGrid";case"Form":return"Form";case"SubGridStandard":case"SubGridAssociated":return"SubGrid";default:return}}function lt(a){const g=a.languageCode??1033,c=a.entityLogicalName,m=new DOMParser().parseFromString(a.xml,"application/xml");if(m.querySelector("parsererror"))throw new Error("The XML is not well-formed.");const S=a.activeLocation==="Application",A=rt(m,c,S),R=new XMLSerializer,I=R.serializeToString(A),y=[],r=[],$=[],N=!!c&&new RegExp(`Mscrm\\.(HomepageGrid|SubGrid|Form)\\.${c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\.`,"i").test(I),w=S&&!(A===m.documentElement&&N);A!==m.documentElement?$.push(`Imported the RibbonDiffXml of ${w?"the application ribbon":c} from the document.`):S&&!w&&$.push(`The XML's Locations name the ${c} table, so it was imported as that table's customizations, not the application ribbon's.`);const L=w?"Application":he.includes(a.activeLocation)?a.activeLocation:"HomepageGrid",v=Te(I,a.activeLocation,c),x=(e,t,o)=>{const s=new Map,n=new Map;for(const h of t)s.set(h.id,h),n.set(h.id,(n.get(h.id)??0)+1);for(const[h,b]of n)b>1&&$.push(`${o} ${h} is defined ${b} times in the XML — the last one was used.`);const u=Array.from(s.values()),i=[...e],p=[];let f=0;for(const h of u){const b=i.findIndex(T=>T.id===h.id);if(b>=0&&ve(i[b],h)){f++;continue}y.push(`${o} ${h.id} ${b>=0?"updated":"added"}`),b>=0?i[b]=h:i.push(h),p.push(h.id)}return{out:i,changedIds:p,unchanged:f}},d=x(a.commands,v.commands,"Command"),C=x(a.enableRules,v.enableRules,"Enable rule"),k=x(a.displayRules,v.displayRules,"Display rule"),B=x(a.locLabels,v.locLabels,"Label"),H=B.out,be=d.unchanged+C.unchanged+k.unchanged+B.unchanged,G=(e,t)=>e&&Pe(e,H,g)||t,D=JSON.parse(JSON.stringify(a.ribbons));let j=!1,z=0;const ee=new Set,te=e=>{if(w)return ce.slice().reverse();const t=pe.exec(e),o=t&&t[2]!=="{!EntityLogicalName}"?t[1]:L;return[o,...he.filter(s=>s!==o),"Application"]},F=(e,t)=>{w&&e!=="Application"?$.push(`${t} is on the table's ribbon (${e}), not the application ribbon: the change is published with the table.`):!w&&e==="Application"&&$.push(`${t} was found only on the application ribbon: the change is published to the application ribbon and affects every table.`)},oe=[],E=(e,t)=>{e&&e!==t&&oe.push(e)},_=e=>{for(const t of te(e))for(const o of D[t].tabs){const s=o.groups.find(n=>n.id===e);if(s)return{location:t,tab:o,group:s}}},P=e=>{for(const t of te(e)){const o=D[t].tabs.find(s=>s.id===e);if(o)return{location:t,tab:o}}},U=e=>{for(const t of te(e)){const o=[];for(const s of D[t].tabs)for(const n of s.groups)for(const u of n.buttons)u.id===e&&o.push({group:n,button:u});if(o.length>0)return{location:t,found:o}}},W=(e,t)=>{const o=pe.exec(t);let s="it isn't in the loaded ribbon";o&&o[2]!=="{!EntityLogicalName}"&&c&&o[2]!==c?s=`it belongs to the ${o[2]} table, but ${c} is loaded`:(o?.[2]==="{!EntityLogicalName}"||t.startsWith("Mscrm.Global"))&&(s="it belongs to the application ribbon, which isn't loaded with it"),r.push(`${e}: Location "${t}" not found — ${s}.`)},je=O(A.querySelector(":scope > RuleDefinitions > TabDisplayRules")).map(e=>R.serializeToString(e)).join(""),ne=e=>Te(`<RibbonDiffXml><UI><Ribbon><Tabs>${e}</Tabs></Ribbon></UI><RuleDefinitions><TabDisplayRules>${je}</TabDisplayRules></RuleDefinitions></RibbonDiffXml>`,a.activeLocation,c,H).ribbon.tabs[0],J=e=>R.serializeToString(e),ge=e=>ne(`<Tab Id="${Le}"><Groups><Group Id="${st}"><Controls>${J(e)}</Controls></Group></Groups></Tab>`)?.groups[0]?.buttons.find(t=>t.id===e.getAttribute("Id")),ye=e=>{const t=e.source;t&&(e.label=G(t.labelToken,e.id),t.tooltipTitleToken&&(e.tooltipTitle=G(t.tooltipTitleToken,"")),t.tooltipBodyToken&&(e.tooltipBody=G(t.tooltipBodyToken,"")))},Y=e=>{for(const t of e.source?.xml?[e.source.xml]:Object.values(e.source?.attributes??{}))for(const[,o]of t.matchAll(me))H.some(s=>s.id===o)||r.push(`${e.id}: references label ${o}, which neither the XML nor the loaded ribbon defines — add its <LocLabel> or the publish will fail.`)},$e=e=>({titleToken:e.getAttribute("Title")??void 0,attributes:it(e)}),xe=(e,t)=>(_e(e,{origin:"unmanaged"}),e.hidden=!1,t!==void 0&&!e.source?.attributes.Sequence&&(e.sequence=t),ye(e),Y(e),e),se=e=>r.push(`${e}: flyout / split buttons and their menus can't be imported yet (#27).`),Ne=(e,t)=>{const o=new Set(Array.from(e.querySelectorAll("Menu *")).map(n=>n.getAttribute("Id")).filter(n=>!!n)),s=[];for(const n of t?.buttons??[])o.has(n.id)||(ue.has(n.kind)?se(n.id):s.push(xe(n)));return s},K=(e,t)=>{const o=e.findIndex(s=>s.sequence>t.sequence);e.splice(o<0?e.length:o,0,t)},Ae=(e,t,o)=>{const s=U(e),n=ge(t);if(!s||!n)return!1;ye(n),Y(n),F(s.location,e);for(const{group:u,button:i}of s.found){if(n.kind!==i.kind)return r.push(`${e}: changing a <${t.tagName}> into another kind of control isn't supported.`),!0;if(ue.has(i.kind))return se(e),!0;const p=JSON.parse(JSON.stringify(i));Object.assign(i,{label:n.label,tooltipTitle:n.tooltipTitle,tooltipBody:n.tooltipBody,icon:n.icon,image16:n.image16,image32:n.image32,commandId:n.commandId,templateAlias:n.templateAlias||i.templateAlias,source:structuredClone(n.source)});const f=n.source?.attributes.Sequence?n.sequence:o;f!==void 0&&f!==i.sequence&&(i.origin==="unmanaged"?(u.buttons.splice(u.buttons.indexOf(i),1),i.sequence=f,K(u.buttons,i)):r.push(`${e}: Sequence ${f} not applied — only your own buttons can be re-ordered.`)),Fe(p,i)||p.sequence!==i.sequence?(j=!0,y.push(`Updated ${i.label} (${e}) on ${s.location}`),n.templateAlias||$.push(`${e}: the override has no TemplateAlias — ${i.templateAlias} from the loaded control is kept.`)):(Object.assign(i,p),ve(p.source?.attributes,n.source?.attributes)?z++:r.push(`${e}: the override only changes attributes CBS doesn't publish yet (label, tooltip, icon, command and template alias are).`))}return!0},Se=(e,t,o,s)=>{const n=t.getAttribute("Id");if(!n)return r.push(`CustomAction ${e.getAttribute("Id")}: the control has no Id.`);const u=U(n);if(u){u.found.some(f=>f.group.id===o)||r.push(`${n}: already in group ${u.found[0].group.id} — updated there, not moved to ${o}.`),Ae(n,t,s)&&E(e.getAttribute("Id"),`${n}.Override.CustomAction`);return}const i=_(o);if(!i)return W(`${n}`,e.getAttribute("Location")??"");const p=ge(t);if(!p)return r.push(`${n}: couldn't read the <${t.tagName}>.`);if(ue.has(p.kind))return se(n);K(i.group.buttons,xe(p,s)),F(i.location,n),E(e.getAttribute("Id"),`${n}.CustomAction`),j=!0,y.push(`Added ${p.label} (${n}) to ${i.group.id} on ${i.location}`)},Ce=(e,t)=>{const o=ne(`<Tab Id="${Le}"><Groups>${J(e)}</Groups></Tab>`)?.groups[0];if(!o)return;const s=$e(e);return Y({id:o.id,source:s}),{...o,label:G(s.titleToken,o.id),source:s,sequence:e.getAttribute("Sequence")===null?t??o.sequence:o.sequence,buttons:Ne(e,o)}},Ee=(e,t,o,s)=>{const n=t.getAttribute("Id");if(!n)return r.push(`CustomAction ${e.getAttribute("Id")}: the group has no Id.`);if(_(n)){r.push(`Group ${n} already exists — it was left as is (re-titling groups isn't supported).`);for(const f of O(t.querySelector(":scope > Controls")))de.has(f.tagName)?Se(e,f,n,void 0):He(ze[f.tagName])&&r.push(`${f.getAttribute("Id")??"(no Id)"}: adding a <${f.tagName}> to an existing group isn't supported — Command Bar Studio shows it read-only.`);return}const i=P(o);if(!i)return W(`Group ${n}`,e.getAttribute("Location")??"");const p=Ce(t,s);if(!p)return r.push(`Group ${n}: couldn't read the <Group>.`);K(i.tab.groups,p),F(i.location,n),E(e.getAttribute("Id"),`${n}.CustomAction`),j=!0,y.push(`Added group ${p.label} (${n}) with ${p.buttons.length} control(s) to ${o} on ${i.location}`)},Oe=(e,t,o)=>{const s=t.getAttribute("Id");if(!s)return r.push(`CustomAction ${e.getAttribute("Id")}: the tab has no Id.`);if(P(s))return r.push(`Tab ${s} already exists — it was left as is.`);const n=ne(J(t));if(!n)return r.push(`Tab ${s}: couldn't read the <Tab>.`);const u=n.tabDisplayRules.flatMap(T=>T.rules.map(we=>we.kind==="EntityRule"?at(we.context):void 0)),i=w?"Application":u.find(T=>!!T)??pe.exec(s)?.[1]??L,f=Array.from(t.querySelectorAll(":scope > Groups > Group")).map(T=>Ce(T,void 0)).filter(T=>!!T),h=$e(t);Y({id:s,source:h});const b={...n,label:G(h.titleToken,s),source:h,sequence:t.getAttribute("Sequence")===null?o??n.sequence:n.sequence,groups:f};K(D[i].tabs,b),E(e.getAttribute("Id"),`${s}.CustomAction`),b.commandId&&(ee.add(b.commandId),d.out.some(T=>T.id===b.commandId)||(d.out.push({id:b.commandId,enableRules:[],displayRules:[],actions:[]}),d.changedIds.push(b.commandId),$.push(`Tab ${s}: its Command ${b.commandId} has no CommandDefinition in the XML — an empty one was added.`))),j=!0,y.push(`Added tab ${b.label} (${s}) with ${f.length} group(s) to ${i}`),t.querySelector(":scope > Scaling > Scale")&&r.push(`Tab ${s}: its <Scale> steps weren't imported — CBS writes a default MaxSize for each group.`)},Ge=e=>{const t=e.getAttribute("Location")??"",o=U(t);if(o){const s=o.found.filter(n=>!n.button.hidden);for(const n of s)n.button.hidden=!0;s.length>0?(F(o.location,t),E(e.getAttribute("HideActionId"),`${t}.HideAction`),j=!0,y.push(`Hid ${s[0].button.label} (${t}) on ${o.location}`)):z++;return}if(_(t)||P(t))return r.push(`Hiding ${t}: hiding whole groups or tabs isn't supported yet — hide their buttons.`);r.push(`Hiding ${t}: not found in the loaded ribbon (it may belong to another table, or already be hidden by your customizations).`)},Xe=e=>{const t=e.getAttribute("Id")??"(no Id)",o=e.getAttribute("Location")??"",s=e.getAttribute("Sequence"),n=s===null?void 0:parseInt(s,10),u=O(e.querySelector(":scope > CommandUIDefinition"))[0];if(!u)return r.push(`CustomAction ${t}: no <CommandUIDefinition> content.`);const i=u.tagName;if(o.endsWith(Ie)){const p=o.slice(0,-Ie.length);return p.endsWith(".Controls")&&de.has(i)?Se(e,u,p.slice(0,-9),n):p.endsWith(".Groups")&&i==="Group"?Ee(e,u,p.slice(0,-7),n):p==="Mscrm.Tabs"&&i==="Tab"?Oe(e,u,n):p.endsWith(".Scaling")&&(i==="MaxSize"||i==="Scale")?r.push(`CustomAction ${t}: <${i}> scaling isn't imported — CBS writes a default MaxSize for each new group.`):r.push(`CustomAction ${t}: a <${i}> at "${o}" isn't supported.`)}if(de.has(i)&&u.getAttribute("Id")===o){if(Ae(o,u,n)){E(t,`${o}.Override.CustomAction`);return}return W(`Override ${t}`,o)}return U(o)||_(o)||P(o)?r.push(`CustomAction ${t}: replacing ${o} with a <${i}> isn't supported — only overriding a control with the same Id is.`):W(`CustomAction ${t}`,o)},Me=O(A.querySelector(":scope > CustomActions"));for(const e of Me)e.tagName==="CustomAction"?Xe(e):e.tagName==="HideCustomAction"?Ge(e):r.push(`<${e.tagName}> in CustomActions isn't supported.`);const V=new Set;for(const e of ce)for(const t of D[e].tabs)for(const o of t.groups)for(const s of o.buttons)for(const n of Be(s))V.add(n);for(const e of ee)V.add(e);const ie=new Set,re=new Set;for(const e of d.out)if(V.has(e.id)){e.enableRules.forEach(t=>ie.add(t)),e.displayRules.forEach(t=>re.add(t));for(const t of e.rawRuleRefs??[]){const o=nt.exec(t.xml);o&&(o[1]==="EnableRule"?ie:re).add(o[2])}}const Q=(e,t,o,s)=>{for(const n of e)t.has(n)||r.push(`${o} ${n} was imported but ${s}, so it won't be published.`)};Q(d.changedIds,V,"Command","no button on the loaded ribbon uses it"),Q(C.changedIds,ie,"Enable rule","no command a button uses references it"),Q(k.changedIds,re,"Display rule","no command a button uses references it");const Re=new Set(Array.from(J(A).matchAll(me),e=>e[1]));for(const e of ce)for(const t of D[e].tabs)for(const o of t.groups)for(const s of o.buttons)for(const n of Object.values(s.source?.attributes??{}))for(const u of n.matchAll(me))Re.add(u[1]);Q(B.changedIds,Re,"Label","nothing references it");const qe=Array.from(A.querySelectorAll(":scope > RuleDefinitions > TabDisplayRules > TabDisplayRule"));for(const e of qe){const t=e.getAttribute("TabCommand")??"";ee.has(t)||r.push(`TabDisplayRule for ${t}: only the display rules of tabs this import adds are imported.`);const o=O(e).filter(s=>s.tagName!=="EntityRule"&&s.tagName!=="PageRule");o.length>0&&r.push(`TabDisplayRule for ${t}: ${o.map(s=>`<${s.tagName}>`).join(", ")} not imported — only EntityRule and PageRule are supported.`)}oe.length>0&&$.push(`Ids normalised: CBS publishes CustomAction / HideCustomAction ids as {control}.CustomAction, {control}.Override.CustomAction and {control}.HideAction, so ${oe.join(", ")} will be written under those ids.`),be+z>0&&y.push(`${be+z} control(s) / definition(s) were already up to date`);const ke=j||d.changedIds.length+C.changedIds.length+k.changedIds.length+B.changedIds.length>0;return{ribbons:j?D:a.ribbons,commands:d.out,enableRules:C.out,displayRules:k.out,locLabels:H,applied:y,notApplied:r,notes:$,changed:ke}}function ct(a,g){const c=Ue.getState(),m=lt({xml:a,ribbons:c.ribbons,commands:c.commands,enableRules:c.enableRules,displayRules:c.displayRules,locLabels:c.locLabels,entityLogicalName:Je.getState().activeEntity?.logicalName??c.ribbons.HomepageGrid.entityLogicalName,activeLocation:We.getState().location,languageCode:c.baseLanguageCode});return g&&m.changed&&c.applyImport(m,`${m.applied.length} change(s)`),m}const fe=({items:a})=>l.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:"20px",maxHeight:"160px",overflowY:"auto"},children:a.map((g,c)=>l.jsx("li",{children:l.jsx(De,{size:200,children:g})},c))}),$t=()=>{const a=ae(d=>d.importXmlOpen),g=ae(d=>d.importXmlSeed),c=ae(d=>d.closeImportXml),[m,S]=X.useState(""),[A,R]=X.useState([]),[I,y]=X.useState(null),[r,$]=X.useState("");X.useEffect(()=>{a&&(S(g),R([]),y(null),$(""))},[a,g]);const N=d=>{S(d),I?.imported||y(null)},w=()=>{const d=Ye(m);return R(d),d.every(C=>C.severity==="warning")},L=d=>{if(w()){$("");try{y({result:ct(m,d),imported:d})}catch(C){y(null),$(C instanceof Error?C.message:String(C))}}},v=I?.imported===!0,x=I?.result;return l.jsx(Ve,{open:a,onOpenChange:()=>c(),children:l.jsxs(Qe,{style:{maxWidth:"960px",width:"92vw",height:"80vh",maxHeight:"860px"},children:[l.jsx(Ze,{children:"Import RibbonDiffXml"}),l.jsxs(et,{style:{height:"100%",display:"flex",flexDirection:"column"},children:[l.jsxs(tt,{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",gap:"8px"},children:[l.jsx(De,{size:200,children:"Paste a RibbonDiffXml (for example from Ribbon Workbench or a solution's customizations.xml — the loaded table's part is used, or the application ribbon's when that is on screen). Commands, rules and labels are added or replaced by id; new buttons, groups and tabs are added to the loaded ribbon; overrides and hides edit the existing controls. Everything imported becomes one unpublished change, which Undo takes back as a whole."}),l.jsx("div",{style:{flex:1,minHeight:0},children:l.jsx(Ke,{language:"xml",value:m,onChange:N,readOnly:v,height:"100%",options:{wordWrap:"on",lineNumbers:"on",padding:{top:8}}})}),A.length>0&&l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:A.map((d,C)=>l.jsx(M,{intent:d.severity==="warning"?"warning":"error",children:l.jsxs(q,{children:[d.message,d.lineHint?` (${d.lineHint})`:""]})},C))}),r&&l.jsx(M,{intent:"error",children:l.jsx(q,{children:r})}),x&&l.jsx(M,{intent:x.changed?"success":"info",layout:"multiline",children:l.jsxs(q,{children:[l.jsx(le,{children:v?x.changed?"Imported — review the changes, then publish":"Nothing to import — the session already has all of it":"Preview — nothing has changed yet"}),x.applied.length>0&&l.jsx(fe,{items:x.applied})]})}),x&&x.notes.length>0&&l.jsx(M,{intent:"info",layout:"multiline",children:l.jsxs(q,{children:[l.jsx(le,{children:"Good to know"}),l.jsx(fe,{items:x.notes})]})}),x&&x.notApplied.length>0&&l.jsx(M,{intent:"warning",layout:"multiline",children:l.jsxs(q,{children:[l.jsx(le,{children:v?"Not imported / won't be published":"Can't be imported / won't be published"}),l.jsx(fe,{items:x.notApplied})]})})]}),l.jsx(ot,{children:v?l.jsx(Z,{appearance:"primary",onClick:c,children:"Close"}):l.jsxs(l.Fragment,{children:[l.jsx(Z,{appearance:"secondary",onClick:c,children:"Cancel"}),l.jsx(Z,{appearance:"secondary",onClick:()=>L(!1),disabled:!m.trim(),children:"Preview"}),l.jsx(Z,{appearance:"primary",onClick:()=>L(!0),disabled:!m.trim(),children:"Import"})]})})]})]})})};export{$t as ImportXmlModal,$t as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as a,h as M,cq as P,co as q,z as G,cB as J}from"./fluent-icons-DUgjkNjy.js";import{R as N,a as B}from"./monaco-BIO15LCS.js";import{a as L,u as m,c as V,am as Y}from"./index-CL8TmfXp.js";import{D as Q,i as Z,k as ee,j as ae,aa as te,B as $,d as x,l as le,I as oe,b as H,t as i,T as F,m as ne}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const f={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:"🇪🇸"}},ie=Object.keys(f).map(Number),se=G({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}}),he=()=>{const n=se(),p=L(e=>e.localizationEditorOpen),c=L(e=>e.localizationEditorButtonId),u=L(e=>e.closeLocalizationEditor),h=m(e=>e.locLabels),v=m(e=>e.upsertLocLabel),W=m(e=>e.batch),k=m(e=>e.ribbons),d=m(e=>e.baseLanguageCode),X=N.useMemo(()=>{if(c){for(const e of Object.values(k))for(const t of e.tabs)for(const l of t.groups)for(const s of V(l))if(s.id===c)return s.source}},[k,c]),y=c?Y(c,X):null,b=y?.label??null,j=y?.tooltipTitle??null,S=y?.tooltipBody??null,I=B.useCallback(()=>{const e=h.find(o=>o.id===b),t=h.find(o=>o.id===j),l=h.find(o=>o.id===S),s=new Set([d]);return e?.titles.forEach(o=>s.add(o.languageCode)),t?.titles.forEach(o=>s.add(o.languageCode)),l?.titles.forEach(o=>s.add(o.languageCode)),Array.from(s).sort((o,r)=>o===d?-1:r===d?1:o-r).map(o=>({lcid:o,label:e?.titles.find(r=>r.languageCode===o)?.description??"",tooltipTitle:t?.titles.find(r=>r.languageCode===o)?.description??"",tooltipBody:l?.titles.find(r=>r.languageCode===o)?.description??""}))},[h,b,j,S,d]),[g,C]=B.useState([]),[R,w]=B.useState("");N.useEffect(()=>{p&&C(I())},[p,I]);const z=(e,t,l)=>{C(s=>s.map(o=>o.lcid===e?{...o,[t]:l}:o))},T=(e,t,l)=>{if(!l)return;const s=l.selectionStart??l.value.length,o=l.selectionEnd??l.value.length,r=g.find(K=>K.lcid===e)?.[t]??"",_=r.slice(0,s)+""+r.slice(o);z(e,t,_)},D=()=>{const e=parseInt(R,10);!e||g.find(t=>t.lcid===e)||(C(t=>[...t,{lcid:e,label:"",tooltipTitle:"",tooltipBody:""}]),w(""))},E=e=>{e!==d&&C(t=>t.filter(l=>l.lcid!==e))},O=()=>{if(!b||!j||!S)return;const e=t=>g.filter(l=>l[t]).map(l=>({languageCode:l.lcid,description:l[t]}));W(()=>{e("label").length>0&&v({id:b,titles:e("label")}),e("tooltipTitle").length>0&&v({id:j,titles:e("tooltipTitle")}),e("tooltipBody").length>0&&v({id:S,titles:e("tooltipBody")})}),u()},U=g.find(e=>e.lcid===d);return a.jsx(Q,{open:p,onOpenChange:(e,t)=>!t.open&&u(),children:a.jsx(Z,{className:n.surface,children:a.jsxs(ee,{children:[a.jsxs(ae,{action:a.jsx(x,{appearance:"subtle",icon:a.jsx(M,{}),onClick:u,"aria-label":"Close"}),children:[a.jsxs(te,{children:["Translations — ",U?.label||c||"Button"]}),a.jsxs($,{appearance:"tint",size:"small",style:{marginLeft:8},children:[g.length," language",g.length!==1?"s":""]})]}),a.jsxs(le,{className:n.body,children:[a.jsxs("div",{className:n.chipRow,children:[g.map(e=>{const t=f[e.lcid];return a.jsxs($,{className:n.chip,appearance:e.label?"filled":"outline",color:e.label?"brand":"informative",size:"medium",children:[t?.flag??"🌐"," ",t?.name??`LCID ${e.lcid}`,e.lcid!==d&&a.jsx("span",{style:{marginLeft:4,cursor:"pointer",opacity:.7},onClick:()=>E(e.lcid),"aria-label":`Remove ${t?.name}`,children:"×"})]},e.lcid)}),a.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[a.jsx(oe,{size:"small",style:{width:"180px"},placeholder:"LCID or language…",value:R,onChange:(e,t)=>w(t.value),list:"lcid-list",onKeyDown:e=>e.key==="Enter"&&D()}),a.jsx("datalist",{id:"lcid-list",children:ie.filter(e=>!g.find(t=>t.lcid===e)).map(e=>a.jsxs("option",{value:String(e),children:[f[e]?.flag," ",f[e]?.name," (",e,")"]},e))}),a.jsx(x,{size:"small",appearance:"subtle",icon:a.jsx(P,{}),onClick:D,"aria-label":"Add language"})]})]}),a.jsxs("div",{className:n.noteBar,children:["💡 LCID ",d," (",f[d]?.name??"base language",`) is the organisation's base language and cannot be removed. Use "Insert " to force a line break in long labels.`]}),a.jsxs("table",{className:n.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{className:n.th,style:{width:"160px"},children:"Language"}),a.jsx("th",{className:n.th,children:"Label"}),a.jsx("th",{className:n.th,children:"Tooltip title"}),a.jsx("th",{className:n.th,children:"Tooltip body"}),a.jsx("th",{className:n.th,style:{width:"40px"}})]})}),a.jsx("tbody",{children:g.map(e=>{const t=f[e.lcid];return a.jsxs("tr",{children:[a.jsxs("td",{className:`${n.td} ${n.langCell}`,children:[a.jsxs(H,{size:200,children:[t?.flag??"🌐"," ",t?.name??`LCID ${e.lcid}`]}),a.jsx("br",{}),a.jsx(H,{size:100,style:{color:i.colorNeutralForeground3},children:e.lcid})]}),a.jsx("td",{className:n.td,children:a.jsx(A,{value:e.label,onChange:l=>z(e.lcid,"label",l),onInsertBreak:l=>T(e.lcid,"label",l)})}),a.jsx("td",{className:n.td,children:a.jsx(A,{value:e.tooltipTitle,onChange:l=>z(e.lcid,"tooltipTitle",l),onInsertBreak:l=>T(e.lcid,"tooltipTitle",l)})}),a.jsx("td",{className:n.td,children:a.jsx(re,{value:e.tooltipBody,onChange:l=>z(e.lcid,"tooltipBody",l)})}),a.jsx("td",{className:`${n.td} ${n.actionCell}`,children:e.lcid!==d&&a.jsx(F,{content:"Remove this language",relationship:"label",children:a.jsx(x,{appearance:"subtle",size:"small",icon:a.jsx(q,{}),onClick:()=>E(e.lcid),"aria-label":"Remove language"})})})]},e.lcid)})})]})]}),a.jsxs(ne,{children:[a.jsx(x,{appearance:"secondary",onClick:u,children:"Cancel"}),a.jsx(x,{appearance:"primary",onClick:O,children:"Save translations"})]})]})})})};function A({value:n,onChange:p,onInsertBreak:c}){const u=N.useRef(null);return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[a.jsx("input",{ref:u,style:{width:"100%",fontFamily:"inherit",fontSize:13,padding:"3px 6px",border:"1px solid var(--colorNeutralStroke1)",borderRadius:4,boxSizing:"border-box"},value:n,onChange:h=>p(h.target.value)}),a.jsx(F,{content:"Insert Dataverse line break ()",relationship:"label",children:a.jsxs("button",{type:"button",onClick:()=>c(u.current),style:{fontSize:11,border:"none",background:"none",color:"var(--colorNeutralForeground3)",cursor:"pointer",padding:0,textAlign:"left",display:"flex",alignItems:"center",gap:2},children:[a.jsx(J,{fontSize:12})," Insert ⏎"]})})]})}function re({value:n,onChange:p}){return a.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,onChange:c=>p(c.target.value),rows:2})}export{he as LocalizationEditor,he as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{y as r,Z as A,h as $,cj as E,be as B,cA as X,bc as O,z as P}from"./fluent-icons-DUgjkNjy.js";import{a as m}from"./monaco-BIO15LCS.js";import{u as C,a as k,l as F,g as H}from"./index-CL8TmfXp.js";import{M as U}from"./MonacoEditor-CBUJNFgC.js";import{ai as V,aj as z,ak as G,t as d,d as W,al as _,M as K,f as Z,ac as Q,ad as q,am as N}from"./fluent-ui-Dde22_ZN.js";import"./dnd-BmqIZ1-i.js";const J=["Add","AddCircle","Alert","AppFolder","Archive","ArrowClockwise","ArrowCounterclockwise","ArrowDown","ArrowExport","ArrowImport","ArrowLeft","ArrowRight","ArrowSync","ArrowUp","Attach","Beaker","Bookmark","Bug","Building","Calculator","CalendarLtr","CalendarMonth","Call","Camera","Cart","Chart","Checkmark","CheckmarkCircle","Circle","ClipboardTask","Clock","Cloud","Code","CodeBlock","Comment","ContactCard","Copy","CreditCard","Crown","Cube","CursorClick","DataBarVertical","Delete","Diamond","Document","DocumentCopy","DocumentEdit","DocumentText","Download","Edit","Emoji","ErrorCircle","Eye","EyeOff","Filter","Flag","Flow","FolderOpen","Globe","Grid","Group","Heart","Home","Image","Info","Key","Library","Link","List","Location","Lock","Mail","Map","MegaphoneLoud","Money","MoreCircle","MoreHorizontal","Note","NoteEdit","NumberCircle1","Open","Organization","Pause","People","PeopleCommunity","Person","PersonAdd","PersonSearch","Phone","Play","Plug","Print","Question","Refresh","Rename","Save","Search","Send","Settings","Share","Shield","ShoppingBag","Sparkle","Star","StarEmphasis","Stop","Table","Tag","TaskList","TextBulletList","TextDescription","ThumbLike","Timer","ToggleLeft","ToggleRight","Tool","Translate","Umbrella","Unlock","Upload","Video","Warning","Wrench"];function I(t,p){const g=[];return g.push(t.languages.registerCompletionItemProvider("xml",{triggerCharacters:[":","$"],provideCompletionItems(l,e){const a=l.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column});if(!a.includes("$LocLabels:"))return{suggestions:[]};const b=a.lastIndexOf("$LocLabels:")+11,s=a.slice(b),i={startLineNumber:e.lineNumber,startColumn:e.column-s.length,endLineNumber:e.lineNumber,endColumn:e.column};return{suggestions:C.getState().locLabels.map(u=>({label:u.id,kind:t.languages.CompletionItemKind.Reference,insertText:u.id,range:i,detail:"LocLabel reference"}))}}})),g.push(t.languages.registerCompletionItemProvider("xml",{triggerCharacters:[":","$"],provideCompletionItems(l,e){const a=l.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column});if(!a.includes("$webresource:"))return{suggestions:[]};const b=a.lastIndexOf("$webresource:")+13,s=a.slice(b),i={startLineNumber:e.lineNumber,startColumn:e.column-s.length,endLineNumber:e.lineNumber,endColumn:e.column};return{suggestions:p().map(u=>({label:u,kind:t.languages.CompletionItemKind.File,insertText:u,range:i,detail:"Web resource"}))}}})),g.push(t.languages.registerCompletionItemProvider("xml",{triggerCharacters:['"'],provideCompletionItems(l,e){const a=l.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column});if(!/Command\s*=\s*"[^"]*$/.test(a))return{suggestions:[]};const s=a.match(/Command\s*=\s*"([^"]*)$/)?.[1]??"",i={startLineNumber:e.lineNumber,startColumn:e.column-s.length,endLineNumber:e.lineNumber,endColumn:e.column};return{suggestions:C.getState().commands.map(u=>({label:u.id,kind:t.languages.CompletionItemKind.Function,insertText:u.id,range:i,detail:"CommandDefinition"}))}}})),g.push(t.languages.registerCompletionItemProvider("xml",{triggerCharacters:['"'],provideCompletionItems(l,e){const a=l.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column});if(!/ModernImage\s*=\s*"[^"]*$/.test(a))return{suggestions:[]};const s=a.match(/ModernImage\s*=\s*"([^"]*)$/)?.[1]??"",i={startLineNumber:e.lineNumber,startColumn:e.column-s.length,endLineNumber:e.lineNumber,endColumn:e.column};return{suggestions:J.map(c=>({label:c,kind:t.languages.CompletionItemKind.Color,insertText:c,range:i,detail:"Fluent icon (ModernImage)",documentation:`Renders the ${c}_20_Regular Fluent icon`}))}}})),g}function S(t){t.forEach(p=>p.dispose())}const Y=P({drawer:{width:"960px",maxWidth:"90vw"},body:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",padding:0},infoBar:{flexShrink:0,margin:`${d.spacingVerticalS} ${d.spacingHorizontalM}`},tabRow:{flexShrink:0,padding:`0 ${d.spacingHorizontalM}`},toolbar:{flexShrink:0,display:"flex",alignItems:"center",gap:d.spacingHorizontalS,padding:`${d.spacingVerticalXS} ${d.spacingHorizontalM}`,borderTop:`1px solid ${d.colorNeutralStroke2}`,borderBottom:`1px solid ${d.colorNeutralStroke2}`},editorContainer:{flex:1,minHeight:0,overflow:"hidden"}}),ee=[{label:"Home Grid",value:"HomepageGrid"},{label:"Sub Grid",value:"SubGrid"},{label:"Form",value:"Form"},{label:"Application",value:"Application"}],ie=()=>{const t=Y(),p=k(n=>n.xmlDrawerOpen),g=k(n=>n.closeXmlDrawer),l=C(n=>n.ribbons),e=C(n=>n.baseline),a=C(n=>n.commands),b=C(n=>n.displayRules),s=C(n=>n.enableRules),i=C(n=>n.locLabels),f=k(n=>n.openImportXml),[c,u]=m.useState("HomepageGrid"),[x,y]=m.useState([]),v=m.useRef(null),w=m.useRef(null),h=m.useRef([]);m.useEffect(()=>{p&&F().then(n=>y(n.map(o=>o.name))).catch(()=>y([]))},[p]),m.useEffect(()=>()=>{S(h.current),h.current=[]},[]);const D=m.useCallback((n,o)=>{v.current=n,w.current=o,S(h.current),h.current=I(o,()=>x)},[x]);m.useEffect(()=>{w.current&&(S(h.current),h.current=I(w.current,()=>x))},[x]);const T=()=>{v.current?.getAction("editor.action.formatDocument")?.run()},L=m.useCallback(n=>{try{return`<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
${H({location:n,current:l[n],baseline:e[n],commands:a,displayRules:b,enableRules:s,locLabels:i,entityLogicalName:l[n].entityLogicalName})}`}catch(o){return`<!-- Error generating XML: ${String(o)} -->`}},[l,e,a,b,s,i])(c),j=()=>{navigator.clipboard.writeText(L)},M=()=>{const n=new Blob([L],{type:"application/xml"}),o=URL.createObjectURL(n),R=document.createElement("a");R.href=o,R.download=`RibbonDiffXml_${c}.xml`,R.click(),URL.revokeObjectURL(o)};return r.jsxs(V,{position:"end",open:p,onOpenChange:()=>g(),className:t.drawer,children:[r.jsx(z,{children:r.jsxs(G,{action:r.jsx(W,{appearance:"subtle",icon:r.jsx($,{}),onClick:g,"aria-label":"Close XML drawer"}),children:[r.jsx(A,{style:{marginRight:d.spacingHorizontalS}}),"RibbonDiffXml"]})}),r.jsxs(_,{className:t.body,children:[r.jsx(K,{className:t.infoBar,intent:"info",children:r.jsxs(Z,{children:["This is the ",r.jsx("strong",{children:"RibbonDiffXml"})," that will be packaged into your solution ZIP and imported into Dataverse. It contains only the delta (your changes), not the full ribbon."]})}),r.jsx("div",{className:t.tabRow,children:r.jsx(Q,{selectedValue:c,onTabSelect:(n,o)=>u(o.value),children:ee.map(n=>r.jsx(q,{value:n.value,children:n.label},n.value))})}),r.jsxs("div",{className:t.toolbar,children:[r.jsx(N,{icon:r.jsx(E,{}),onClick:j,children:"Copy"}),r.jsx(N,{icon:r.jsx(B,{}),onClick:M,children:"Download"}),r.jsx(N,{icon:r.jsx(X,{}),onClick:T,children:"Format XML"}),r.jsx(N,{icon:r.jsx(O,{}),onClick:()=>f(L),children:"Import this XML"})]}),r.jsx("div",{className:t.editorContainer,children:r.jsx(U,{language:"xml",value:L,readOnly:!0,height:"100%",onMount:D})})]})]})};export{ie as XmlDrawer,ie as default};
|