@mohsinonxrm/pptb-commandbar-studio 0.6.1 → 0.6.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 +19 -4
- package/dist/assets/{BulkPublishModal-DqX2QmUD.js → BulkPublishModal-mFfxdo1T.js} +1 -1
- package/dist/assets/{CommandEditorPanel-DidGBtFC.js → CommandEditorPanel-_mV9SqAb.js} +1 -1
- package/dist/assets/{CommandPalette-AuDfsF8l.js → CommandPalette-CK3uU6Ky.js} +1 -1
- package/dist/assets/{ConflictDrawer-DxQ_jd-x.js → ConflictDrawer-BFlon1xn.js} +1 -1
- package/dist/assets/{CrmParameterEditor-BdmP65mF.js → CrmParameterEditor-B84bdjcT.js} +1 -1
- package/dist/assets/{DiffViewer-BZuqvP4f.js → DiffViewer-JSOMstAl.js} +2 -2
- package/dist/assets/{HideInsteadOfDeleteModal-BYHCTZrG.js → HideInsteadOfDeleteModal-DYsP_BRs.js} +1 -1
- package/dist/assets/{IconPickerModal-Bw0C7KwV.js → IconPickerModal-BF3KU0Ux.js} +1 -1
- package/dist/assets/{ImportXmlModal-B8NgiUDZ.js → ImportXmlModal-BYj1QmDX.js} +1 -1
- package/dist/assets/{LocalizationEditor-tmniX5PC.js → LocalizationEditor-SeIMV_0G.js} +1 -1
- package/dist/assets/{MonacoEditor-Bbg9u2FW.js → MonacoEditor-DakCq511.js} +2 -2
- package/dist/assets/{NewButtonModal-BVvlbCv4.js → NewButtonModal-D3iJDvUq.js} +1 -1
- package/dist/assets/{NewGroupModal-CgQy-uo4.js → NewGroupModal-Cfywgyga.js} +1 -1
- package/dist/assets/{NewTabModal-B_2-kwAx.js → NewTabModal-DGNwUnJ5.js} +1 -1
- package/dist/assets/{RuleEditorPanel-BkNwBgaP.js → RuleEditorPanel-BmI_wJKH.js} +1 -1
- package/dist/assets/{ScalingEditorPanel-ezMkzvG1.js → ScalingEditorPanel-VCqXvcQy.js} +1 -1
- package/dist/assets/{TabDisplayRulesPanel-trzExQ1T.js → TabDisplayRulesPanel-D26HGtKC.js} +1 -1
- package/dist/assets/{UrlComposerModal-BlVXHKRM.js → UrlComposerModal-gVBqcCZd.js} +1 -1
- package/dist/assets/{WebResourceBrowser-DaPOZQ5X.js → WebResourceBrowser-Hrw1yujP.js} +1 -1
- package/dist/assets/{XmlDrawer-BI6Wy6kL.js → XmlDrawer-lnZmbePV.js} +1 -1
- package/dist/assets/{cssMode-DdC7kBk-.js → cssMode-BGIqMXMp.js} +1 -1
- package/dist/assets/{dnd-fsSwRnQv.js → dnd-vmvAsOrM.js} +1 -1
- package/dist/assets/{fluent-icons-DxKNRZ1A.js → fluent-icons-4bzebHz-.js} +1 -1
- package/dist/assets/{fluent-ui-D7EtYwEg.js → fluent-ui-lAhdF0Ck.js} +1 -1
- package/dist/assets/{freemarker2-DDn-Wpd6.js → freemarker2-DpL6dihh.js} +1 -1
- package/dist/assets/{handlebars-Ck_SjSJx.js → handlebars-ChRbmRjV.js} +1 -1
- package/dist/assets/{html-BaJUqhKx.js → html-Bt7ZeSoE.js} +1 -1
- package/dist/assets/{htmlMode-CnYhJfhG.js → htmlMode-Uz2nWy9x.js} +1 -1
- package/dist/assets/{index-Bu7BlRFk.js → index-B2t4gwW0.js} +3 -3
- package/dist/assets/{javascript-2UlV1Qbm.js → javascript-Bu0Wr1JA.js} +1 -1
- package/dist/assets/{jsonMode-BmSpB9yr.js → jsonMode-Bc_oOneo.js} +1 -1
- package/dist/assets/{liquid-CE2reFvH.js → liquid-Cj1v6MBK.js} +1 -1
- package/dist/assets/{lspLanguageFeatures-BvbzEddk.js → lspLanguageFeatures-CbQqhnvj.js} +1 -1
- package/dist/assets/{mdx-BvcZv3tC.js → mdx-E7c9inFC.js} +1 -1
- package/dist/assets/{monaco-Bx8A1Vm1.js → monaco-BoSoLy50.js} +180 -179
- package/dist/assets/{python-MTPSN2vk.js → python-C7ICMPw1.js} +1 -1
- package/dist/assets/{razor-Ccq_CgR8.js → razor-xjSsEwAN.js} +1 -1
- package/dist/assets/{server.browser-C3R9jebn.js → server.browser-BZYwcDL4.js} +1 -1
- package/dist/assets/{tsMode-2cv3qhqp.js → tsMode-XBeIdV9f.js} +1 -1
- package/dist/assets/{typescript-BD6t7JEG.js → typescript-sgsLltTO.js} +1 -1
- package/dist/assets/{webResourceService-CvyHBu7T.js → webResourceService-DGt6sRPR.js} +1 -1
- package/dist/assets/{xml-DJGPA7j9.js → xml-DFgHgBBL.js} +1 -1
- package/dist/assets/{xmlValidator-D7JG-eNC.js → xmlValidator-D-tVo-1Z.js} +1 -1
- package/dist/assets/{yaml-Cpl0dvFM.js → yaml-DWfXsscO.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,17 +9,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.6.2] - 2026-10-22
|
|
13
|
+
|
|
14
|
+
A security hotfix: 0.6.1's DOMPurify fix didn't reach the shipped bundle.
|
|
15
|
+
|
|
16
|
+
### 🔒 Security
|
|
17
|
+
|
|
18
|
+
- **The Monaco editor now really uses DOMPurify 3.4.17.** Monaco ships its own copy of DOMPurify
|
|
19
|
+
(3.2.7 in Monaco 0.55.1) and imports that copy, not the npm package, so 0.6.1's npm override
|
|
20
|
+
satisfied `npm audit` but left 3.2.7 in the bundle. The build now replaces Monaco's copy with
|
|
21
|
+
the installed `dompurify` (3.4.17), which clears GHSA-cg2g-xh64-v4q7, GHSA-mrv2-3pqr-j5jr and
|
|
22
|
+
GHSA-c6gr-qvv4-5v3f among others. Nothing else changes; the editors (the XML drawer and the
|
|
23
|
+
command editor) work as before.
|
|
24
|
+
- **CI and the release workflow check the bundled DOMPurify** against the installed version, so a
|
|
25
|
+
bundle with Monaco's own copy can't be published again.
|
|
26
|
+
|
|
12
27
|
## [0.6.1] - 2026-10-22
|
|
13
28
|
|
|
14
|
-
A security hotfix for 0.6.0.
|
|
29
|
+
A security hotfix for 0.6.0. **Superseded by 0.6.2:** the fix below didn't reach the bundle.
|
|
15
30
|
|
|
16
31
|
### 🔒 Security
|
|
17
32
|
|
|
18
33
|
- **DOMPurify 3.4.17 in the Monaco editor.** `monaco-editor` 0.55.1 pins DOMPurify 3.2.7, which
|
|
19
34
|
has advisories rated up to critical (including GHSA-cg2g-xh64-v4q7, GHSA-mrv2-3pqr-j5jr and
|
|
20
|
-
GHSA-c6gr-qvv4-5v3f). An npm override
|
|
21
|
-
`npm audit --omit=dev` reports 0 vulnerabilities
|
|
22
|
-
|
|
35
|
+
GHSA-c6gr-qvv4-5v3f). An npm override resolves the npm dependency to 3.4.17 and
|
|
36
|
+
`npm audit --omit=dev` reports 0 vulnerabilities, but Monaco imports its own bundled copy, so
|
|
37
|
+
the published 0.6.1 still contains DOMPurify 3.2.7. Fixed in 0.6.2.
|
|
23
38
|
|
|
24
39
|
## [0.6.0] - 2026-10-18
|
|
25
40
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z as n,y as ws}from"./fluent-icons-DxKNRZ1A.js";import{a as L,R as se}from"./monaco-Bx8A1Vm1.js";import{p as fe,h as xs,g as Cs,m as Se,j as Is,k as Rs,l as js,n as Ss,o as vs,q as rs,r as ks,s as Ds,t as Ps,v as $s,e as ge,x as Ns,y as As,z as Ls,A as Ge,B as Es,D as Ts,E as ve,F as zs,G as Xs,H as B,c as Ae,I as Ms,J as Os,K as Je,L as Us,M as ke,N as Bs,O as Ye,P as Vs,a as De,u as S,b as re,Q as Fs,R as Ks,S as Ze}from"./index-Bu7BlRFk.js";import{w as qs,v as cs}from"./xmlValidator-D7JG-eNC.js";import{c as Ws}from"./webResourceService-CvyHBu7T.js";import{D as _s,h as Hs,i as Gs,j as Js,k as Ys,M as O,e as U,t as _,a5 as Zs,T as Pe,F as $e,an as Qs,O as Qe,I as en,a1 as sn,a6 as nn,B as Ne,c as tn,ao as on,l as an}from"./fluent-ui-D7EtYwEg.js";import"./dnd-fsSwRnQv.js";import"./ruleKinds-B9hACGaq.js";import"./crmParameters-rgfZhhzN.js";let es=0;async function Le(e){const t=typeof window<"u"?window.toolboxAPI:void 0;es++===0&&await ss(()=>t?.preventClose?.());try{return await e()}finally{--es===0&&await ss(()=>t?.releasePreventClose?.())}}const ln=2e3;async function ss(e){let t;try{await Promise.race([e(),new Promise(i=>t=setTimeout(i,ln))])}catch{}finally{clearTimeout(t)}}function ce(e,t){const i=e.match(new RegExp(`\\s${t}="([^"]*)"`));return i?i[1]:null}function ns(e,t,i){const d=e.indexOf(i,t);return e.slice(t,d===-1?void 0:d).match(/<result\s[^>]*>/g)??[]}function ts(e){const t=e.find(i=>ce(i,"result")!=="success");if(t){const i=ce(t,"errorcode")??"",d=ce(t,"errortext")??"unknown error";return{ok:!1,message:`Dataverse rejected the ribbon (${i}): ${d}`}}return null}function rn(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 a=e.search(/<ribbon\s[^>]*processed="true"/);return a===-1?{ok:!1,message:"Import completed, but Dataverse did not process the application ribbon."}:ts(ns(e,a,"</ribbon>"))??{ok:!0,message:"Application ribbon imported."}}const i=new Set(t.names.filter(Boolean).map(a=>a.toLowerCase())),d=/<entityRibbon\s[^>]*>/g;let c;for(;c=d.exec(e);){const a=(ce(c[0],"id")??"").toLowerCase();if(i.has(a))return ce(c[0],"processed")!=="true"?{ok:!1,message:`Dataverse did not process the ribbon for ${a}.`}:ts(ns(e,c.index,"</entityRibbon>"))??{ok:!0,message:`Ribbon for ${a} 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 Y=window.dataverseAPI;function cn(e,t){return Y.execute({operationName:"ImportSolution",operationType:"action",parameters:{CustomizationFile:e,ImportJobId:t,OverwriteUnmanagedCustomizations:!0,PublishWorkflows:!1}})}function dn(e){const t=e.map(i=>`<entity>${B(i)}</entity>`).join("");return Y.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:`<importexportxml><entities>${t}</entities></importexportxml>`}})}function os(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 un(e){const t=e.titles.map(i=>`<Title languagecode="${i.languageCode}" description="${B(i.description)}"/>`).join("");return`<LocLabel Id="${B(e.id)}"><Titles>${t}</Titles></LocLabel>`}async function ds(e){const t=e.entity?.logicalName??"{!EntityLogicalName}",i={deletedContainerIds:e.plan.deletedContainerIds??[],movedButtons:e.plan.movedButtons??[],editedLocLabelIds:e.plan.editedLocLabelIds??[],editedTabIds:e.plan.editedTabIds??[]},d=e.locLabels.filter(o=>i.editedLocLabelIds.includes(o.id)),c=e.languageCode??1033;for(const o of e.plan.renamedLabels??[]){const p=d.find(T=>T.id===o.id)??e.locLabels.find(T=>T.id===o.id),g=[{languageCode:c,description:o.text},...(p?.titles??[]).filter(T=>T.languageCode!==c)],I=d.findIndex(T=>T.id===o.id);I>=0?d[I]={id:o.id,titles:g}:d.push({id:o.id,titles:g})}let a=d.length?fe(`<RibbonDiffXml><LocLabels>${d.map(un).join("")}</LocLabels></RibbonDiffXml>`):xs();for(const o of e.locations){const p=Cs({current:o.current,baseline:o.baseline,commands:e.commands,enableRules:e.enableRules,displayRules:e.displayRules,locLabels:e.locLabels,entityLogicalName:t,location:o.current.location,languageCode:e.languageCode});a=Se(a,fe(p))}const r=[],b=[];for(const o of e.locations)for(const p of o.current.tabs){if(!i.editedTabIds.includes(p.id))continue;if(p.tabDisplayRules.length>0){const I=Is(p,e.entity===null);I&&b.push(I)}const g=new Set(p.tabDisplayRules.map(I=>I.tabCommand));for(const I of o.baseline.tabs.find(T=>T.id===p.id)?.tabDisplayRules??[])g.has(I.tabCommand)||r.push(I.tabCommand)}b.length>0&&(a=Se(a,fe(`<RibbonDiffXml><RuleDefinitions><TabDisplayRules>${b.join("")}</TabDisplayRules></RuleDefinitions></RibbonDiffXml>`)));const m=[...e.commands.filter(o=>e.plan.editedCommandIds.includes(o.id)).map(Rs)],R={enable:e.enableRules.filter(o=>e.plan.editedEnableRuleIds.includes(o.id)).map(Ss),display:e.displayRules.filter(o=>e.plan.editedDisplayRuleIds.includes(o.id)).map(js)};(m.length||R.enable.length||R.display.length)&&(a=Se(a,fe(`<RibbonDiffXml><CommandDefinitions>${m.join("")}</CommandDefinitions><RuleDefinitions><DisplayRules>${R.display.join("")}</DisplayRules><EnableRules>${R.enable.join("")}</EnableRules></RuleDefinitions></RibbonDiffXml>`)));const x=(o,p)=>{for(const g of Array.from(o.keys()))p.includes(g)||o.delete(g)},$=e.locations.flatMap(o=>o.current.tabs.filter(p=>!o.baseline.tabs.some(g=>g.id===p.id)).map(vs));x(a.commandDefinitions,[...e.plan.editedCommandIds,...$]),x(a.enableRules,e.plan.editedEnableRuleIds),x(a.displayRules,e.plan.editedDisplayRuleIds);const u=await rs(e.entity?.logicalName??null),D=ks(u),C=e.plan.deletedButtonIds.filter(o=>!D.has(o));if(C.length>0)throw new Error(`Can't delete ${C.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 f=Ds(u),v=i.deletedContainerIds.filter(o=>!f.has(o));if(v.length>0)throw new Error(`Can't delete ${v.join(", ")}: not added by this table's unmanaged customizations (it comes from a managed solution or the platform). Undo the delete.`);const V=i.movedButtons.filter(o=>!D.has(o.id)).map(o=>o.id);if(V.length>0)throw new Error(`Can't move ${V.join(", ")}: not defined in this table's unmanaged customizations. Undo the move.`);const F=Ps(u),Z=(e.plan.uncustomisedCommandIds??[]).filter(o=>u.commandDefinitions.has(o)&&!$s(o,F));if(Z.length>0)throw new Error(`Can't uncustomise ${Z.join(", ")}: it is your own command (your customizations' buttons use it and no other solution defines it), so removing it would leave those buttons without a command. Undo the uncustomise.`);const M=new Set;for(const o of e.locations)for(const p of o.current.tabs)for(const g of p.groups)for(const I of ge(g))for(const T of Ns(I))M.add(T);const y=e.plan.uncustomisedCommandIds??[],E=new Set,H=new Set;for(const o of e.commands)if(!(!M.has(o.id)||y.includes(o.id))){o.enableRules.forEach(p=>E.add(p)),o.displayRules.forEach(p=>H.add(p));for(const p of o.rawRuleRefs??[]){const g=/^\s*<(EnableRule|DisplayRule)\b[^>]*?\sId="([^"]+)"/.exec(p.xml);g&&(g[1]==="EnableRule"?E:H).add(g[2])}}let h=As(u,a,{retainedCommandIds:M,editedCommandIds:e.plan.editedCommandIds,editedEnableRuleIds:e.plan.editedEnableRuleIds,editedDisplayRuleIds:e.plan.editedDisplayRuleIds,deletedControlIds:e.plan.deletedButtonIds,unhiddenControlIds:e.plan.unhiddenButtonIds,deletedContainerIds:i.deletedContainerIds,movedControls:i.movedButtons,removedTabCommands:r,uncustomisedCommandIds:y,retainedEnableRuleIds:E,retainedDisplayRuleIds:H});for(const o of e.plan.renamedLabels??[])o.newLabel&&(h=Ls(h,o.containerId,`$LocLabels:${o.id}`));const w=new Set([...Ge(u),...Ge(h)].map(o=>o.id)),K={};for(const o of e.locations)for(const[p,g]of Object.entries(o.baseline.scalingByTab??{}))K[p]={maxSizes:g.maxSizes.filter(I=>!w.has(I.id)).map(I=>I.sequence),scales:g.scales.filter(I=>!w.has(I.id)).map(I=>I.sequence)};const q=Es(h,K);if(q.problems.length>0)throw new Error(`Not published: ${q.problems.join("; ")}.`);return h=q.parts,{scalingChanges:q.changes,xml:zs(h),parts:h,elementCount:ve(h),preservedCount:ve(u),changedCount:ve(a),changedKeys:Ts(u,h),newKeys:Object.keys(h).flatMap(o=>Array.from(h[o].keys()).filter(p=>!u[o].has(p)).map(p=>`${o}:${p}`)),layerDefinitionIds:{commandIds:Array.from(u.commandDefinitions.keys()),enableRuleIds:Array.from(u.enableRules.keys()),displayRuleIds:Array.from(u.displayRules.keys())}}}function us(e,t){const i=[],d={},c={},a={},r={},b=new Set,m=new Set,R=new Set;for(const{current:u,baseline:D}of e.locations)for(const C of[D,u])for(const f of C.tabs)for(const v of f.groups)for(const V of ge(v))for(const F of V.menu?.sections??[])R.add(F.controlsId);for(const{current:u,baseline:D}of e.locations){Object.assign(a,D.templateLayouts);for(const C of D.tabs){i.push(C.id),C.label&&(r[C.id]={Title:C.label});for(const f of C.groups){b.add(f.id),i.push(f.id),f.label&&(r[f.id]={Title:f.label,Label:f.label});for(const v of ge(f))i.push(v.id),v.source&&(r[v.id]=v.source.attributes)}}for(const C of u.tabs)for(const f of C.groups)m.add(f.id);for(const C of[D,u])for(const f of C.tabs)for(const v of f.groups)v.template&&(c[v.id]=v.template)}const x=u=>b.has(u.groupId)&&!m.has(u.groupId);for(const{baseline:u}of e.locations)for(const[D,C]of Object.entries(u.scalingByTab??{}))d[D]={...C,maxSizes:C.maxSizes.filter(f=>!x(f)),scales:C.scales.filter(f=>!x(f))};const $=(u,D)=>{if(!u)return;const C=new Set(D??[]);return u.map(f=>f.id).filter(f=>!C.has(f))};return{changedKeys:t.changedKeys,newKeys:t.newKeys,commands:e.commands,known:{commandIds:$(e.baselineCommands,t.layerDefinitionIds?.commandIds),enableRuleIds:$(e.baselineEnableRules,t.layerDefinitionIds?.enableRuleIds),displayRuleIds:$(e.baselineDisplayRules,t.layerDefinitionIds?.displayRuleIds),elementIds:i},loadedAttributes:r,publisherPrefix:e.publisherPrefix,tabScaling:d,groupTemplates:c,templateLayouts:a,menuControlsIds:R,...e.entity?{places:{entityLogicalName:e.entity.logicalName,tabByCollection:Object.fromEntries(Xs(e.locations.map(u=>u.baseline),e.entity.logicalName))}}:{}}}function mn(e,t){return new Promise((i,d)=>{const c=setTimeout(()=>d(new Error(`it didn't finish within ${Math.round(t/1e3)} s`)),t);e.then(a=>{clearTimeout(c),i(a)},a=>{clearTimeout(c),d(a)})})}async function is(e,t={}){const i=await ds(e),d=us(e,i),c=[],a=qs(i.parts);if(t.lookupWebResources&&a.length>0)try{d.webResources=await t.lookupWebResources(a)}catch(r){c.push({severity:"warning",code:"webresource-lookup",message:`Couldn't check the ${a.length} referenced web resource(s): ${r instanceof Error?r.message:String(r)}`})}return{findings:[...cs(i.parts,d),...c],xml:i.xml}}async function hn(e,t,i={}){const d=i.attempts??3,c=i.contentKeys??[];let a={missing:[],unexpected:[],differing:[]};for(let b=0;b<d;b++){b>0&&await new Promise(m=>setTimeout(m,i.delayMs??5e3));try{a=Vs(t,await rs(e),{contentKeys:c})}catch(m){return{ok:!1,missing:[],unexpected:[],differing:[],message:`Couldn't read the published ribbon layer to verify it (${m instanceof Error?m.message:String(m)}).`}}if(a.missing.length===0&&a.unexpected.length===0&&a.differing.length===0){const m=c.length;return{ok:!0,...a,message:"Verified: the published ribbon layer has every element that was imported"+(m>0?`, and the ${m} element(s) this publish changed have the imported content.`:".")}}}const r=b=>b.slice(0,5).join(", ")+(b.length>5?", …":"");return{ok:!1,...a,message:"The published ribbon layer doesn't match what was imported"+(a.missing.length?`; missing: ${r(a.missing)}`:"")+(a.unexpected.length?`; unexpected: ${r(a.unexpected)}`:"")+(a.differing.length?`; different content: ${r(a.differing)}`:"")+". Reload the table and check before publishing again."}}function as(e,t){return Le(()=>pn(e,t))}async function pn(e,t){const i=Ae.getState(),d=e.entity?e.entity.logicalName:"Application ribbon",c={onProgress:t,...e.busy};t?.(`Reading existing ribbon customizations for ${d}…`),i.logInfo("publish",`Reading unmanaged ribbon layer for ${d}.`);const a=e.languageCode??await Ms(),r=await ds({...e,languageCode:a});i.logInfo("publish",`RibbonDiffXml for ${d}: ${r.preservedCount} existing element(s) preserved, ${r.changedCount} element(s) from this session, ${r.elementCount} total.`);for(const y of r.scalingChanges)i.logWarn("publish",Os(y));const b=cs(r.parts,us({...e,publisherPrefix:e.solution.publisherPrefix},r));for(const y of b)y.severity==="warning"&&i.logWarn("publish",y.message);const m=b.filter(y=>y.severity==="error");if(m.length>0){for(const y of m)i.logError("publish",y.message);throw new Error(`The pre-publish check found ${m.length} error(s), so nothing was imported: `+m.map(y=>y.message).join("; "))}const R=e.entity===null;if(R&&!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 x=e.entity?.schemaName||e.entity?.logicalName||"",$=R?Je({applicationRibbonDiffXml:r.xml}):Je({entities:[{schemaName:x,localizedName:e.entity?.displayName||x,ribbonDiffXml:r.xml}]}),u=R?[{type:50,schemaName:":RibbonDiffXml",behavior:0}]:[{type:1,schemaName:e.entity.logicalName,behavior:2}],D=gn({...e.solution,languageCode:a,rootComponents:u});t?.("Packaging solution ZIP…");const C=Us({"customizations.xml":ke($),"solution.xml":ke(D),"[Content_Types].xml":ke('<?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 f="";for(let y=0;y<C.length;y++)f+=String.fromCharCode(C[y]);const v=btoa(f),V=async y=>{t?.(`Importing ${d} ribbon${y}…`);const E=crypto.randomUUID();i.logInfo("publish",`Importing solution${y} (import job ${E})…`),await Ye("Import",()=>cn(v,E),c);const H=150,h=2e3;let w=await Y.getImportJobStatus(E),K=0;for(;!os(w)&&K<H;)await new Promise(p=>setTimeout(p,h)),w=await Y.getImportJobStatus(E),K++,K%10===0&&t?.(`Still importing… (${K*2}s elapsed)`);if(!os(w))throw new Error(`Solution import did not complete within ${H*h/1e3} seconds. Check Solutions › History for import job ${E}.`);t?.("Verifying the import…");const q=await Y.retrieve("importjob",E,["data"]),o=rn(q.data,R?{kind:"application"}:{kind:"entity",names:[x,e.entity.logicalName]});if(!o.ok)throw i.logError("publish",o.message),new Error(o.message);return i.logInfo("publish",o.message),E},F=async()=>{t?.("Publishing customizations…"),await Ye("Publish",async()=>{R?await Y.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:"<importexportxml><ribbons><ribbon></ribbon></ribbons></importexportxml>"}}):await dn([e.entity.logicalName])},c)};t?.("Checking that no other solution operation is running…"),await Bs(c);const Z=await V("");let M;if(e.publishCustomizations!==!1){await F();{i.logInfo("publish","Refreshing Unified Interface command-bar metadata (second import of the same package)…");try{await V(" (refreshing Unified Interface metadata)"),await F()}catch(y){throw new Error(`Your changes were imported and published, but refreshing Unified Interface's command-bar metadata failed (${y instanceof Error?y.message:String(y)}). New or changed buttons may not appear in the app until you publish again.`)}}t?.("Verifying the published ribbon…"),M=await hn(e.entity?.logicalName??null,r.parts,{delayMs:e.verifyDelayMs,contentKeys:r.changedKeys}),M.ok?i.logInfo("publish",M.message):i.logWarn("publish",M.message)}else i.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?`${d} ribbon published.`:`${d} ribbon imported (not published).`),{elementCount:r.elementCount,preservedCount:r.preservedCount,importJobId:Z,verification:M,parts:r.parts,changedKeys:r.changedKeys}}function bn(e,t){return Le(()=>fn(e,t))}async function fn(e,t){const i=Ae.getState(),d=2e3,c=600*1e3;e?.("Starting asynchronous publish (PublishAllXmlAsync)..."),i.logInfo("publish","Calling PublishAllXmlAsync action.");const r=(await Y.execute({operationName:"PublishAllXmlAsync",operationType:"action"}))?.AsyncOperationId;if(!r)throw new Error("PublishAllXmlAsync did not return AsyncOperationId.");i.logInfo("publish",`PublishAllXmlAsync job id: ${r}`),e?.("Async publish job started. Waiting for completion...");const b=Date.now();let m=0,R;for(;Date.now()-b<c;){m+=1;const x=await Y.retrieve("asyncoperation",r,["asyncoperationid","statecode","statuscode","name","message","friendlymessage","completedon"]);if(R=x.statuscode,x.statecode===3||!!x.completedon){if(typeof x.statuscode=="number"&&x.statuscode!==30){const u=x.friendlymessage||x.message||`statuscode=${x.statuscode}`;throw new Error(`Asynchronous publish failed: ${u}`)}return e?.("Asynchronous publish completed successfully."),i.logInfo("publish",`PublishAllXmlAsync completed in ${m} poll(s).`),{asyncOperationId:r,statusCode:x.statuscode}}e?.(`Waiting for async publish job... (poll ${m})`),await new Promise(u=>setTimeout(u,d))}throw new Error(`Asynchronous publish timed out after ${Math.round(c/1e3)} seconds (last status: ${R??"unknown"}).`)}function gn(e){const t=e.publisherUniqueName?.trim()||"DefaultPublisher",i=e.publisherName?.trim()||t,d=e.publisherPrefix?.trim()||"new",c=e.languageCode||1033,a=e.friendlyName?.trim()||e.uniqueName,r=e.rootComponents.length===0?"<RootComponents/>":`<RootComponents>
|
|
1
|
+
import{z as n,y as ws}from"./fluent-icons-4bzebHz-.js";import{a as L,R as se}from"./monaco-BoSoLy50.js";import{p as fe,h as xs,g as Cs,m as Se,j as Is,k as Rs,l as js,n as Ss,o as vs,q as rs,r as ks,s as Ds,t as Ps,v as $s,e as ge,x as Ns,y as As,z as Ls,A as Ge,B as Es,D as Ts,E as ve,F as zs,G as Xs,H as B,c as Ae,I as Ms,J as Os,K as Je,L as Us,M as ke,N as Bs,O as Ye,P as Vs,a as De,u as S,b as re,Q as Fs,R as Ks,S as Ze}from"./index-B2t4gwW0.js";import{w as qs,v as cs}from"./xmlValidator-D-tVo-1Z.js";import{c as Ws}from"./webResourceService-DGt6sRPR.js";import{D as _s,h as Hs,i as Gs,j as Js,k as Ys,M as O,e as U,t as _,a5 as Zs,T as Pe,F as $e,an as Qs,O as Qe,I as en,a1 as sn,a6 as nn,B as Ne,c as tn,ao as on,l as an}from"./fluent-ui-lAhdF0Ck.js";import"./dnd-vmvAsOrM.js";import"./ruleKinds-B9hACGaq.js";import"./crmParameters-rgfZhhzN.js";let es=0;async function Le(e){const t=typeof window<"u"?window.toolboxAPI:void 0;es++===0&&await ss(()=>t?.preventClose?.());try{return await e()}finally{--es===0&&await ss(()=>t?.releasePreventClose?.())}}const ln=2e3;async function ss(e){let t;try{await Promise.race([e(),new Promise(i=>t=setTimeout(i,ln))])}catch{}finally{clearTimeout(t)}}function ce(e,t){const i=e.match(new RegExp(`\\s${t}="([^"]*)"`));return i?i[1]:null}function ns(e,t,i){const d=e.indexOf(i,t);return e.slice(t,d===-1?void 0:d).match(/<result\s[^>]*>/g)??[]}function ts(e){const t=e.find(i=>ce(i,"result")!=="success");if(t){const i=ce(t,"errorcode")??"",d=ce(t,"errortext")??"unknown error";return{ok:!1,message:`Dataverse rejected the ribbon (${i}): ${d}`}}return null}function rn(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 a=e.search(/<ribbon\s[^>]*processed="true"/);return a===-1?{ok:!1,message:"Import completed, but Dataverse did not process the application ribbon."}:ts(ns(e,a,"</ribbon>"))??{ok:!0,message:"Application ribbon imported."}}const i=new Set(t.names.filter(Boolean).map(a=>a.toLowerCase())),d=/<entityRibbon\s[^>]*>/g;let c;for(;c=d.exec(e);){const a=(ce(c[0],"id")??"").toLowerCase();if(i.has(a))return ce(c[0],"processed")!=="true"?{ok:!1,message:`Dataverse did not process the ribbon for ${a}.`}:ts(ns(e,c.index,"</entityRibbon>"))??{ok:!0,message:`Ribbon for ${a} 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 Y=window.dataverseAPI;function cn(e,t){return Y.execute({operationName:"ImportSolution",operationType:"action",parameters:{CustomizationFile:e,ImportJobId:t,OverwriteUnmanagedCustomizations:!0,PublishWorkflows:!1}})}function dn(e){const t=e.map(i=>`<entity>${B(i)}</entity>`).join("");return Y.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:`<importexportxml><entities>${t}</entities></importexportxml>`}})}function os(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 un(e){const t=e.titles.map(i=>`<Title languagecode="${i.languageCode}" description="${B(i.description)}"/>`).join("");return`<LocLabel Id="${B(e.id)}"><Titles>${t}</Titles></LocLabel>`}async function ds(e){const t=e.entity?.logicalName??"{!EntityLogicalName}",i={deletedContainerIds:e.plan.deletedContainerIds??[],movedButtons:e.plan.movedButtons??[],editedLocLabelIds:e.plan.editedLocLabelIds??[],editedTabIds:e.plan.editedTabIds??[]},d=e.locLabels.filter(o=>i.editedLocLabelIds.includes(o.id)),c=e.languageCode??1033;for(const o of e.plan.renamedLabels??[]){const p=d.find(T=>T.id===o.id)??e.locLabels.find(T=>T.id===o.id),g=[{languageCode:c,description:o.text},...(p?.titles??[]).filter(T=>T.languageCode!==c)],I=d.findIndex(T=>T.id===o.id);I>=0?d[I]={id:o.id,titles:g}:d.push({id:o.id,titles:g})}let a=d.length?fe(`<RibbonDiffXml><LocLabels>${d.map(un).join("")}</LocLabels></RibbonDiffXml>`):xs();for(const o of e.locations){const p=Cs({current:o.current,baseline:o.baseline,commands:e.commands,enableRules:e.enableRules,displayRules:e.displayRules,locLabels:e.locLabels,entityLogicalName:t,location:o.current.location,languageCode:e.languageCode});a=Se(a,fe(p))}const r=[],b=[];for(const o of e.locations)for(const p of o.current.tabs){if(!i.editedTabIds.includes(p.id))continue;if(p.tabDisplayRules.length>0){const I=Is(p,e.entity===null);I&&b.push(I)}const g=new Set(p.tabDisplayRules.map(I=>I.tabCommand));for(const I of o.baseline.tabs.find(T=>T.id===p.id)?.tabDisplayRules??[])g.has(I.tabCommand)||r.push(I.tabCommand)}b.length>0&&(a=Se(a,fe(`<RibbonDiffXml><RuleDefinitions><TabDisplayRules>${b.join("")}</TabDisplayRules></RuleDefinitions></RibbonDiffXml>`)));const m=[...e.commands.filter(o=>e.plan.editedCommandIds.includes(o.id)).map(Rs)],R={enable:e.enableRules.filter(o=>e.plan.editedEnableRuleIds.includes(o.id)).map(Ss),display:e.displayRules.filter(o=>e.plan.editedDisplayRuleIds.includes(o.id)).map(js)};(m.length||R.enable.length||R.display.length)&&(a=Se(a,fe(`<RibbonDiffXml><CommandDefinitions>${m.join("")}</CommandDefinitions><RuleDefinitions><DisplayRules>${R.display.join("")}</DisplayRules><EnableRules>${R.enable.join("")}</EnableRules></RuleDefinitions></RibbonDiffXml>`)));const x=(o,p)=>{for(const g of Array.from(o.keys()))p.includes(g)||o.delete(g)},$=e.locations.flatMap(o=>o.current.tabs.filter(p=>!o.baseline.tabs.some(g=>g.id===p.id)).map(vs));x(a.commandDefinitions,[...e.plan.editedCommandIds,...$]),x(a.enableRules,e.plan.editedEnableRuleIds),x(a.displayRules,e.plan.editedDisplayRuleIds);const u=await rs(e.entity?.logicalName??null),D=ks(u),C=e.plan.deletedButtonIds.filter(o=>!D.has(o));if(C.length>0)throw new Error(`Can't delete ${C.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 f=Ds(u),v=i.deletedContainerIds.filter(o=>!f.has(o));if(v.length>0)throw new Error(`Can't delete ${v.join(", ")}: not added by this table's unmanaged customizations (it comes from a managed solution or the platform). Undo the delete.`);const V=i.movedButtons.filter(o=>!D.has(o.id)).map(o=>o.id);if(V.length>0)throw new Error(`Can't move ${V.join(", ")}: not defined in this table's unmanaged customizations. Undo the move.`);const F=Ps(u),Z=(e.plan.uncustomisedCommandIds??[]).filter(o=>u.commandDefinitions.has(o)&&!$s(o,F));if(Z.length>0)throw new Error(`Can't uncustomise ${Z.join(", ")}: it is your own command (your customizations' buttons use it and no other solution defines it), so removing it would leave those buttons without a command. Undo the uncustomise.`);const M=new Set;for(const o of e.locations)for(const p of o.current.tabs)for(const g of p.groups)for(const I of ge(g))for(const T of Ns(I))M.add(T);const y=e.plan.uncustomisedCommandIds??[],E=new Set,H=new Set;for(const o of e.commands)if(!(!M.has(o.id)||y.includes(o.id))){o.enableRules.forEach(p=>E.add(p)),o.displayRules.forEach(p=>H.add(p));for(const p of o.rawRuleRefs??[]){const g=/^\s*<(EnableRule|DisplayRule)\b[^>]*?\sId="([^"]+)"/.exec(p.xml);g&&(g[1]==="EnableRule"?E:H).add(g[2])}}let h=As(u,a,{retainedCommandIds:M,editedCommandIds:e.plan.editedCommandIds,editedEnableRuleIds:e.plan.editedEnableRuleIds,editedDisplayRuleIds:e.plan.editedDisplayRuleIds,deletedControlIds:e.plan.deletedButtonIds,unhiddenControlIds:e.plan.unhiddenButtonIds,deletedContainerIds:i.deletedContainerIds,movedControls:i.movedButtons,removedTabCommands:r,uncustomisedCommandIds:y,retainedEnableRuleIds:E,retainedDisplayRuleIds:H});for(const o of e.plan.renamedLabels??[])o.newLabel&&(h=Ls(h,o.containerId,`$LocLabels:${o.id}`));const w=new Set([...Ge(u),...Ge(h)].map(o=>o.id)),K={};for(const o of e.locations)for(const[p,g]of Object.entries(o.baseline.scalingByTab??{}))K[p]={maxSizes:g.maxSizes.filter(I=>!w.has(I.id)).map(I=>I.sequence),scales:g.scales.filter(I=>!w.has(I.id)).map(I=>I.sequence)};const q=Es(h,K);if(q.problems.length>0)throw new Error(`Not published: ${q.problems.join("; ")}.`);return h=q.parts,{scalingChanges:q.changes,xml:zs(h),parts:h,elementCount:ve(h),preservedCount:ve(u),changedCount:ve(a),changedKeys:Ts(u,h),newKeys:Object.keys(h).flatMap(o=>Array.from(h[o].keys()).filter(p=>!u[o].has(p)).map(p=>`${o}:${p}`)),layerDefinitionIds:{commandIds:Array.from(u.commandDefinitions.keys()),enableRuleIds:Array.from(u.enableRules.keys()),displayRuleIds:Array.from(u.displayRules.keys())}}}function us(e,t){const i=[],d={},c={},a={},r={},b=new Set,m=new Set,R=new Set;for(const{current:u,baseline:D}of e.locations)for(const C of[D,u])for(const f of C.tabs)for(const v of f.groups)for(const V of ge(v))for(const F of V.menu?.sections??[])R.add(F.controlsId);for(const{current:u,baseline:D}of e.locations){Object.assign(a,D.templateLayouts);for(const C of D.tabs){i.push(C.id),C.label&&(r[C.id]={Title:C.label});for(const f of C.groups){b.add(f.id),i.push(f.id),f.label&&(r[f.id]={Title:f.label,Label:f.label});for(const v of ge(f))i.push(v.id),v.source&&(r[v.id]=v.source.attributes)}}for(const C of u.tabs)for(const f of C.groups)m.add(f.id);for(const C of[D,u])for(const f of C.tabs)for(const v of f.groups)v.template&&(c[v.id]=v.template)}const x=u=>b.has(u.groupId)&&!m.has(u.groupId);for(const{baseline:u}of e.locations)for(const[D,C]of Object.entries(u.scalingByTab??{}))d[D]={...C,maxSizes:C.maxSizes.filter(f=>!x(f)),scales:C.scales.filter(f=>!x(f))};const $=(u,D)=>{if(!u)return;const C=new Set(D??[]);return u.map(f=>f.id).filter(f=>!C.has(f))};return{changedKeys:t.changedKeys,newKeys:t.newKeys,commands:e.commands,known:{commandIds:$(e.baselineCommands,t.layerDefinitionIds?.commandIds),enableRuleIds:$(e.baselineEnableRules,t.layerDefinitionIds?.enableRuleIds),displayRuleIds:$(e.baselineDisplayRules,t.layerDefinitionIds?.displayRuleIds),elementIds:i},loadedAttributes:r,publisherPrefix:e.publisherPrefix,tabScaling:d,groupTemplates:c,templateLayouts:a,menuControlsIds:R,...e.entity?{places:{entityLogicalName:e.entity.logicalName,tabByCollection:Object.fromEntries(Xs(e.locations.map(u=>u.baseline),e.entity.logicalName))}}:{}}}function mn(e,t){return new Promise((i,d)=>{const c=setTimeout(()=>d(new Error(`it didn't finish within ${Math.round(t/1e3)} s`)),t);e.then(a=>{clearTimeout(c),i(a)},a=>{clearTimeout(c),d(a)})})}async function is(e,t={}){const i=await ds(e),d=us(e,i),c=[],a=qs(i.parts);if(t.lookupWebResources&&a.length>0)try{d.webResources=await t.lookupWebResources(a)}catch(r){c.push({severity:"warning",code:"webresource-lookup",message:`Couldn't check the ${a.length} referenced web resource(s): ${r instanceof Error?r.message:String(r)}`})}return{findings:[...cs(i.parts,d),...c],xml:i.xml}}async function hn(e,t,i={}){const d=i.attempts??3,c=i.contentKeys??[];let a={missing:[],unexpected:[],differing:[]};for(let b=0;b<d;b++){b>0&&await new Promise(m=>setTimeout(m,i.delayMs??5e3));try{a=Vs(t,await rs(e),{contentKeys:c})}catch(m){return{ok:!1,missing:[],unexpected:[],differing:[],message:`Couldn't read the published ribbon layer to verify it (${m instanceof Error?m.message:String(m)}).`}}if(a.missing.length===0&&a.unexpected.length===0&&a.differing.length===0){const m=c.length;return{ok:!0,...a,message:"Verified: the published ribbon layer has every element that was imported"+(m>0?`, and the ${m} element(s) this publish changed have the imported content.`:".")}}}const r=b=>b.slice(0,5).join(", ")+(b.length>5?", …":"");return{ok:!1,...a,message:"The published ribbon layer doesn't match what was imported"+(a.missing.length?`; missing: ${r(a.missing)}`:"")+(a.unexpected.length?`; unexpected: ${r(a.unexpected)}`:"")+(a.differing.length?`; different content: ${r(a.differing)}`:"")+". Reload the table and check before publishing again."}}function as(e,t){return Le(()=>pn(e,t))}async function pn(e,t){const i=Ae.getState(),d=e.entity?e.entity.logicalName:"Application ribbon",c={onProgress:t,...e.busy};t?.(`Reading existing ribbon customizations for ${d}…`),i.logInfo("publish",`Reading unmanaged ribbon layer for ${d}.`);const a=e.languageCode??await Ms(),r=await ds({...e,languageCode:a});i.logInfo("publish",`RibbonDiffXml for ${d}: ${r.preservedCount} existing element(s) preserved, ${r.changedCount} element(s) from this session, ${r.elementCount} total.`);for(const y of r.scalingChanges)i.logWarn("publish",Os(y));const b=cs(r.parts,us({...e,publisherPrefix:e.solution.publisherPrefix},r));for(const y of b)y.severity==="warning"&&i.logWarn("publish",y.message);const m=b.filter(y=>y.severity==="error");if(m.length>0){for(const y of m)i.logError("publish",y.message);throw new Error(`The pre-publish check found ${m.length} error(s), so nothing was imported: `+m.map(y=>y.message).join("; "))}const R=e.entity===null;if(R&&!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 x=e.entity?.schemaName||e.entity?.logicalName||"",$=R?Je({applicationRibbonDiffXml:r.xml}):Je({entities:[{schemaName:x,localizedName:e.entity?.displayName||x,ribbonDiffXml:r.xml}]}),u=R?[{type:50,schemaName:":RibbonDiffXml",behavior:0}]:[{type:1,schemaName:e.entity.logicalName,behavior:2}],D=gn({...e.solution,languageCode:a,rootComponents:u});t?.("Packaging solution ZIP…");const C=Us({"customizations.xml":ke($),"solution.xml":ke(D),"[Content_Types].xml":ke('<?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 f="";for(let y=0;y<C.length;y++)f+=String.fromCharCode(C[y]);const v=btoa(f),V=async y=>{t?.(`Importing ${d} ribbon${y}…`);const E=crypto.randomUUID();i.logInfo("publish",`Importing solution${y} (import job ${E})…`),await Ye("Import",()=>cn(v,E),c);const H=150,h=2e3;let w=await Y.getImportJobStatus(E),K=0;for(;!os(w)&&K<H;)await new Promise(p=>setTimeout(p,h)),w=await Y.getImportJobStatus(E),K++,K%10===0&&t?.(`Still importing… (${K*2}s elapsed)`);if(!os(w))throw new Error(`Solution import did not complete within ${H*h/1e3} seconds. Check Solutions › History for import job ${E}.`);t?.("Verifying the import…");const q=await Y.retrieve("importjob",E,["data"]),o=rn(q.data,R?{kind:"application"}:{kind:"entity",names:[x,e.entity.logicalName]});if(!o.ok)throw i.logError("publish",o.message),new Error(o.message);return i.logInfo("publish",o.message),E},F=async()=>{t?.("Publishing customizations…"),await Ye("Publish",async()=>{R?await Y.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:"<importexportxml><ribbons><ribbon></ribbon></ribbons></importexportxml>"}}):await dn([e.entity.logicalName])},c)};t?.("Checking that no other solution operation is running…"),await Bs(c);const Z=await V("");let M;if(e.publishCustomizations!==!1){await F();{i.logInfo("publish","Refreshing Unified Interface command-bar metadata (second import of the same package)…");try{await V(" (refreshing Unified Interface metadata)"),await F()}catch(y){throw new Error(`Your changes were imported and published, but refreshing Unified Interface's command-bar metadata failed (${y instanceof Error?y.message:String(y)}). New or changed buttons may not appear in the app until you publish again.`)}}t?.("Verifying the published ribbon…"),M=await hn(e.entity?.logicalName??null,r.parts,{delayMs:e.verifyDelayMs,contentKeys:r.changedKeys}),M.ok?i.logInfo("publish",M.message):i.logWarn("publish",M.message)}else i.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?`${d} ribbon published.`:`${d} ribbon imported (not published).`),{elementCount:r.elementCount,preservedCount:r.preservedCount,importJobId:Z,verification:M,parts:r.parts,changedKeys:r.changedKeys}}function bn(e,t){return Le(()=>fn(e,t))}async function fn(e,t){const i=Ae.getState(),d=2e3,c=600*1e3;e?.("Starting asynchronous publish (PublishAllXmlAsync)..."),i.logInfo("publish","Calling PublishAllXmlAsync action.");const r=(await Y.execute({operationName:"PublishAllXmlAsync",operationType:"action"}))?.AsyncOperationId;if(!r)throw new Error("PublishAllXmlAsync did not return AsyncOperationId.");i.logInfo("publish",`PublishAllXmlAsync job id: ${r}`),e?.("Async publish job started. Waiting for completion...");const b=Date.now();let m=0,R;for(;Date.now()-b<c;){m+=1;const x=await Y.retrieve("asyncoperation",r,["asyncoperationid","statecode","statuscode","name","message","friendlymessage","completedon"]);if(R=x.statuscode,x.statecode===3||!!x.completedon){if(typeof x.statuscode=="number"&&x.statuscode!==30){const u=x.friendlymessage||x.message||`statuscode=${x.statuscode}`;throw new Error(`Asynchronous publish failed: ${u}`)}return e?.("Asynchronous publish completed successfully."),i.logInfo("publish",`PublishAllXmlAsync completed in ${m} poll(s).`),{asyncOperationId:r,statusCode:x.statuscode}}e?.(`Waiting for async publish job... (poll ${m})`),await new Promise(u=>setTimeout(u,d))}throw new Error(`Asynchronous publish timed out after ${Math.round(c/1e3)} seconds (last status: ${R??"unknown"}).`)}function gn(e){const t=e.publisherUniqueName?.trim()||"DefaultPublisher",i=e.publisherName?.trim()||t,d=e.publisherPrefix?.trim()||"new",c=e.languageCode||1033,a=e.friendlyName?.trim()||e.uniqueName,r=e.rootComponents.length===0?"<RootComponents/>":`<RootComponents>
|
|
2
2
|
${e.rootComponents.map(b=>{const m=[`type="${b.type}"`];return b.schemaName&&m.push(`schemaName="${B(b.schemaName)}"`),b.id&&m.push(`id="{${B(b.id)}}"`),m.push(`behavior="${b.behavior}"`),`<RootComponent ${m.join(" ")} />`}).join(`
|
|
3
3
|
`)}
|
|
4
4
|
</RootComponents>`;return`<?xml version="1.0" encoding="utf-8"?>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e,h as R,y as Ae,cq as de}from"./fluent-icons-DxKNRZ1A.js";import{a as m}from"./monaco-Bx8A1Vm1.js";import{a as N,u as x,i as Pe,d as Be,e as We,C as $e,w as Le,f as Te}from"./index-Bu7BlRFk.js";import{C as ue}from"./CrmParameterEditor-BdmP65mF.js";import{M as Oe}from"./MonacoEditor-Bbg9u2FW.js";import{a as Ve,b as He,s as Ue}from"./webResourceService-CvyHBu7T.js";import{ah as _e,ai as Xe,aj as Je,T as d,t as n,B as u,ak as qe,ac as Ye,ad as S,a7 as _,F as j,S as X,c as E,M as y,e as C,I as B}from"./fluent-ui-D7EtYwEg.js";import"./dnd-fsSwRnQv.js";import"./crmParameters-rgfZhhzN.js";const Ge=Ae({drawer:{width:"640px",maxWidth:"90vw"},body:{display:"flex",flexDirection:"column",gap:n.spacingVerticalS,padding:n.spacingVerticalM,overflowY:"auto"},actionCard:{border:`1px solid ${n.colorNeutralStroke2}`,borderRadius:n.borderRadiusMedium,padding:n.spacingVerticalM,display:"flex",flexDirection:"column",gap:n.spacingVerticalS},actionHeader:{display:"flex",alignItems:"center",justifyContent:"space-between"},row:{display:"flex",gap:n.spacingHorizontalS,alignItems:"flex-end"},ruleRow:{display:"inline-flex",alignItems:"center",gap:n.spacingHorizontalXS},ruleRemoveBtn:{minWidth:"20px",width:"20px",height:"20px"},ruleChip:{cursor:"pointer"},rulePills:{display:"flex",flexWrap:"wrap",gap:n.spacingHorizontalXS},versionsList:{display:"flex",flexDirection:"column",gap:n.spacingVerticalXS},versionRow:{border:`1px solid ${n.colorNeutralStroke2}`,borderRadius:n.borderRadiusMedium,padding:n.spacingVerticalXS,display:"flex",justifyContent:"space-between",gap:n.spacingHorizontalS},versionMeta:{fontSize:n.fontSizeBase100,color:n.colorNeutralForeground3},securityNote:{fontSize:n.fontSizeBase100},readOnly:{border:"none",margin:0,padding:0,minWidth:0,display:"flex",flexDirection:"column",gap:n.spacingVerticalS},codePanel:{border:`1px solid ${n.colorNeutralStroke2}`,borderRadius:n.borderRadiusMedium,padding:n.spacingVerticalS,display:"flex",flexDirection:"column",gap:n.spacingVerticalS}}),is=()=>{const r=Ge(),W=N(s=>s.commandEditorOpen),z=N(s=>s.commandEditorId),M=N(s=>s.closeCommandEditor),me=N(s=>s.openCommandEditor),J=N(s=>s.openRuleEditor),pe=N(s=>s.openWebResourceBrowser),$=x(s=>s.commands),he=x(s=>s.upsertCommand),xe=x(s=>s.renameCommandId),q=x(s=>s.ribbons),Y=x(s=>s.displayRules),G=x(s=>s.enableRules),be=x(s=>s.past),je=x(s=>s.upsertEnableRule),fe=x(s=>s.upsertDisplayRule),[f,ge]=m.useState("actions"),[p,K]=m.useState(""),[ve,Q]=m.useState(""),[ye,Z]=m.useState(""),[ee,L]=m.useState(null),[I,se]=m.useState(!1),[ae,k]=m.useState(!1),[T,g]=m.useState(null),[ne,O]=m.useState(null),[re,F]=m.useState(""),[Ce,D]=m.useState(!1),[w,le]=m.useState(null),l=$.find(s=>s.id===z),we=Pe(Be(l?.id)),Re=s=>{const a=s.trim();return a.startsWith("$webresource:")?a.slice(13).trim():a},Ne=s=>{if(!s)return"";const a=Uint8Array.from(atob(s),o=>o.charCodeAt(0));return new TextDecoder().decode(a)},Se=s=>{const a=new TextEncoder().encode(s);let o="";for(let i=0;i<a.length;i+=1)o+=String.fromCharCode(a[i]);return btoa(o)},ze=s=>{const a=s.split(".").pop()?.toLowerCase()??"";return{html:1,css:2,js:3,xml:4,png:5,jpg:6,gif:7,xsl:9,ico:10,svg:11,resx:12}[a]??3};m.useEffect(()=>{l&&K(l.id)},[l]),m.useEffect(()=>{W&&z&&!l&&M()},[W,z,l,M]);const A=m.useMemo(()=>l?p.trim()?/\s/.test(p)?"Command ID cannot contain whitespace.":p!==l.id&&$.some(s=>s.id.toLowerCase()===p.toLowerCase())?"A command with this ID already exists.":"":"Command ID is required.":"",[p,l,$]),V=m.useMemo(()=>Object.entries(q).flatMap(([s,a])=>a.tabs.flatMap(o=>o.groups.flatMap(i=>We(i).filter(c=>c.commandId===z).map(c=>({location:s,tab:o,group:i,button:c}))))),[q,z]),ie=V.length;if(!l)return null;const oe=async(s,a)=>{const o=l.actions[s];if(!o||o.kind!=="javascript")return;const i=Re(o.library);if(!i){g("JavaScript library must be a valid $webresource path."),L(s),se(a),F(""),le(null);return}L(s),se(a),k(!0),g(null),O(null),D(!1),le(i);try{const c=await Ve(i);if(!c){F(""),g(`Web resource not found: ${i}`);return}const t=await He(c.id);F(Ne(t))}catch(c){g(c instanceof Error?c.message:"Failed to load web resource content."),F("")}finally{k(!1)}},Fe=async()=>{if(!(!I||ee===null||!w)){k(!0),g(null),O(null);try{const s=await Ue(w,Se(re),ze(w),{displayName:w.split("/").pop()});O(s.solutionWarning??null),D(!1)}catch(s){g(s instanceof Error?s.message:"Failed to save web resource content.")}finally{k(!1)}}},v=s=>{he({...l,...s})},b=(s,a)=>{const o=[...l.actions];o[s]=a,v({actions:o})},P=s=>{v({actions:l.actions.filter((a,o)=>o!==s)})},H=s=>{const a=s==="javascript"?{kind:"javascript",library:"",functionName:"",params:[]}:{kind:"url",address:"https://",params:[]};v({actions:[...l.actions,a]})},Ee=(s,a)=>{const o=ee===a;if(s.kind==="javascript")return e.jsxs("div",{className:r.actionCard,children:[e.jsxs("div",{className:r.actionHeader,children:[e.jsx(E,{appearance:"filled",color:"success",size:"small",children:"JavaScript"}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(R,{}),onClick:()=>P(a),"aria-label":"Remove action"})]}),e.jsx(j,{label:"Library (Web Resource)",children:e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsx(B,{style:{flex:1},value:s.library,onChange:(i,c)=>b(a,{...s,library:c.value.replace(/^(\s*\$webresource:\s*)+/i,"$webresource:")}),placeholder:"$webresource:publisher_/scripts/myfile.js"}),e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{Le.set(i=>{b(a,{...s,library:`$webresource:${i.name}`})}),pe()},children:"Browse…"})]})}),e.jsx(j,{label:"Function name",children:e.jsx(B,{value:s.functionName,onChange:(i,c)=>b(a,{...s,functionName:c.value}),placeholder:"MyNamespace.myFunction"})}),e.jsx(y,{intent:"info",children:e.jsx(C,{children:"Read-only function preview and Monaco editing are available in the web resource browser integration path."})}),e.jsx(_,{children:"Parameters (positional)"}),e.jsx(ue,{params:s.params,onChange:i=>b(a,{...s,params:i}),urlMode:!1}),e.jsxs("div",{className:r.row,children:[e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{oe(a,!1)},children:"Function preview"}),e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{oe(a,!0)},children:"Open in Monaco"})]}),o&&e.jsxs("div",{className:r.codePanel,children:[e.jsxs("div",{className:r.row,children:[e.jsx(d,{weight:"semibold",children:I?"Monaco Editor":"Function Preview"}),w&&e.jsx(d,{size:200,style:{fontFamily:n.fontFamilyMonospace},children:w})]}),T&&e.jsx(y,{intent:"error",children:e.jsx(C,{children:T})}),ne&&e.jsx(y,{intent:"warning",children:e.jsx(C,{children:ne})}),ae?e.jsx(d,{style:{color:n.colorNeutralForeground3},children:"Loading source…"}):e.jsx("div",{style:{height:240},children:e.jsx(Oe,{language:"javascript",value:re,readOnly:!I,onChange:i=>{F(i),D(!0)},options:{wordWrap:"on"}})}),e.jsxs("div",{className:r.row,children:[e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{L(null),g(null),D(!1)},children:"Close"}),I&&e.jsx(u,{appearance:"primary",size:"small",onClick:()=>{Fe()},disabled:!Ce||ae||!!T,children:"Save Web Resource"})]})]})]},a);if(s.kind==="url"){const i=s.address.trim().startsWith("https://");return e.jsxs("div",{className:r.actionCard,children:[e.jsxs("div",{className:r.actionHeader,children:[e.jsx(E,{appearance:"filled",color:"informative",size:"small",children:"URL"}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(R,{}),onClick:()=>P(a),"aria-label":"Remove action"})]}),e.jsx(y,{intent:"warning",children:e.jsx(C,{children:e.jsx(d,{className:r.securityNote,children:"⚠ Ampersands in URLs are automatically escaped as & in the generated XML."})})}),e.jsx(j,{label:"Address",validationState:i?"none":"error",validationMessage:i?void 0:"URL must start with https://",children:e.jsx(B,{value:s.address,onChange:(c,t)=>b(a,{...s,address:t.value}),placeholder:"https://..."})}),e.jsx(j,{label:"Open in (WinMode)",children:e.jsxs(X,{value:String(s.winMode??0),onChange:(c,t)=>b(a,{...s,winMode:parseInt(t.value)}),children:[e.jsx("option",{value:"0",children:"Navigate (0)"}),e.jsx("option",{value:"1",children:"Dialog (1)"}),e.jsx("option",{value:"2",children:"Popup (2)"})]})}),e.jsx(j,{children:e.jsxs(u,{appearance:s.passParams?"primary":"subtle",size:"small",onClick:()=>b(a,{...s,passParams:s.passParams?void 0:!0}),children:[s.passParams?"✓ PassParams ON":"PassParams OFF"," — appends typename, type, id, orgname…"]})}),e.jsx(_,{children:"Parameters (named)"}),e.jsx(ue,{params:s.params,onChange:c=>b(a,{...s,params:c}),urlMode:!0})]},a)}return s.kind==="powerFx"||s.kind==="customApi"?e.jsxs("div",{className:r.actionCard,children:[e.jsxs("div",{className:r.actionHeader,children:[e.jsxs(E,{appearance:"filled",color:"danger",size:"small",children:[s.kind==="powerFx"?"Power Fx":"Custom API"," — not supported"]}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(R,{}),onClick:()=>P(a),"aria-label":"Remove action"})]}),e.jsx(y,{intent:"error",children:e.jsxs(C,{children:["Classic ribbon commands can't run"," ",s.kind==="powerFx"?"Power Fx":"Custom API"," actions, so this command can't be published while it has one. Remove it and use a JavaScript function instead (for example, call the API with ",e.jsx("code",{children:"Xrm.WebApi.online.execute"}),"), or build the command with modern commanding in the app designer."]})})]},a):s.kind==="outlookCommand"||s.kind==="raw"?e.jsxs("div",{className:r.actionCard,children:[e.jsxs("div",{className:r.actionHeader,children:[e.jsx(E,{appearance:"outline",size:"small",children:s.kind==="outlookCommand"?"Outlook command":s.tagName}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(R,{}),onClick:()=>P(a),"aria-label":"Remove action"})]}),e.jsx(d,{size:200,style:{color:n.colorNeutralForeground3},children:s.kind==="outlookCommand"?`ActionType="${s.actionType}"${s.data?` Data="${s.data}"`:""}`:s.xml})]},a):null},Me=()=>e.jsxs(e.Fragment,{children:[l.actions.map((s,a)=>Ee(s,a)),l.actions.length===0&&e.jsx(d,{italic:!0,style:{color:n.colorNeutralForeground3},children:"No actions defined — button will do nothing when clicked."}),e.jsxs("div",{className:r.row,children:[e.jsx(j,{label:"Action type",style:{minWidth:"220px"},children:e.jsxs(X,{onChange:(s,a)=>{const o=a.value;o&&H(o)},value:"",children:[e.jsx("option",{value:"",children:"Add action..."}),e.jsx("option",{value:"javascript",children:"JavaScript function"}),e.jsx("option",{value:"url",children:"URL action"})]})}),e.jsx(u,{icon:e.jsx(de,{}),appearance:"secondary",size:"small",onClick:()=>H("javascript"),children:"Add JavaScript function"}),e.jsx(u,{icon:e.jsx(de,{}),appearance:"secondary",size:"small",onClick:()=>H("url"),children:"Add URL action"})]})]}),Ie=()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{label:"Command ID",children:e.jsx(B,{value:p,onChange:(s,a)=>K(a.value),style:{fontFamily:n.fontFamilyMonospace}})}),A&&e.jsx(d,{style:{color:n.colorPaletteRedForeground1,fontSize:n.fontSizeBase100},children:A}),e.jsx(u,{appearance:"secondary",size:"small",disabled:!p.trim()||!!A||p===l.id,onClick:()=>{if(!p.trim()||A)return;const s=p.trim();xe(l.id,s)&&me(s)},children:"Apply ID change"}),e.jsx(d,{style:{color:n.colorNeutralForeground3,fontSize:n.fontSizeBase200},children:"Naming convention: Publisher.EntityName.ButtonName.Command"}),e.jsx(y,{intent:"warning",children:e.jsx(C,{children:e.jsxs(d,{className:r.securityNote,children:["⚠ ",e.jsx("strong",{children:"Security:"})," All command definitions are visible in browser source regardless of button visibility. Do not embed sensitive logic, credentials, or privileged information in command parameters or function names."]})})})]}),te=s=>{const a=s==="enable"?l.enableRules:l.displayRules,o=(s==="enable"?G:Y).map(t=>t.id).filter(t=>!a.includes(t)),i=s==="enable"?ve:ye,c=()=>{const t=new Set([...G.map(U=>U.id),...Y.map(U=>U.id)]),h=Te("New",s==="enable"?"Enable":"Display",t);s==="enable"?je({id:h,steps:[]}):fe({id:h,steps:[]}),J(h,s)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:r.rulePills,children:[a.map(t=>e.jsxs("div",{className:r.ruleRow,children:[e.jsx(E,{appearance:"outline",size:"medium",className:r.ruleChip,onClick:()=>J(t,s),role:"button",tabIndex:0,children:t}),e.jsx(u,{appearance:"subtle",size:"small",className:r.ruleRemoveBtn,icon:e.jsx(R,{}),"aria-label":`Unbind ${t}`,onClick:()=>{v(s==="enable"?{enableRules:l.enableRules.filter(h=>h!==t)}:{displayRules:l.displayRules.filter(h=>h!==t)})}})]},t)),a.length===0&&e.jsxs(d,{italic:!0,style:{color:n.colorNeutralForeground3},children:["No ",s," rules — always ",s==="enable"?"enabled":"visible","."]})]}),e.jsxs("div",{className:r.row,children:[e.jsx(j,{label:`Bind existing ${s} rule`,style:{minWidth:"260px"},children:e.jsxs(X,{value:i,onChange:(t,h)=>s==="enable"?Q(h.value):Z(h.value),children:[e.jsx("option",{value:"",children:"Select a rule…"}),o.map(t=>e.jsx("option",{value:t,children:t},t))]})}),e.jsx(u,{appearance:"secondary",size:"small",disabled:!i,onClick:()=>{i&&(s==="enable"?(v({enableRules:[...l.enableRules,i]}),Q("")):(v({displayRules:[...l.displayRules,i]}),Z("")))},children:"Bind selected"}),e.jsxs(u,{appearance:"subtle",size:"small",onClick:c,children:["Create new ",s," rule"]})]}),s==="enable"&&e.jsx(y,{intent:"info",children:e.jsxs(C,{children:["Disabled buttons are ",e.jsx("strong",{children:"hidden"})," in the modern command bar (Unified Interface). In the classic ribbon, disabled buttons remain visible but do not respond to clicks."]})})]})},ke=()=>e.jsxs(e.Fragment,{children:[e.jsxs(d,{children:["Referenced by ",e.jsx("strong",{children:ie})," button(s)."]}),V.length>0&&e.jsx("div",{className:r.versionsList,children:V.map(s=>e.jsx("div",{className:r.versionRow,children:e.jsxs("div",{children:[e.jsx(d,{weight:"semibold",style:{fontFamily:n.fontFamilyMonospace},children:s.button.id}),e.jsxs(d,{className:r.versionMeta,children:[s.location," → ",s.tab.label," → ",s.group.label]})]})},`${s.location}:${s.tab.id}:${s.group.id}:${s.button.id}`))})]}),ce=be.filter(s=>s.target===l.id||s.detail.includes(l.id)).slice().reverse(),De=()=>e.jsx(e.Fragment,{children:ce.length===0?e.jsx(d,{style:{color:n.colorNeutralForeground3},children:"No command-specific history entries yet."}):e.jsx("div",{className:r.versionsList,children:ce.map((s,a)=>e.jsxs("div",{className:r.versionRow,children:[e.jsxs("div",{children:[e.jsx(d,{weight:"semibold",children:s.op}),e.jsx(d,{className:r.versionMeta,children:s.detail})]}),e.jsx(d,{className:r.versionMeta,children:new Date(s.ts).toLocaleString()})]},`${s.ts}-${a}`))})});return e.jsxs(_e,{position:"end",open:W,onOpenChange:()=>M(),className:r.drawer,children:[e.jsx(Xe,{children:e.jsx(Je,{action:e.jsx(u,{appearance:"subtle",icon:e.jsx(R,{}),onClick:M,"aria-label":"Close command editor"}),children:e.jsx(d,{size:400,weight:"semibold",style:{fontFamily:n.fontFamilyMonospace},children:l.id})})}),e.jsxs(qe,{className:r.body,children:[e.jsxs(Ye,{selectedValue:f,onTabSelect:(s,a)=>ge(a.value),children:[e.jsx(S,{value:"actions",children:"Actions"}),e.jsx(S,{value:"enableRules",children:"Enable rules"}),e.jsx(S,{value:"displayRules",children:"Display rules"}),e.jsx(S,{value:"settings",children:"Settings"}),e.jsxs(S,{value:"references",children:["References (",ie,")"]}),e.jsx(S,{value:"versions",children:"Versions"})]}),e.jsx(_,{}),e.jsx($e,{commandId:l.id}),e.jsxs("fieldset",{disabled:we,className:r.readOnly,children:[f==="actions"&&Me(),f==="enableRules"&&te("enable"),f==="displayRules"&&te("display"),f==="settings"&&Ie()]}),f==="references"&&ke(),f==="versions"&&De()]})]})};export{is as CommandEditorPanel,is as default};
|
|
1
|
+
import{z as e,h as R,y as Ae,cq as de}from"./fluent-icons-4bzebHz-.js";import{a as m}from"./monaco-BoSoLy50.js";import{a as N,u as x,i as Pe,d as Be,e as We,C as $e,w as Le,f as Te}from"./index-B2t4gwW0.js";import{C as ue}from"./CrmParameterEditor-B84bdjcT.js";import{M as Oe}from"./MonacoEditor-DakCq511.js";import{a as Ve,b as He,s as Ue}from"./webResourceService-DGt6sRPR.js";import{ah as _e,ai as Xe,aj as Je,T as d,t as n,B as u,ak as qe,ac as Ye,ad as S,a7 as _,F as j,S as X,c as E,M as y,e as C,I as B}from"./fluent-ui-lAhdF0Ck.js";import"./dnd-vmvAsOrM.js";import"./crmParameters-rgfZhhzN.js";const Ge=Ae({drawer:{width:"640px",maxWidth:"90vw"},body:{display:"flex",flexDirection:"column",gap:n.spacingVerticalS,padding:n.spacingVerticalM,overflowY:"auto"},actionCard:{border:`1px solid ${n.colorNeutralStroke2}`,borderRadius:n.borderRadiusMedium,padding:n.spacingVerticalM,display:"flex",flexDirection:"column",gap:n.spacingVerticalS},actionHeader:{display:"flex",alignItems:"center",justifyContent:"space-between"},row:{display:"flex",gap:n.spacingHorizontalS,alignItems:"flex-end"},ruleRow:{display:"inline-flex",alignItems:"center",gap:n.spacingHorizontalXS},ruleRemoveBtn:{minWidth:"20px",width:"20px",height:"20px"},ruleChip:{cursor:"pointer"},rulePills:{display:"flex",flexWrap:"wrap",gap:n.spacingHorizontalXS},versionsList:{display:"flex",flexDirection:"column",gap:n.spacingVerticalXS},versionRow:{border:`1px solid ${n.colorNeutralStroke2}`,borderRadius:n.borderRadiusMedium,padding:n.spacingVerticalXS,display:"flex",justifyContent:"space-between",gap:n.spacingHorizontalS},versionMeta:{fontSize:n.fontSizeBase100,color:n.colorNeutralForeground3},securityNote:{fontSize:n.fontSizeBase100},readOnly:{border:"none",margin:0,padding:0,minWidth:0,display:"flex",flexDirection:"column",gap:n.spacingVerticalS},codePanel:{border:`1px solid ${n.colorNeutralStroke2}`,borderRadius:n.borderRadiusMedium,padding:n.spacingVerticalS,display:"flex",flexDirection:"column",gap:n.spacingVerticalS}}),is=()=>{const r=Ge(),W=N(s=>s.commandEditorOpen),z=N(s=>s.commandEditorId),M=N(s=>s.closeCommandEditor),me=N(s=>s.openCommandEditor),J=N(s=>s.openRuleEditor),pe=N(s=>s.openWebResourceBrowser),$=x(s=>s.commands),he=x(s=>s.upsertCommand),xe=x(s=>s.renameCommandId),q=x(s=>s.ribbons),Y=x(s=>s.displayRules),G=x(s=>s.enableRules),be=x(s=>s.past),je=x(s=>s.upsertEnableRule),fe=x(s=>s.upsertDisplayRule),[f,ge]=m.useState("actions"),[p,K]=m.useState(""),[ve,Q]=m.useState(""),[ye,Z]=m.useState(""),[ee,L]=m.useState(null),[I,se]=m.useState(!1),[ae,k]=m.useState(!1),[T,g]=m.useState(null),[ne,O]=m.useState(null),[re,F]=m.useState(""),[Ce,D]=m.useState(!1),[w,le]=m.useState(null),l=$.find(s=>s.id===z),we=Pe(Be(l?.id)),Re=s=>{const a=s.trim();return a.startsWith("$webresource:")?a.slice(13).trim():a},Ne=s=>{if(!s)return"";const a=Uint8Array.from(atob(s),o=>o.charCodeAt(0));return new TextDecoder().decode(a)},Se=s=>{const a=new TextEncoder().encode(s);let o="";for(let i=0;i<a.length;i+=1)o+=String.fromCharCode(a[i]);return btoa(o)},ze=s=>{const a=s.split(".").pop()?.toLowerCase()??"";return{html:1,css:2,js:3,xml:4,png:5,jpg:6,gif:7,xsl:9,ico:10,svg:11,resx:12}[a]??3};m.useEffect(()=>{l&&K(l.id)},[l]),m.useEffect(()=>{W&&z&&!l&&M()},[W,z,l,M]);const A=m.useMemo(()=>l?p.trim()?/\s/.test(p)?"Command ID cannot contain whitespace.":p!==l.id&&$.some(s=>s.id.toLowerCase()===p.toLowerCase())?"A command with this ID already exists.":"":"Command ID is required.":"",[p,l,$]),V=m.useMemo(()=>Object.entries(q).flatMap(([s,a])=>a.tabs.flatMap(o=>o.groups.flatMap(i=>We(i).filter(c=>c.commandId===z).map(c=>({location:s,tab:o,group:i,button:c}))))),[q,z]),ie=V.length;if(!l)return null;const oe=async(s,a)=>{const o=l.actions[s];if(!o||o.kind!=="javascript")return;const i=Re(o.library);if(!i){g("JavaScript library must be a valid $webresource path."),L(s),se(a),F(""),le(null);return}L(s),se(a),k(!0),g(null),O(null),D(!1),le(i);try{const c=await Ve(i);if(!c){F(""),g(`Web resource not found: ${i}`);return}const t=await He(c.id);F(Ne(t))}catch(c){g(c instanceof Error?c.message:"Failed to load web resource content."),F("")}finally{k(!1)}},Fe=async()=>{if(!(!I||ee===null||!w)){k(!0),g(null),O(null);try{const s=await Ue(w,Se(re),ze(w),{displayName:w.split("/").pop()});O(s.solutionWarning??null),D(!1)}catch(s){g(s instanceof Error?s.message:"Failed to save web resource content.")}finally{k(!1)}}},v=s=>{he({...l,...s})},b=(s,a)=>{const o=[...l.actions];o[s]=a,v({actions:o})},P=s=>{v({actions:l.actions.filter((a,o)=>o!==s)})},H=s=>{const a=s==="javascript"?{kind:"javascript",library:"",functionName:"",params:[]}:{kind:"url",address:"https://",params:[]};v({actions:[...l.actions,a]})},Ee=(s,a)=>{const o=ee===a;if(s.kind==="javascript")return e.jsxs("div",{className:r.actionCard,children:[e.jsxs("div",{className:r.actionHeader,children:[e.jsx(E,{appearance:"filled",color:"success",size:"small",children:"JavaScript"}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(R,{}),onClick:()=>P(a),"aria-label":"Remove action"})]}),e.jsx(j,{label:"Library (Web Resource)",children:e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsx(B,{style:{flex:1},value:s.library,onChange:(i,c)=>b(a,{...s,library:c.value.replace(/^(\s*\$webresource:\s*)+/i,"$webresource:")}),placeholder:"$webresource:publisher_/scripts/myfile.js"}),e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{Le.set(i=>{b(a,{...s,library:`$webresource:${i.name}`})}),pe()},children:"Browse…"})]})}),e.jsx(j,{label:"Function name",children:e.jsx(B,{value:s.functionName,onChange:(i,c)=>b(a,{...s,functionName:c.value}),placeholder:"MyNamespace.myFunction"})}),e.jsx(y,{intent:"info",children:e.jsx(C,{children:"Read-only function preview and Monaco editing are available in the web resource browser integration path."})}),e.jsx(_,{children:"Parameters (positional)"}),e.jsx(ue,{params:s.params,onChange:i=>b(a,{...s,params:i}),urlMode:!1}),e.jsxs("div",{className:r.row,children:[e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{oe(a,!1)},children:"Function preview"}),e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{oe(a,!0)},children:"Open in Monaco"})]}),o&&e.jsxs("div",{className:r.codePanel,children:[e.jsxs("div",{className:r.row,children:[e.jsx(d,{weight:"semibold",children:I?"Monaco Editor":"Function Preview"}),w&&e.jsx(d,{size:200,style:{fontFamily:n.fontFamilyMonospace},children:w})]}),T&&e.jsx(y,{intent:"error",children:e.jsx(C,{children:T})}),ne&&e.jsx(y,{intent:"warning",children:e.jsx(C,{children:ne})}),ae?e.jsx(d,{style:{color:n.colorNeutralForeground3},children:"Loading source…"}):e.jsx("div",{style:{height:240},children:e.jsx(Oe,{language:"javascript",value:re,readOnly:!I,onChange:i=>{F(i),D(!0)},options:{wordWrap:"on"}})}),e.jsxs("div",{className:r.row,children:[e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{L(null),g(null),D(!1)},children:"Close"}),I&&e.jsx(u,{appearance:"primary",size:"small",onClick:()=>{Fe()},disabled:!Ce||ae||!!T,children:"Save Web Resource"})]})]})]},a);if(s.kind==="url"){const i=s.address.trim().startsWith("https://");return e.jsxs("div",{className:r.actionCard,children:[e.jsxs("div",{className:r.actionHeader,children:[e.jsx(E,{appearance:"filled",color:"informative",size:"small",children:"URL"}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(R,{}),onClick:()=>P(a),"aria-label":"Remove action"})]}),e.jsx(y,{intent:"warning",children:e.jsx(C,{children:e.jsx(d,{className:r.securityNote,children:"⚠ Ampersands in URLs are automatically escaped as & in the generated XML."})})}),e.jsx(j,{label:"Address",validationState:i?"none":"error",validationMessage:i?void 0:"URL must start with https://",children:e.jsx(B,{value:s.address,onChange:(c,t)=>b(a,{...s,address:t.value}),placeholder:"https://..."})}),e.jsx(j,{label:"Open in (WinMode)",children:e.jsxs(X,{value:String(s.winMode??0),onChange:(c,t)=>b(a,{...s,winMode:parseInt(t.value)}),children:[e.jsx("option",{value:"0",children:"Navigate (0)"}),e.jsx("option",{value:"1",children:"Dialog (1)"}),e.jsx("option",{value:"2",children:"Popup (2)"})]})}),e.jsx(j,{children:e.jsxs(u,{appearance:s.passParams?"primary":"subtle",size:"small",onClick:()=>b(a,{...s,passParams:s.passParams?void 0:!0}),children:[s.passParams?"✓ PassParams ON":"PassParams OFF"," — appends typename, type, id, orgname…"]})}),e.jsx(_,{children:"Parameters (named)"}),e.jsx(ue,{params:s.params,onChange:c=>b(a,{...s,params:c}),urlMode:!0})]},a)}return s.kind==="powerFx"||s.kind==="customApi"?e.jsxs("div",{className:r.actionCard,children:[e.jsxs("div",{className:r.actionHeader,children:[e.jsxs(E,{appearance:"filled",color:"danger",size:"small",children:[s.kind==="powerFx"?"Power Fx":"Custom API"," — not supported"]}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(R,{}),onClick:()=>P(a),"aria-label":"Remove action"})]}),e.jsx(y,{intent:"error",children:e.jsxs(C,{children:["Classic ribbon commands can't run"," ",s.kind==="powerFx"?"Power Fx":"Custom API"," actions, so this command can't be published while it has one. Remove it and use a JavaScript function instead (for example, call the API with ",e.jsx("code",{children:"Xrm.WebApi.online.execute"}),"), or build the command with modern commanding in the app designer."]})})]},a):s.kind==="outlookCommand"||s.kind==="raw"?e.jsxs("div",{className:r.actionCard,children:[e.jsxs("div",{className:r.actionHeader,children:[e.jsx(E,{appearance:"outline",size:"small",children:s.kind==="outlookCommand"?"Outlook command":s.tagName}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(R,{}),onClick:()=>P(a),"aria-label":"Remove action"})]}),e.jsx(d,{size:200,style:{color:n.colorNeutralForeground3},children:s.kind==="outlookCommand"?`ActionType="${s.actionType}"${s.data?` Data="${s.data}"`:""}`:s.xml})]},a):null},Me=()=>e.jsxs(e.Fragment,{children:[l.actions.map((s,a)=>Ee(s,a)),l.actions.length===0&&e.jsx(d,{italic:!0,style:{color:n.colorNeutralForeground3},children:"No actions defined — button will do nothing when clicked."}),e.jsxs("div",{className:r.row,children:[e.jsx(j,{label:"Action type",style:{minWidth:"220px"},children:e.jsxs(X,{onChange:(s,a)=>{const o=a.value;o&&H(o)},value:"",children:[e.jsx("option",{value:"",children:"Add action..."}),e.jsx("option",{value:"javascript",children:"JavaScript function"}),e.jsx("option",{value:"url",children:"URL action"})]})}),e.jsx(u,{icon:e.jsx(de,{}),appearance:"secondary",size:"small",onClick:()=>H("javascript"),children:"Add JavaScript function"}),e.jsx(u,{icon:e.jsx(de,{}),appearance:"secondary",size:"small",onClick:()=>H("url"),children:"Add URL action"})]})]}),Ie=()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{label:"Command ID",children:e.jsx(B,{value:p,onChange:(s,a)=>K(a.value),style:{fontFamily:n.fontFamilyMonospace}})}),A&&e.jsx(d,{style:{color:n.colorPaletteRedForeground1,fontSize:n.fontSizeBase100},children:A}),e.jsx(u,{appearance:"secondary",size:"small",disabled:!p.trim()||!!A||p===l.id,onClick:()=>{if(!p.trim()||A)return;const s=p.trim();xe(l.id,s)&&me(s)},children:"Apply ID change"}),e.jsx(d,{style:{color:n.colorNeutralForeground3,fontSize:n.fontSizeBase200},children:"Naming convention: Publisher.EntityName.ButtonName.Command"}),e.jsx(y,{intent:"warning",children:e.jsx(C,{children:e.jsxs(d,{className:r.securityNote,children:["⚠ ",e.jsx("strong",{children:"Security:"})," All command definitions are visible in browser source regardless of button visibility. Do not embed sensitive logic, credentials, or privileged information in command parameters or function names."]})})})]}),te=s=>{const a=s==="enable"?l.enableRules:l.displayRules,o=(s==="enable"?G:Y).map(t=>t.id).filter(t=>!a.includes(t)),i=s==="enable"?ve:ye,c=()=>{const t=new Set([...G.map(U=>U.id),...Y.map(U=>U.id)]),h=Te("New",s==="enable"?"Enable":"Display",t);s==="enable"?je({id:h,steps:[]}):fe({id:h,steps:[]}),J(h,s)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:r.rulePills,children:[a.map(t=>e.jsxs("div",{className:r.ruleRow,children:[e.jsx(E,{appearance:"outline",size:"medium",className:r.ruleChip,onClick:()=>J(t,s),role:"button",tabIndex:0,children:t}),e.jsx(u,{appearance:"subtle",size:"small",className:r.ruleRemoveBtn,icon:e.jsx(R,{}),"aria-label":`Unbind ${t}`,onClick:()=>{v(s==="enable"?{enableRules:l.enableRules.filter(h=>h!==t)}:{displayRules:l.displayRules.filter(h=>h!==t)})}})]},t)),a.length===0&&e.jsxs(d,{italic:!0,style:{color:n.colorNeutralForeground3},children:["No ",s," rules — always ",s==="enable"?"enabled":"visible","."]})]}),e.jsxs("div",{className:r.row,children:[e.jsx(j,{label:`Bind existing ${s} rule`,style:{minWidth:"260px"},children:e.jsxs(X,{value:i,onChange:(t,h)=>s==="enable"?Q(h.value):Z(h.value),children:[e.jsx("option",{value:"",children:"Select a rule…"}),o.map(t=>e.jsx("option",{value:t,children:t},t))]})}),e.jsx(u,{appearance:"secondary",size:"small",disabled:!i,onClick:()=>{i&&(s==="enable"?(v({enableRules:[...l.enableRules,i]}),Q("")):(v({displayRules:[...l.displayRules,i]}),Z("")))},children:"Bind selected"}),e.jsxs(u,{appearance:"subtle",size:"small",onClick:c,children:["Create new ",s," rule"]})]}),s==="enable"&&e.jsx(y,{intent:"info",children:e.jsxs(C,{children:["Disabled buttons are ",e.jsx("strong",{children:"hidden"})," in the modern command bar (Unified Interface). In the classic ribbon, disabled buttons remain visible but do not respond to clicks."]})})]})},ke=()=>e.jsxs(e.Fragment,{children:[e.jsxs(d,{children:["Referenced by ",e.jsx("strong",{children:ie})," button(s)."]}),V.length>0&&e.jsx("div",{className:r.versionsList,children:V.map(s=>e.jsx("div",{className:r.versionRow,children:e.jsxs("div",{children:[e.jsx(d,{weight:"semibold",style:{fontFamily:n.fontFamilyMonospace},children:s.button.id}),e.jsxs(d,{className:r.versionMeta,children:[s.location," → ",s.tab.label," → ",s.group.label]})]})},`${s.location}:${s.tab.id}:${s.group.id}:${s.button.id}`))})]}),ce=be.filter(s=>s.target===l.id||s.detail.includes(l.id)).slice().reverse(),De=()=>e.jsx(e.Fragment,{children:ce.length===0?e.jsx(d,{style:{color:n.colorNeutralForeground3},children:"No command-specific history entries yet."}):e.jsx("div",{className:r.versionsList,children:ce.map((s,a)=>e.jsxs("div",{className:r.versionRow,children:[e.jsxs("div",{children:[e.jsx(d,{weight:"semibold",children:s.op}),e.jsx(d,{className:r.versionMeta,children:s.detail})]}),e.jsx(d,{className:r.versionMeta,children:new Date(s.ts).toLocaleString()})]},`${s.ts}-${a}`))})});return e.jsxs(_e,{position:"end",open:W,onOpenChange:()=>M(),className:r.drawer,children:[e.jsx(Xe,{children:e.jsx(Je,{action:e.jsx(u,{appearance:"subtle",icon:e.jsx(R,{}),onClick:M,"aria-label":"Close command editor"}),children:e.jsx(d,{size:400,weight:"semibold",style:{fontFamily:n.fontFamilyMonospace},children:l.id})})}),e.jsxs(qe,{className:r.body,children:[e.jsxs(Ye,{selectedValue:f,onTabSelect:(s,a)=>ge(a.value),children:[e.jsx(S,{value:"actions",children:"Actions"}),e.jsx(S,{value:"enableRules",children:"Enable rules"}),e.jsx(S,{value:"displayRules",children:"Display rules"}),e.jsx(S,{value:"settings",children:"Settings"}),e.jsxs(S,{value:"references",children:["References (",ie,")"]}),e.jsx(S,{value:"versions",children:"Versions"})]}),e.jsx(_,{}),e.jsx($e,{commandId:l.id}),e.jsxs("fieldset",{disabled:we,className:r.readOnly,children:[f==="actions"&&Me(),f==="enableRules"&&te("enable"),f==="displayRules"&&te("display"),f==="settings"&&Ie()]}),f==="references"&&ke(),f==="versions"&&De()]})]})};export{is as CommandEditorPanel,is as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as a,E as te,y as oe}from"./fluent-icons-
|
|
1
|
+
import{z as a,E as te,y as oe}from"./fluent-icons-4bzebHz-.js";import{a as u}from"./monaco-BoSoLy50.js";import{a as s,u as c,b as ae,a7 as ne,X as h,a2 as se,a8 as ie,e as le}from"./index-B2t4gwW0.js";import{t,c as re,T as y}from"./fluent-ui-lAhdF0Ck.js";import"./dnd-vmvAsOrM.js";const ce=oe({backdrop:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.5)",zIndex:1e3,display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:"10vh"},palette:{width:"640px",maxWidth:"90vw",backgroundColor:t.colorNeutralBackground1,borderRadius:t.borderRadiusLarge,boxShadow:t.shadow64,overflow:"hidden"},searchRow:{display:"flex",alignItems:"center",padding:`${t.spacingVerticalM} ${t.spacingHorizontalM}`,borderBottom:`1px solid ${t.colorNeutralStroke1}`,gap:t.spacingHorizontalS},searchInput:{flex:1,border:"none",outline:"none",fontSize:t.fontSizeBase400,backgroundColor:"transparent"},results:{maxHeight:"400px",overflowY:"auto"},group:{paddingTop:t.spacingVerticalXS},groupLabel:{padding:`${t.spacingVerticalXXS} ${t.spacingHorizontalM}`,color:t.colorNeutralForeground3,fontSize:t.fontSizeBase100,fontWeight:t.fontWeightSemibold,textTransform:"uppercase",letterSpacing:"0.08em"},item:{display:"flex",alignItems:"center",gap:t.spacingHorizontalS,padding:`${t.spacingVerticalXS} ${t.spacingHorizontalM}`,cursor:"pointer","&:hover":{backgroundColor:t.colorNeutralBackground1Hover}},itemSelected:{backgroundColor:t.colorNeutralBackground1Hover},itemLabel:{flex:1},itemSub:{color:t.colorNeutralForeground3,fontSize:t.fontSizeBase200},footer:{padding:`${t.spacingVerticalXS} ${t.spacingHorizontalM}`,borderTop:`1px solid ${t.colorNeutralStroke1}`,color:t.colorNeutralForeground3,fontSize:t.fontSizeBase100,display:"flex",gap:t.spacingHorizontalL}}),he=()=>{const i=ce(),g=s(e=>e.commandPaletteOpen),N=s(e=>e.setCommandPaletteOpen),L=s(e=>e.openBulkPublish),X=s(e=>e.openXmlDrawer),f=s(e=>e.openImportXml),D=s(e=>e.openCommandEditor),C=s(e=>e.openRuleEditor),T=s(e=>e.openNewGroup),H=s(e=>e.openNewButton),O=s(e=>e.openLocalizationEditor),v=s(e=>e.themeMode),P=s(e=>e.setThemeMode),W=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),[l,j]=u.useState(""),[x,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(ie(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:()=>{X(),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||(O(p),n())}},{id:"toggle-theme",label:`Toggle theme (${v==="dark"?"Dark":"Light"})`,subtitle:"Switch between light and dark",kind:"action",action:()=>{P(v==="dark"?"light":"dark"),n()}},{id:"undo",label:"Undo",subtitle:"Ctrl+Z",kind:"action",action:()=>{W(),n()}},{id:"redo",label:"Redo",subtitle:"Ctrl+Shift+Z",kind:"action",action:()=>{G(),n()}}];if(e.push(..._),!l.startsWith("@")&&!l.startsWith("/")){const o=Object.entries($).flatMap(([m,ee])=>ee.tabs.flatMap(M=>M.groups.flatMap(B=>le(B).map(w=>({id:`btn-${w.id}`,label:w.label||w.id,subtitle:`${m} → ${M.label} → ${B.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:()=>{D(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()}})}),(l.startsWith("@")||!l)&&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},k=l.startsWith("@")||l.startsWith("/")?l.slice(1):l,E=Z(),b=k?E.filter(e=>e.label.toLowerCase().includes(k.toLowerCase())||(e.subtitle??"").toLowerCase().includes(k.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[x]?.action():e.key==="Escape"&&n()};return g?a.jsx("div",{className:i.backdrop,onClick:n,role:"presentation",children:a.jsxs("div",{className:i.palette,onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[a.jsxs("div",{className:i.searchRow,children:[a.jsx(te,{style:{color:t.colorNeutralForeground3,flexShrink:0}}),a.jsx("input",{ref:z,className:i.searchInput,value:l,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:i.results,role:"listbox",children:[b.map((e,r)=>a.jsxs("div",{className:`${i.item} ${r===x?i.itemSelected:""}`,onClick:e.action,role:"option","aria-selected":r===x,onMouseEnter:()=>d(r),children:[a.jsx(re,{appearance:"outline",size:"small",children:e.kind}),a.jsxs("div",{className:i.itemLabel,children:[a.jsx(y,{children:e.label}),e.subtitle&&a.jsx(y,{className:i.itemSub,block:!0,children:e.subtitle})]})]},e.id)),b.length===0&&a.jsx("div",{className:i.item,children:a.jsx(y,{style:{color:t.colorNeutralForeground3},children:"No results"})})]}),a.jsxs("div",{className:i.footer,children:[a.jsx("span",{children:"↑↓ navigate"}),a.jsx("span",{children:"↵ select"}),a.jsx("span",{children:"Esc close"}),a.jsx("span",{children:"@ entities"}),a.jsx("span",{children:"/ actions"})]})]})}):null};export{he as CommandPalette,he as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e,h as k,bM as C,b6 as D,y as M}from"./fluent-icons-
|
|
1
|
+
import{z as e,h as k,bM as C,b6 as D,y as M}from"./fluent-icons-4bzebHz-.js";import{a as c}from"./monaco-BoSoLy50.js";import{a as u,u as B}from"./index-B2t4gwW0.js";import{ah as I,ai as R,aj as H,aa as L,B as N,ak as E,T as a,t as o,M as h,e as x,a5 as F,c as z,m as O}from"./fluent-ui-lAhdF0Ck.js";import"./dnd-vmvAsOrM.js";function $(){return window.dataverseAPI}function P(i){const l=i.map(s=>{const r=s.publisherid,d=s.versionnumber,m=typeof d=="number"?d:Number(d??0)||0;return{solutionId:String(s.solutionid??""),solutionName:String(s.friendlyname??s.uniquename??"Unknown Solution"),publisher:String(r?.friendlyname??r?.customizationprefix??"Unknown Publisher"),managed:!!s.ismanaged,importedOn:s.modifiedon?String(s.modifiedon):void 0,wins:!1,versionNumber:m}});return l.sort((s,r)=>s.versionNumber-r.versionNumber),l.length>0&&(l[l.length-1].wins=!0),l.map(({versionNumber:s,...r})=>r)}async function A(i){if(!i)return null;const r=(await $().getSolutions(["solutionid","friendlyname","uniquename","ismanaged","publisherid","versionnumber","modifiedon"])).value;return r.length<=1?null:{elementId:i,elementKind:"button",solutions:P(r)}}const T=M({drawer:{width:"560px",maxWidth:"95vw"},body:{display:"flex",flexDirection:"column",gap:o.spacingHorizontalM,padding:o.spacingHorizontalM,overflowY:"auto"},solutionRow:{display:"flex",flexDirection:"column",gap:o.spacingHorizontalXS,padding:o.spacingHorizontalS,border:`1px solid ${o.colorNeutralStroke2}`,borderRadius:o.borderRadiusMedium,backgroundColor:o.colorNeutralBackground2},solutionRowWinner:{border:`2px solid ${o.colorBrandStroke1}`,backgroundColor:o.colorBrandBackground2},solutionHeader:{display:"flex",alignItems:"center",gap:o.spacingHorizontalS},elementId:{fontFamily:o.fontFamilyMonospace,fontSize:o.fontSizeBase200,backgroundColor:o.colorNeutralBackground4,padding:`2px ${o.spacingHorizontalXS}`,borderRadius:o.borderRadiusSmall,wordBreak:"break-all"}}),K=()=>{const i=T(),l=u(n=>n.conflictDrawerOpen),s=u(n=>n.conflictElementId),r=u(n=>n.closeConflictDrawer),d=u(n=>n.openXmlDrawer),m=B(n=>n.conflicts),[p,b]=c.useState(null),[j,f]=c.useState(!1),[v,g]=c.useState(null);c.useEffect(()=>{if(!l||!s){b(null),g(null),f(!1);return}let n=!1;return f(!0),g(null),A(s).then(t=>{n||b(t)}).catch(t=>{n||g(t instanceof Error?t.message:"Failed to load conflict layers")}).finally(()=>{n||f(!1)}),()=>{n=!0}},[l,s]);const w=m.filter(n=>n.elementId===s),y=c.useMemo(()=>p||w[0],[p,w]),S=y?[...y.solutions].sort((n,t)=>n.wins===t.wins?0:n.wins?1:-1):[];return e.jsxs(I,{className:i.drawer,open:l,position:"end",onOpenChange:(n,t)=>!t.open&&r(),children:[e.jsx(R,{children:e.jsx(H,{action:e.jsx(N,{appearance:"subtle",icon:e.jsx(k,{}),onClick:r,"aria-label":"Close"}),children:e.jsx(L,{children:"Solution Conflicts"})})}),e.jsx(E,{children:e.jsxs("div",{className:i.body,children:[s&&e.jsxs("div",{children:[e.jsx(a,{size:200,style:{color:o.colorNeutralForeground3},children:"Conflicting element:"}),e.jsx("div",{className:i.elementId,children:s})]}),e.jsx(h,{intent:"warning",children:e.jsx(x,{children:e.jsx(a,{size:200,children:"Multiple solutions customize this element. Dataverse applies them in solution import order — the most recently imported solution wins."})})}),e.jsx(h,{intent:"info",children:e.jsx(x,{children:e.jsxs(a,{size:200,children:[e.jsx("strong",{children:"To resolve:"})," Merge changes into one solution, or use solution layering to control evaluation order. Managed solutions appear as read-only layers — to resolve, merge the customization into your unmanaged solution."]})})}),j&&e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:o.spacingHorizontalM},children:e.jsx(F,{label:"Loading solution layers..."})}),v&&e.jsx(h,{intent:"error",children:e.jsx(x,{children:v})}),!j&&S.length===0&&e.jsx(a,{style:{color:o.colorNeutralForeground3,textAlign:"center"},children:"No conflict details available from environment layers."}),S.map((n,t)=>e.jsxs("div",{className:`${i.solutionRow} ${n.wins?i.solutionRowWinner:""}`,children:[e.jsxs("div",{className:i.solutionHeader,children:[e.jsx(a,{weight:"semibold",children:n.solutionName}),n.wins&&e.jsx(z,{appearance:"filled",color:"brand",children:"WINS"}),n.managed&&e.jsx(O,{content:"Managed solution — read-only",relationship:"label",children:e.jsx(C,{style:{color:o.colorNeutralForeground3}})}),e.jsx(z,{appearance:"outline",size:"small",children:n.managed?"Managed":"Unmanaged"})]}),e.jsxs(a,{size:200,style:{color:o.colorNeutralForeground3},children:["Publisher: ",n.publisher]}),n.importedOn&&e.jsxs(a,{size:200,style:{color:o.colorNeutralForeground3},children:["Imported: ",new Date(n.importedOn).toLocaleString()]}),e.jsx("div",{style:{display:"flex",gap:o.spacingHorizontalS,flexWrap:"wrap"},children:e.jsx(N,{appearance:"subtle",size:"small",icon:e.jsx(D,{}),onClick:d,children:"View XML diff"})})]},`${n.solutionId}-${t}`))]})})]})};export{K as ConflictDrawer,K as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e,s as h,A as P,h as g,cq as y,y as f}from"./fluent-icons-
|
|
1
|
+
import{z as e,s as h,A as P,h as g,cq as y,y as f}from"./fluent-icons-4bzebHz-.js";import{U as j}from"./crmParameters-rgfZhhzN.js";import{S as v,F as I,I as S,am as k,c as b,B as u,T as R,t as o}from"./fluent-ui-lAhdF0Ck.js";const N=f({root:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS},param:{display:"flex",gap:o.spacingHorizontalS,alignItems:"flex-end",padding:o.spacingVerticalXS,border:`1px solid ${o.colorNeutralStroke2}`,borderRadius:o.borderRadiusMedium},typeSelect:{width:"140px",flexShrink:0},valueField:{flex:1},actions:{display:"flex",gap:o.spacingHorizontalXS,flexShrink:0},addButton:{alignSelf:"flex-start"},hint:{color:o.colorNeutralForeground3,fontSize:o.fontSizeBase100}}),A=[{label:"Context",values:["PrimaryControl","PrimaryControlId","SelectedControl","CommandProperties"]},{label:"Record",values:["PrimaryEntityTypeCode","PrimaryEntityTypeName","FirstPrimaryItemId","PrimaryItemIds"]},{label:"Selection context",values:["SelectedEntityTypeCode","SelectedEntityTypeName","FirstSelectedItemId"]},{label:"Grid selection",values:["SelectedControlSelectedItemCount","SelectedControlSelectedItemIds","SelectedControlSelectedItemReferences","SelectedControlAllItemCount","SelectedControlAllItemIds","SelectedControlAllItemReferences","SelectedControlUnselectedItemCount","SelectedControlUnselectedItemIds","SelectedControlUnselectedItemReferences"]},{label:"Org/User",values:["OrgName","OrgLcid","UserLcid"]}],B=({params:c,onChange:d,urlMode:m=!1})=>{const i=N(),s=(l,t)=>{const r=[...c];r[l]=t,d(r)},C=l=>{d(c.filter((t,r)=>r!==l))},x=(l,t)=>{const r=[...c],a=l+t;a<0||a>=r.length||([r[l],r[a]]=[r[a],r[l]],d(r))},p=()=>{d([...c,{kind:"CrmParameter",value:"PrimaryControl"}])};return e.jsxs("div",{className:i.root,children:[c.map((l,t)=>e.jsxs("div",{className:i.param,children:[e.jsx("div",{className:i.typeSelect,children:e.jsxs(v,{value:l.kind,onChange:(r,a)=>{const n=a.value;n==="CrmParameter"?s(t,{kind:n,value:"PrimaryControl"}):n==="BoolParameter"?s(t,{kind:n,value:!1}):n==="IntParameter"||n==="DecimalParameter"?s(t,{kind:n,value:0}):s(t,{kind:"StringParameter",value:""})},children:[e.jsx("option",{value:"CrmParameter",children:"CrmParameter"}),e.jsx("option",{value:"StringParameter",children:"String"}),e.jsx("option",{value:"BoolParameter",children:"Boolean"}),e.jsx("option",{value:"IntParameter",children:"Integer"}),e.jsx("option",{value:"DecimalParameter",children:"Decimal"})]})}),m&&e.jsx(I,{label:"Name (querystring key)",style:{width:"130px",flexShrink:0},children:e.jsx(S,{value:l.name??"",onChange:(r,a)=>s(t,{...l,name:a.value||void 0}),placeholder:"key"})}),e.jsx("div",{className:i.valueField,children:l.kind==="CrmParameter"?e.jsx(v,{value:l.value,onChange:(r,a)=>s(t,{...l,value:a.value}),children:A.map(r=>r.values.filter(a=>!m||!j.has(a)).map(a=>e.jsx("option",{value:a,children:a},a)))}):l.kind==="BoolParameter"?e.jsx(k,{checked:l.value,onChange:(r,a)=>s(t,{...l,value:a.checked}),label:"true"}):e.jsx(S,{type:l.kind==="StringParameter"?"text":"number",value:String(l.value),onChange:(r,a)=>{const n=l.kind==="StringParameter"?a.value:l.kind==="IntParameter"?parseInt(a.value):parseFloat(a.value);s(t,{...l,value:n})}})}),m&&l.kind==="CrmParameter"&&!l.name&&e.jsx(b,{appearance:"filled",color:"warning",size:"small",title:"Name required for URL actions"}),e.jsxs("div",{className:i.actions,children:[e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(h,{}),onClick:()=>x(t,-1),disabled:t===0,"aria-label":"Move up"}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(P,{}),onClick:()=>x(t,1),disabled:t===c.length-1,"aria-label":"Move down"}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(g,{}),onClick:()=>C(t),"aria-label":"Remove parameter"})]})]},t)),m&&e.jsxs(R,{className:i.hint,children:["For URL actions, each CrmParameter must have a ",e.jsx("code",{children:"name"})," attribute (querystring key)."]}),e.jsx(u,{className:i.addButton,appearance:"secondary",size:"small",icon:e.jsx(y,{}),onClick:p,children:"Add parameter"})]})};export{B as C};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./monaco-
|
|
2
|
-
import{R as g,a as b,_ as H}from"./monaco-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./monaco-BoSoLy50.js","./monaco-Dprb6f6S.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{R as g,a as b,_ as H}from"./monaco-BoSoLy50.js";import{z as s,h as E,y as C}from"./fluent-icons-4bzebHz-.js";import{a as x,u,g as N}from"./index-B2t4gwW0.js";import{ah as O,ai as _,aj as V,aa as $,B as S,ak as X,M as I,e as T,T as A,c as D,a5 as G,t as r}from"./fluent-ui-lAhdF0Ck.js";import"./dnd-vmvAsOrM.js";const P=g.lazy(()=>H(()=>import("./monaco-BoSoLy50.js").then(n=>n.i),__vite__mapDeps([0,1]),import.meta.url).then(n=>({default:n.DiffEditor}))),W=["HomepageGrid","SubGrid","Form","Application"],U=C({drawer:{},body:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,overflow:"hidden",gap:r.spacingHorizontalS},statsBar:{display:"flex",alignItems:"center",gap:r.spacingHorizontalS,padding:`${r.spacingVerticalXS} ${r.spacingHorizontalM}`,flexShrink:0},toggleRow:{display:"flex",alignItems:"center",gap:r.spacingHorizontalS,padding:`${r.spacingVerticalXS} ${r.spacingHorizontalM}`,borderBottom:`1px solid ${r.colorNeutralStroke2}`,flexShrink:0},editorWrap:{flex:1,height:0,minHeight:"400px",overflow:"hidden",position:"relative"}});function F(n,o){const l=n.split(`
|
|
3
3
|
`),c=o.split(`
|
|
4
4
|
`);let d=0,a=0;const f=new Set(l),t=new Set(c);for(const i of c)f.has(i)||d++;for(const i of l)t.has(i)||a++;return{added:d,removed:a}}function B(n,o,l,c,d,a,f){const t=[];for(const i of W){const p=f?o[i]:n[i],m=o[i];try{t.push(`<!-- ${i} -->
|
|
5
5
|
`+N({location:i,current:p,baseline:m,commands:l,displayRules:c,enableRules:d,locLabels:a,entityLogicalName:p.entityLogicalName}))}catch(h){t.push(`<!-- ${i}: Error generating XML: ${String(h)} -->`)}}return t.join(`
|
package/dist/assets/{HideInsteadOfDeleteModal-BYHCTZrG.js → HideInsteadOfDeleteModal-DYsP_BRs.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as r}from"./fluent-icons-
|
|
1
|
+
import{z as r}from"./fluent-icons-4bzebHz-.js";import{a as i,u as n,ag as u,ah as c,a8 as b}from"./index-B2t4gwW0.js";import"./monaco-BoSoLy50.js";import"./fluent-ui-lAhdF0Ck.js";import"./dnd-vmvAsOrM.js";const h=()=>{const o=i(e=>e.hideInsteadOfDelete),a=i(e=>e.closeHideInsteadOfDelete),s=i(e=>e.announce),t=n(e=>o?b(e.ribbons[o.location].tabs.find(d=>d.id===o.tabId)?.groups.find(d=>d.id===o.groupId),o.buttonId):void 0),l=n(e=>o?e.baseline[o.location]:void 0);return!o||!t||!l?null:r.jsx(u,{open:!0,buttonLabel:t.label,commandId:t.commandId,deleteBlockedReason:c(t,l),onConfirmHide:()=>{n.getState().hideOobButton(o.location,o.tabId,o.groupId,o.buttonId),s("Button hidden"),a()},onConfirmDisplayRule:()=>{n.getState().hideWithDisplayRules(t.commandId)&&s("Button hidden"),a()},onCancel:a})};export{h as HideInsteadOfDeleteModal,h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as r,h as pe,E as q,L as he,y as me}from"./fluent-icons-DxKNRZ1A.js";import{a as l,R as X}from"./monaco-Bx8A1Vm1.js";import{O as be,a as Y,u as fe,X as T,b as Z,aa as ye,c as U,ab as we}from"./index-Bu7BlRFk.js";import{s as J,p as Se,l as Q,d as xe}from"./webResourceService-CvyHBu7T.js";import{D as Ce,h as ke,j as ve,i as Re,aa as je,B as A,k as Be,ac as Ie,ad as W,I as H,C as $e,O as Te,a1 as Ae,t as s,T as y,c as Pe,l as Ee}from"./fluent-ui-D7EtYwEg.js";import"./dnd-fsSwRnQv.js";function G(a){return a.replace(/([A-Z])/g,(t,i,c)=>(c>0?"_":"")+t.toLowerCase())}function Ne(a){const t=new TextEncoder().encode(a);let i="";for(let c=0;c<t.length;c++)i+=String.fromCharCode(t[c]);return btoa(i)}function ee(a,t="regular"){return`${G(a)}${t==="filled"?".filled":""}.svg`}function oe(a,t,i="regular"){const c=a.trim().replace(/_+$/,"");if(!c)throw new Error("A publisher prefix is required to name the icon web resource");return`${c}_/icons/cbs/${ee(t,i)}`}const Fe=11,De=2*6e4,K={save:J,publish:Se},Le=new Set;async function ze(a,t,i,c,g={}){const x=g.save??K.save,I=g.publish??K.publish,v=g.published??Le,w=oe(i,a,t),h=await c(a,20,t);if(!h)throw new Error(`Could not convert the Fluent icon "${a}" to SVG`);const m=await x(w,Ne(h),Fe,{displayName:`${ee(a,t)} (CBS icon)`,keepExisting:!0}),d={name:w,id:m.id,created:m.created};if(!v.has(m.id))try{await be(`Publishing icon web resource ${w}`,()=>I(m.id),{timeoutMs:De,...g.busy}),v.add(m.id)}catch(C){d.publishError=C instanceof Error?C.message:String(C)}return d}const Me=[{category:"Actions",keywords:["Add","Delete","Edit","Save","Copy","Paste","Undo","Redo","Send","Print","Refresh"]},{category:"Communication",keywords:["Mail","Chat","Phone","Call","Message"]},{category:"Navigation",keywords:["Arrow","Chevron","Navigation","Home","Back","Forward"]},{category:"System",keywords:["Settings","Info","Warning","Dismiss","Question","Checkmark","Error"]},{category:"Security",keywords:["Lock","Shield","Key","Fingerprint"]},{category:"People",keywords:["Person","People","Contact","User"]},{category:"Business",keywords:["Building","Briefcase","Money","Credit","Cart","Tag","Receipt"]},{category:"Files",keywords:["Document","Folder","Attach","Upload","Download","File"]},{category:"Web",keywords:["Globe","Link","Open","Browser","World"]},{category:"Time",keywords:["Calendar","Clock","Timer","History"]},{category:"Rating",keywords:["Star","Heart","Thumb"]},{category:"View",keywords:["Eye","Zoom","View","Window","Preview"]},{category:"Layout",keywords:["Grid","List","Table","Panel","Column","Row"]},{category:"Development",keywords:["Code","Bug","Branch","Wrench","Tool","Terminal"]},{category:"Media",keywords:["Play","Pause","Stop","Video","Audio","Camera"]},{category:"Analytics",keywords:["Chart","Data","Poll","Graph","Trend"]}],Ue=["Add","Delete","Edit","Save","Copy","Cut","ClipboardPaste","Share","Mail","Chat","Phone","Search","Filter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","ChevronDown","ChevronUp","Navigation","Home","Settings","Info","Warning","Checkmark","Dismiss","QuestionCircle","LockClosed","LockOpen","Shield","Person","People","PersonAdd","Building","Briefcase","Money","CreditCard","Cart","Tag","Document","DocumentBulletList","Folder","FolderOpen","Attach","ArrowDownload","ArrowUpload","Globe","Link","Open","Calendar","Clock","Timer","Star","Heart","ThumbLike","ThumbDislike","Eye","EyeOff","ZoomIn","ZoomOut","Maximize","Minimize","Grid","List","Table","TableSimple","Code","Bug","Play","Pause","Stop","Refresh","ArrowSync","ArrowUndo","ArrowRedo","Printer","Send","Rocket","Sparkle","Trophy","Lightbulb","Bot","DataBar","ChartMultiple","Poll"];function We(a){for(const t of Me)if(t.keywords.some(i=>a.includes(i)))return t.category;return"General"}const re=Ue.map(a=>({name:a,category:We(a)})),He=["All",...Array.from(new Set(re.map(a=>a.category))).sort()],Ge=me({surface:{width:"720px",maxWidth:"95vw",height:"min(580px, 90vh)",maxHeight:"90vh",overflow:"hidden"},dialogBody:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},body:{display:"flex",flexDirection:"column",flex:1,minHeight:0,overflow:"hidden",gap:s.spacingHorizontalS},toolbar:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS,flexWrap:"wrap",flexShrink:0},categoryPicker:{minWidth:"180px",maxWidth:"220px"},iconGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(72px, 1fr))",gap:s.spacingHorizontalXS,overflowY:"auto",flex:1,minHeight:0,padding:s.spacingHorizontalXS},iconTile:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",padding:s.spacingHorizontalXS,borderRadius:s.borderRadiusMedium,border:"1px solid transparent",cursor:"pointer",minHeight:"64px",":hover":{backgroundColor:s.colorNeutralBackground3,border:`1px solid ${s.colorNeutralStroke1}`}},iconTileSelected:{backgroundColor:s.colorBrandBackground2,border:`1px solid ${s.colorBrandStroke1}`},iconLabel:{fontSize:s.fontSizeBase100,textAlign:"center",lineHeight:1.2,wordBreak:"break-word",color:s.colorNeutralForeground2},webResourceList:{flex:1,overflowY:"auto"},webResourceRow:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS,padding:`${s.spacingHorizontalXS} ${s.spacingHorizontalS}`,cursor:"pointer",borderRadius:s.borderRadiusMedium,":hover":{backgroundColor:s.colorNeutralBackground3}},uploadArea:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:s.spacingHorizontalM,border:`2px dashed ${s.colorNeutralStroke2}`,borderRadius:s.borderRadiusMedium,color:s.colorNeutralForeground3}}),Ze=()=>{const a=Ge(),t=Y(e=>e.iconPickerOpen),i=Y(e=>e.closeIconPicker),c=fe(e=>e.setButtonProp),g=T(e=>e.selectedButtonId),x=T(e=>e.selectedGroupId),I=T(e=>e.tabId),v=T(e=>e.location),w=Z(e=>e.publisherPrefix),h=Z(e=>e.activeSolution),[m,d]=l.useState(null),[C,P]=l.useState(null),[b,_]=l.useState("fluent"),[E,se]=l.useState(""),[$,ae]=l.useState("All"),[R,te]=l.useState("regular"),[u,ne]=l.useState(null),[f,N]=l.useState(""),[F,D]=l.useState([]),[O,V]=l.useState(!1),[L,ie]=l.useState(""),[j,k]=l.useState(!1);X.useEffect(()=>{t||(d(null),P(null))},[t]),X.useEffect(()=>{!t||b!=="webresource"||(V(!0),Q("svg").then(e=>D(e)).catch(()=>D([])).finally(()=>V(!1)))},[t,b]);const le=l.useMemo(()=>{const e=L.toLowerCase();return F.filter(o=>!e||o.name.toLowerCase().includes(e))},[L,F]),ce=l.useMemo(()=>{const e=E.toLowerCase();return re.filter(o=>($==="All"||o.category===$)&&(e===""||o.name.toLowerCase().includes(e)))},[E,$]),de=async()=>{if(!u||!g||!x)return;const e=U.getState();if(d(null),!h||h.isManaged){d("Select an unmanaged solution first — the icon is added to it as an SVG web resource.");return}k(!0);try{const o=await ze(u,R,w,we,{busy:{onProgress:n=>e.logInfo("webresource",n)}});o.publishError&&e.logWarn("webresource",`Publishing icon web resource ${o.name} failed: ${o.publishError}. Pick the icon again or publish customizations before using the button.`),c(v,I,x,g,{icon:G(u),image16:`$webresource:${o.name}`,image32:`$webresource:${o.name}`}),e.logInfo("webresource",`${o.created?"Uploaded":"Reusing"} icon web resource ${o.name} (solution ${h.uniqueName}).`),i()}catch(o){const n=o instanceof Error?o.message:String(o);e.logError("webresource",`Fluent icon "${u}" could not be added as a web resource: ${n}`),d(`Could not add the icon as a web resource: ${n}`)}finally{k(!1)}},ue=async()=>{if(!f||!g||!x)return;const e=U.getState();d(null),P(null);const o=f.startsWith("$webresource:")?f.slice(13).trim():null;let n=null;if(o){k(!0);try{const S=F.find(z=>z.name===o),p=await xe(o,S);p.solutionUniqueName&&e.logInfo("webresource",`Added web resource ${o} to solution ${p.solutionUniqueName}.`),n=p.solutionWarning??null}catch(S){const p=S instanceof Error?S.message:String(S);if(/^No web resource named /.test(p)){d(p);return}n=`The icon was set, but ${o} could not be added to the solution: ${p}`,e.logError("webresource",n)}finally{k(!1)}}if(c(v,I,x,g,{image16:f,image32:f}),n){P(n);return}i()},ge=async e=>{if(!h||h.isManaged){d("Select an unmanaged solution first — the SVG is added to it as a web resource.");return}d(null),k(!0);try{const o=await new Promise((p,z)=>{const B=new FileReader;B.onerror=()=>z(B.error??new Error("Failed to read SVG")),B.onload=()=>{const M=String(B.result??"");p(M.includes(",")?M.split(",")[1]??"":M)},B.readAsDataURL(e)}),n=`${w||"new"}_/icons/${e.name}`;await J(n,o,11,{displayName:e.name}),N(`$webresource:${n}`),_("webresource");const S=await Q("svg");D(S)}catch(o){const n=o instanceof Error?o.message:String(o);U.getState().logError("webresource",`SVG upload failed: ${n}`),d(`Upload failed: ${n}`)}finally{k(!1)}};return r.jsx(Ce,{open:t,onOpenChange:(e,o)=>!o.open&&i(),children:r.jsx(ke,{className:a.surface,children:r.jsxs(ve,{className:a.dialogBody,children:[r.jsx(Re,{action:r.jsx(A,{appearance:"subtle",icon:r.jsx(pe,{}),onClick:i,"aria-label":"Close"}),children:r.jsx(je,{children:"Choose Icon"})}),r.jsxs(Be,{className:a.body,children:[r.jsxs(Ie,{selectedValue:b,onTabSelect:(e,o)=>_(o.value),size:"small",children:[r.jsx(W,{value:"fluent",children:"Fluent icons"}),r.jsx(W,{value:"webresource",children:"Web resources"}),r.jsx(W,{value:"upload",children:"Upload SVG"})]}),b==="fluent"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:a.toolbar,children:[r.jsx(H,{contentBefore:r.jsx(q,{}),placeholder:"Search icons…",value:E,onChange:(e,o)=>se(o.value),size:"small",style:{flex:1}}),r.jsx($e,{className:a.categoryPicker,placeholder:"Category",value:$,onOptionSelect:(e,o)=>ae(String(o.optionValue??"All")),children:He.map(e=>r.jsx(Te,{value:e,text:e,children:e},e))}),r.jsx(Ae,{label:R==="regular"?"Regular":"Filled",checked:R==="filled",onChange:(e,o)=>te(o.checked?"filled":"regular")})]}),r.jsx("div",{className:a.iconGrid,children:ce.map(e=>r.jsxs("div",{className:`${a.iconTile} ${u===e.name?a.iconTileSelected:""}`,onClick:()=>ne(e.name),role:"option","aria-selected":u===e.name,title:`${e.name} — ${e.category}`,children:[r.jsx(ye,{name:G(e.name),size:24,variant:R}),r.jsx("span",{className:a.iconLabel,children:e.name})]},e.name))}),u&&r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS,padding:s.spacingHorizontalXS,backgroundColor:s.colorNeutralBackground3,borderRadius:s.borderRadiusMedium,flexShrink:0},children:[r.jsxs(y,{size:200,style:{fontFamily:s.fontFamilyMonospace},children:['ModernImage="$webresource:',oe(w||"new",u,R),'"']}),r.jsx(Pe,{appearance:"tint",color:"success",children:"Selected"})]})]}),b==="webresource"&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:s.spacingHorizontalS,flex:1},children:[r.jsx(H,{contentBefore:r.jsx(q,{}),placeholder:"Search SVG web resources...",value:L,onChange:(e,o)=>ie(o.value),size:"small"}),r.jsxs("div",{className:a.webResourceList,children:[O&&r.jsx(y,{size:200,style:{color:s.colorNeutralForeground3},children:"Loading web resources..."}),!O&&le.slice(0,200).map(e=>{const o=`$webresource:${e.name}`,n=f===o;return r.jsx("div",{className:a.webResourceRow,onClick:()=>N(o),style:{backgroundColor:n?s.colorBrandBackground2:void 0},children:r.jsx(y,{size:200,style:{fontFamily:s.fontFamilyMonospace},children:o})},e.id)})]}),r.jsx(H,{placeholder:"$webresource:publisher_/icons/…",value:f,onChange:(e,o)=>N(o.value)}),r.jsx(y,{size:100,style:{color:s.colorNeutralForeground3},children:"Both image16 and image32 will be set to this path. Use SVG for best results across all DPI levels."})]}),b==="upload"&&r.jsxs("div",{className:a.uploadArea,children:[r.jsx(he,{fontSize:48,style:{opacity:.4}}),r.jsx(y,{children:"Drag an SVG file here, or click to browse"}),r.jsx(y,{size:200,style:{color:s.colorNeutralForeground3},children:"The file will be uploaded as a web resource in the active solution."}),r.jsx("input",{type:"file",accept:".svg",style:{display:"none"},id:"icon-upload-input",onChange:e=>{const o=e.target.files?.[0];o&&ge(o)}}),r.jsx("label",{htmlFor:"icon-upload-input",style:{display:"inline-block",cursor:"pointer",padding:"6px 12px",background:s.colorBrandBackground,color:s.colorNeutralForegroundOnBrand,borderRadius:s.borderRadiusMedium,fontSize:s.fontSizeBase300},children:j?"Uploading...":"Browse for SVG"})]}),m&&r.jsx(y,{role:"alert",size:200,style:{color:s.colorPaletteRedForeground1,flexShrink:0},children:m}),C&&r.jsxs(y,{role:"status",size:200,style:{color:s.colorPaletteMarigoldForeground1,flexShrink:0},children:["Icon applied. ",C]})]}),r.jsxs(Ee,{children:[r.jsx(A,{appearance:"secondary",onClick:i,children:"Cancel"}),b==="fluent"&&r.jsx(A,{appearance:"primary",disabled:!u||j,onClick:()=>{de()},children:j?"Adding icon…":`Use ${u??"icon"}`}),b==="webresource"&&r.jsx(A,{appearance:"primary",disabled:!f||j,onClick:()=>{ue()},children:j?"Adding icon…":"Use web resource"})]})]})})})};export{Ze as IconPickerModal,Ze as default};
|
|
1
|
+
import{z as r,h as pe,E as q,L as he,y as me}from"./fluent-icons-4bzebHz-.js";import{a as l,R as X}from"./monaco-BoSoLy50.js";import{O as be,a as Y,u as fe,X as T,b as Z,aa as ye,c as U,ab as we}from"./index-B2t4gwW0.js";import{s as J,p as Se,l as Q,d as xe}from"./webResourceService-DGt6sRPR.js";import{D as Ce,h as ke,j as ve,i as Re,aa as je,B as A,k as Be,ac as Ie,ad as W,I as H,C as $e,O as Te,a1 as Ae,t as s,T as y,c as Pe,l as Ee}from"./fluent-ui-lAhdF0Ck.js";import"./dnd-vmvAsOrM.js";function G(a){return a.replace(/([A-Z])/g,(t,i,c)=>(c>0?"_":"")+t.toLowerCase())}function Ne(a){const t=new TextEncoder().encode(a);let i="";for(let c=0;c<t.length;c++)i+=String.fromCharCode(t[c]);return btoa(i)}function ee(a,t="regular"){return`${G(a)}${t==="filled"?".filled":""}.svg`}function oe(a,t,i="regular"){const c=a.trim().replace(/_+$/,"");if(!c)throw new Error("A publisher prefix is required to name the icon web resource");return`${c}_/icons/cbs/${ee(t,i)}`}const Fe=11,De=2*6e4,K={save:J,publish:Se},Le=new Set;async function ze(a,t,i,c,g={}){const x=g.save??K.save,I=g.publish??K.publish,v=g.published??Le,w=oe(i,a,t),h=await c(a,20,t);if(!h)throw new Error(`Could not convert the Fluent icon "${a}" to SVG`);const m=await x(w,Ne(h),Fe,{displayName:`${ee(a,t)} (CBS icon)`,keepExisting:!0}),d={name:w,id:m.id,created:m.created};if(!v.has(m.id))try{await be(`Publishing icon web resource ${w}`,()=>I(m.id),{timeoutMs:De,...g.busy}),v.add(m.id)}catch(C){d.publishError=C instanceof Error?C.message:String(C)}return d}const Me=[{category:"Actions",keywords:["Add","Delete","Edit","Save","Copy","Paste","Undo","Redo","Send","Print","Refresh"]},{category:"Communication",keywords:["Mail","Chat","Phone","Call","Message"]},{category:"Navigation",keywords:["Arrow","Chevron","Navigation","Home","Back","Forward"]},{category:"System",keywords:["Settings","Info","Warning","Dismiss","Question","Checkmark","Error"]},{category:"Security",keywords:["Lock","Shield","Key","Fingerprint"]},{category:"People",keywords:["Person","People","Contact","User"]},{category:"Business",keywords:["Building","Briefcase","Money","Credit","Cart","Tag","Receipt"]},{category:"Files",keywords:["Document","Folder","Attach","Upload","Download","File"]},{category:"Web",keywords:["Globe","Link","Open","Browser","World"]},{category:"Time",keywords:["Calendar","Clock","Timer","History"]},{category:"Rating",keywords:["Star","Heart","Thumb"]},{category:"View",keywords:["Eye","Zoom","View","Window","Preview"]},{category:"Layout",keywords:["Grid","List","Table","Panel","Column","Row"]},{category:"Development",keywords:["Code","Bug","Branch","Wrench","Tool","Terminal"]},{category:"Media",keywords:["Play","Pause","Stop","Video","Audio","Camera"]},{category:"Analytics",keywords:["Chart","Data","Poll","Graph","Trend"]}],Ue=["Add","Delete","Edit","Save","Copy","Cut","ClipboardPaste","Share","Mail","Chat","Phone","Search","Filter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","ChevronDown","ChevronUp","Navigation","Home","Settings","Info","Warning","Checkmark","Dismiss","QuestionCircle","LockClosed","LockOpen","Shield","Person","People","PersonAdd","Building","Briefcase","Money","CreditCard","Cart","Tag","Document","DocumentBulletList","Folder","FolderOpen","Attach","ArrowDownload","ArrowUpload","Globe","Link","Open","Calendar","Clock","Timer","Star","Heart","ThumbLike","ThumbDislike","Eye","EyeOff","ZoomIn","ZoomOut","Maximize","Minimize","Grid","List","Table","TableSimple","Code","Bug","Play","Pause","Stop","Refresh","ArrowSync","ArrowUndo","ArrowRedo","Printer","Send","Rocket","Sparkle","Trophy","Lightbulb","Bot","DataBar","ChartMultiple","Poll"];function We(a){for(const t of Me)if(t.keywords.some(i=>a.includes(i)))return t.category;return"General"}const re=Ue.map(a=>({name:a,category:We(a)})),He=["All",...Array.from(new Set(re.map(a=>a.category))).sort()],Ge=me({surface:{width:"720px",maxWidth:"95vw",height:"min(580px, 90vh)",maxHeight:"90vh",overflow:"hidden"},dialogBody:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},body:{display:"flex",flexDirection:"column",flex:1,minHeight:0,overflow:"hidden",gap:s.spacingHorizontalS},toolbar:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS,flexWrap:"wrap",flexShrink:0},categoryPicker:{minWidth:"180px",maxWidth:"220px"},iconGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(72px, 1fr))",gap:s.spacingHorizontalXS,overflowY:"auto",flex:1,minHeight:0,padding:s.spacingHorizontalXS},iconTile:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",padding:s.spacingHorizontalXS,borderRadius:s.borderRadiusMedium,border:"1px solid transparent",cursor:"pointer",minHeight:"64px",":hover":{backgroundColor:s.colorNeutralBackground3,border:`1px solid ${s.colorNeutralStroke1}`}},iconTileSelected:{backgroundColor:s.colorBrandBackground2,border:`1px solid ${s.colorBrandStroke1}`},iconLabel:{fontSize:s.fontSizeBase100,textAlign:"center",lineHeight:1.2,wordBreak:"break-word",color:s.colorNeutralForeground2},webResourceList:{flex:1,overflowY:"auto"},webResourceRow:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS,padding:`${s.spacingHorizontalXS} ${s.spacingHorizontalS}`,cursor:"pointer",borderRadius:s.borderRadiusMedium,":hover":{backgroundColor:s.colorNeutralBackground3}},uploadArea:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:s.spacingHorizontalM,border:`2px dashed ${s.colorNeutralStroke2}`,borderRadius:s.borderRadiusMedium,color:s.colorNeutralForeground3}}),Ze=()=>{const a=Ge(),t=Y(e=>e.iconPickerOpen),i=Y(e=>e.closeIconPicker),c=fe(e=>e.setButtonProp),g=T(e=>e.selectedButtonId),x=T(e=>e.selectedGroupId),I=T(e=>e.tabId),v=T(e=>e.location),w=Z(e=>e.publisherPrefix),h=Z(e=>e.activeSolution),[m,d]=l.useState(null),[C,P]=l.useState(null),[b,_]=l.useState("fluent"),[E,se]=l.useState(""),[$,ae]=l.useState("All"),[R,te]=l.useState("regular"),[u,ne]=l.useState(null),[f,N]=l.useState(""),[F,D]=l.useState([]),[O,V]=l.useState(!1),[L,ie]=l.useState(""),[j,k]=l.useState(!1);X.useEffect(()=>{t||(d(null),P(null))},[t]),X.useEffect(()=>{!t||b!=="webresource"||(V(!0),Q("svg").then(e=>D(e)).catch(()=>D([])).finally(()=>V(!1)))},[t,b]);const le=l.useMemo(()=>{const e=L.toLowerCase();return F.filter(o=>!e||o.name.toLowerCase().includes(e))},[L,F]),ce=l.useMemo(()=>{const e=E.toLowerCase();return re.filter(o=>($==="All"||o.category===$)&&(e===""||o.name.toLowerCase().includes(e)))},[E,$]),de=async()=>{if(!u||!g||!x)return;const e=U.getState();if(d(null),!h||h.isManaged){d("Select an unmanaged solution first — the icon is added to it as an SVG web resource.");return}k(!0);try{const o=await ze(u,R,w,we,{busy:{onProgress:n=>e.logInfo("webresource",n)}});o.publishError&&e.logWarn("webresource",`Publishing icon web resource ${o.name} failed: ${o.publishError}. Pick the icon again or publish customizations before using the button.`),c(v,I,x,g,{icon:G(u),image16:`$webresource:${o.name}`,image32:`$webresource:${o.name}`}),e.logInfo("webresource",`${o.created?"Uploaded":"Reusing"} icon web resource ${o.name} (solution ${h.uniqueName}).`),i()}catch(o){const n=o instanceof Error?o.message:String(o);e.logError("webresource",`Fluent icon "${u}" could not be added as a web resource: ${n}`),d(`Could not add the icon as a web resource: ${n}`)}finally{k(!1)}},ue=async()=>{if(!f||!g||!x)return;const e=U.getState();d(null),P(null);const o=f.startsWith("$webresource:")?f.slice(13).trim():null;let n=null;if(o){k(!0);try{const S=F.find(z=>z.name===o),p=await xe(o,S);p.solutionUniqueName&&e.logInfo("webresource",`Added web resource ${o} to solution ${p.solutionUniqueName}.`),n=p.solutionWarning??null}catch(S){const p=S instanceof Error?S.message:String(S);if(/^No web resource named /.test(p)){d(p);return}n=`The icon was set, but ${o} could not be added to the solution: ${p}`,e.logError("webresource",n)}finally{k(!1)}}if(c(v,I,x,g,{image16:f,image32:f}),n){P(n);return}i()},ge=async e=>{if(!h||h.isManaged){d("Select an unmanaged solution first — the SVG is added to it as a web resource.");return}d(null),k(!0);try{const o=await new Promise((p,z)=>{const B=new FileReader;B.onerror=()=>z(B.error??new Error("Failed to read SVG")),B.onload=()=>{const M=String(B.result??"");p(M.includes(",")?M.split(",")[1]??"":M)},B.readAsDataURL(e)}),n=`${w||"new"}_/icons/${e.name}`;await J(n,o,11,{displayName:e.name}),N(`$webresource:${n}`),_("webresource");const S=await Q("svg");D(S)}catch(o){const n=o instanceof Error?o.message:String(o);U.getState().logError("webresource",`SVG upload failed: ${n}`),d(`Upload failed: ${n}`)}finally{k(!1)}};return r.jsx(Ce,{open:t,onOpenChange:(e,o)=>!o.open&&i(),children:r.jsx(ke,{className:a.surface,children:r.jsxs(ve,{className:a.dialogBody,children:[r.jsx(Re,{action:r.jsx(A,{appearance:"subtle",icon:r.jsx(pe,{}),onClick:i,"aria-label":"Close"}),children:r.jsx(je,{children:"Choose Icon"})}),r.jsxs(Be,{className:a.body,children:[r.jsxs(Ie,{selectedValue:b,onTabSelect:(e,o)=>_(o.value),size:"small",children:[r.jsx(W,{value:"fluent",children:"Fluent icons"}),r.jsx(W,{value:"webresource",children:"Web resources"}),r.jsx(W,{value:"upload",children:"Upload SVG"})]}),b==="fluent"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:a.toolbar,children:[r.jsx(H,{contentBefore:r.jsx(q,{}),placeholder:"Search icons…",value:E,onChange:(e,o)=>se(o.value),size:"small",style:{flex:1}}),r.jsx($e,{className:a.categoryPicker,placeholder:"Category",value:$,onOptionSelect:(e,o)=>ae(String(o.optionValue??"All")),children:He.map(e=>r.jsx(Te,{value:e,text:e,children:e},e))}),r.jsx(Ae,{label:R==="regular"?"Regular":"Filled",checked:R==="filled",onChange:(e,o)=>te(o.checked?"filled":"regular")})]}),r.jsx("div",{className:a.iconGrid,children:ce.map(e=>r.jsxs("div",{className:`${a.iconTile} ${u===e.name?a.iconTileSelected:""}`,onClick:()=>ne(e.name),role:"option","aria-selected":u===e.name,title:`${e.name} — ${e.category}`,children:[r.jsx(ye,{name:G(e.name),size:24,variant:R}),r.jsx("span",{className:a.iconLabel,children:e.name})]},e.name))}),u&&r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS,padding:s.spacingHorizontalXS,backgroundColor:s.colorNeutralBackground3,borderRadius:s.borderRadiusMedium,flexShrink:0},children:[r.jsxs(y,{size:200,style:{fontFamily:s.fontFamilyMonospace},children:['ModernImage="$webresource:',oe(w||"new",u,R),'"']}),r.jsx(Pe,{appearance:"tint",color:"success",children:"Selected"})]})]}),b==="webresource"&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:s.spacingHorizontalS,flex:1},children:[r.jsx(H,{contentBefore:r.jsx(q,{}),placeholder:"Search SVG web resources...",value:L,onChange:(e,o)=>ie(o.value),size:"small"}),r.jsxs("div",{className:a.webResourceList,children:[O&&r.jsx(y,{size:200,style:{color:s.colorNeutralForeground3},children:"Loading web resources..."}),!O&&le.slice(0,200).map(e=>{const o=`$webresource:${e.name}`,n=f===o;return r.jsx("div",{className:a.webResourceRow,onClick:()=>N(o),style:{backgroundColor:n?s.colorBrandBackground2:void 0},children:r.jsx(y,{size:200,style:{fontFamily:s.fontFamilyMonospace},children:o})},e.id)})]}),r.jsx(H,{placeholder:"$webresource:publisher_/icons/…",value:f,onChange:(e,o)=>N(o.value)}),r.jsx(y,{size:100,style:{color:s.colorNeutralForeground3},children:"Both image16 and image32 will be set to this path. Use SVG for best results across all DPI levels."})]}),b==="upload"&&r.jsxs("div",{className:a.uploadArea,children:[r.jsx(he,{fontSize:48,style:{opacity:.4}}),r.jsx(y,{children:"Drag an SVG file here, or click to browse"}),r.jsx(y,{size:200,style:{color:s.colorNeutralForeground3},children:"The file will be uploaded as a web resource in the active solution."}),r.jsx("input",{type:"file",accept:".svg",style:{display:"none"},id:"icon-upload-input",onChange:e=>{const o=e.target.files?.[0];o&&ge(o)}}),r.jsx("label",{htmlFor:"icon-upload-input",style:{display:"inline-block",cursor:"pointer",padding:"6px 12px",background:s.colorBrandBackground,color:s.colorNeutralForegroundOnBrand,borderRadius:s.borderRadiusMedium,fontSize:s.fontSizeBase300},children:j?"Uploading...":"Browse for SVG"})]}),m&&r.jsx(y,{role:"alert",size:200,style:{color:s.colorPaletteRedForeground1,flexShrink:0},children:m}),C&&r.jsxs(y,{role:"status",size:200,style:{color:s.colorPaletteMarigoldForeground1,flexShrink:0},children:["Icon applied. ",C]})]}),r.jsxs(Ee,{children:[r.jsx(A,{appearance:"secondary",onClick:i,children:"Cancel"}),b==="fluent"&&r.jsx(A,{appearance:"primary",disabled:!u||j,onClick:()=>{de()},children:j?"Adding icon…":`Use ${u??"icon"}`}),b==="webresource"&&r.jsx(A,{appearance:"primary",disabled:!f||j,onClick:()=>{ue()},children:j?"Adding icon…":"Use web resource"})]})]})})})};export{Ze as IconPickerModal,Ze as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as l}from"./fluent-icons-DxKNRZ1A.js";import{a as X}from"./monaco-Bx8A1Vm1.js";import{a1 as Te,x as Be,a2 as He,a3 as ze,a4 as Fe,a5 as _e,a6 as Pe,a as ae,u as Ue,X as We,b as Je}from"./index-Bu7BlRFk.js";import{a as Ye}from"./xmlValidator-D7JG-eNC.js";import{M as Ke}from"./MonacoEditor-Bbg9u2FW.js";import{D as Ve,h as Qe,i as Ze,j as et,k as tt,T as De,M,e as q,ap as le,l as ot,B as Z}from"./fluent-ui-D7EtYwEg.js";import"./dnd-fsSwRnQv.js";import"./ruleKinds-B9hACGaq.js";import"./crmParameters-rgfZhhzN.js";const fe=["HomepageGrid","SubGrid","Form"],ce=[...fe,"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":fe.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 f of t)s.set(f.id,f),n.set(f.id,(n.get(f.id)??0)+1);for(const[f,b]of n)b>1&&$.push(`${o} ${f} is defined ${b} times in the XML — the last one was used.`);const u=Array.from(s.values()),i=[...e],p=[];let h=0;for(const f of u){const b=i.findIndex(T=>T.id===f.id);if(b>=0&&ve(i[b],f)){h++;continue}y.push(`${o} ${f.id} ${b>=0?"updated":"added"}`),b>=0?i[b]=f:i.push(f),p.push(f.id)}return{out:i,changedIds:p,unchanged:h}},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,...fe.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 h=n.source?.attributes.Sequence?n.sequence:o;h!==void 0&&h!==i.sequence&&(i.origin==="unmanaged"?(u.buttons.splice(u.buttons.indexOf(i),1),i.sequence=h,K(u.buttons,i)):r.push(`${e}: Sequence ${h} 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(h=>h.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 h of O(t.querySelector(":scope > Controls")))de.has(h.tagName)?Se(e,h,n,void 0):He(ze[h.tagName])&&r.push(`${h.getAttribute("Id")??"(no Id)"}: adding a <${h.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,h=Array.from(t.querySelectorAll(":scope > Groups > Group")).map(T=>Ce(T,void 0)).filter(T=>!!T),f=$e(t);Y({id:s,source:f});const b={...n,label:G(f.titleToken,s),source:f,sequence:t.getAttribute("Sequence")===null?o??n.sequence:n.sequence,groups:h};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 ${h.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 he=({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(he,{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(he,{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(he,{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
|
+
import{z as l}from"./fluent-icons-4bzebHz-.js";import{a as X}from"./monaco-BoSoLy50.js";import{a1 as Te,x as Be,a2 as He,a3 as ze,a4 as Fe,a5 as _e,a6 as Pe,a as ae,u as Ue,X as We,b as Je}from"./index-B2t4gwW0.js";import{a as Ye}from"./xmlValidator-D-tVo-1Z.js";import{M as Ke}from"./MonacoEditor-DakCq511.js";import{D as Ve,h as Qe,i as Ze,j as et,k as tt,T as De,M,e as q,ap as le,l as ot,B as Z}from"./fluent-ui-lAhdF0Ck.js";import"./dnd-vmvAsOrM.js";import"./ruleKinds-B9hACGaq.js";import"./crmParameters-rgfZhhzN.js";const fe=["HomepageGrid","SubGrid","Form"],ce=[...fe,"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":fe.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 f of t)s.set(f.id,f),n.set(f.id,(n.get(f.id)??0)+1);for(const[f,b]of n)b>1&&$.push(`${o} ${f} is defined ${b} times in the XML — the last one was used.`);const u=Array.from(s.values()),i=[...e],p=[];let h=0;for(const f of u){const b=i.findIndex(T=>T.id===f.id);if(b>=0&&ve(i[b],f)){h++;continue}y.push(`${o} ${f.id} ${b>=0?"updated":"added"}`),b>=0?i[b]=f:i.push(f),p.push(f.id)}return{out:i,changedIds:p,unchanged:h}},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,...fe.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 h=n.source?.attributes.Sequence?n.sequence:o;h!==void 0&&h!==i.sequence&&(i.origin==="unmanaged"?(u.buttons.splice(u.buttons.indexOf(i),1),i.sequence=h,K(u.buttons,i)):r.push(`${e}: Sequence ${h} 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(h=>h.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 h of O(t.querySelector(":scope > Controls")))de.has(h.tagName)?Se(e,h,n,void 0):He(ze[h.tagName])&&r.push(`${h.getAttribute("Id")??"(no Id)"}: adding a <${h.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,h=Array.from(t.querySelectorAll(":scope > Groups > Group")).map(T=>Ce(T,void 0)).filter(T=>!!T),f=$e(t);Y({id:s,source:f});const b={...n,label:G(f.titleToken,s),source:f,sequence:t.getAttribute("Sequence")===null?o??n.sequence:n.sequence,groups:h};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 ${h.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 he=({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(he,{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(he,{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(he,{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 +1 @@
|
|
|
1
|
-
import{z as a,h as M,cq as P,co as q,y as G,cB as J}from"./fluent-icons-
|
|
1
|
+
import{z as a,h as M,cq as P,co as q,y as G,cB as J}from"./fluent-icons-4bzebHz-.js";import{R as N,a as B}from"./monaco-BoSoLy50.js";import{a as L,u as m,e as V,a9 as Y}from"./index-B2t4gwW0.js";import{D as Q,h as Z,j as ee,i as ae,aa as te,c as $,B as x,k as le,I as oe,T as H,t as i,m as F,l as ne}from"./fluent-ui-lAhdF0Ck.js";import"./dnd-vmvAsOrM.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};
|