@mohsinonxrm/pptb-commandbar-studio 0.8.0 → 0.9.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +472 -0
- package/README.md +71 -48
- package/dist/assets/BulkPublishModal-DzDZJg0U.js +36 -0
- package/dist/assets/CommandEditorPanel-DsCP9yG4.js +1 -0
- package/dist/assets/CommandPalette-ID3kRJ9l.js +1 -0
- package/dist/assets/CompareView-DGsrcdoN.js +7 -0
- package/dist/assets/CrmParameterEditor-C22QGWff.js +1 -0
- package/dist/assets/EditorDrawer-CvCe9WeO.js +2 -0
- package/dist/assets/HideInsteadOfDeleteModal-3j9g-E9l.js +1 -0
- package/dist/assets/IconPickerModal-BLoDLbLR.js +1 -0
- package/dist/assets/ImportXmlModal-BD-L1QzJ.js +1 -0
- package/dist/assets/{MonacoEditor-uzfuRCpJ.js → MonacoEditor-BMKRZv-g.js} +1 -1
- package/dist/assets/NewButtonModal-COYXwEyk.js +1 -0
- package/dist/assets/NewGroupModal-boP_t1fI.js +1 -0
- package/dist/assets/NewTabModal-BI4afbC5.js +1 -0
- package/dist/assets/RuleEditorPanel-l8QnRFj6.js +1 -0
- package/dist/assets/ScriptView-BVyCmRvD.js +1 -0
- package/dist/assets/TabDisplayRulesPanel-gORq6MO7.js +1 -0
- package/dist/assets/TranslationsView-DubBATog.js +1 -0
- package/dist/assets/WebResourceBrowser-BATScmTw.js +1 -0
- package/dist/assets/XmlView-Bn4KlTw3.js +2 -0
- package/dist/assets/dnd-C1w9VFfC.js +5 -0
- package/dist/assets/fluent-icons-CQEhzzaC.js +1 -0
- package/dist/assets/fluent-ui-BEjALNLO.js +59 -0
- package/dist/assets/index-6so8O90C.js +136 -0
- package/dist/assets/index-D5GCH8nj.css +1 -0
- package/dist/assets/ruleKinds-BKTUiZ1-.js +1 -0
- package/dist/assets/useReplaceWebResourceConfirm-DND-V0vw.js +1 -0
- package/dist/assets/useStableKeys-BkDn7til.js +1 -0
- package/dist/assets/{xmlValidator-BkeotXuB.js → xmlValidator-PbODaIQV.js} +1 -1
- package/dist/icons/icon.svg +7 -4
- package/dist/index.html +15 -9
- package/index.html +10 -4
- package/package.json +1 -1
- package/dist/assets/BulkPublishModal-mJ41AWew.js +0 -36
- package/dist/assets/CommandEditorPanel-BiP1kPHY.js +0 -1
- package/dist/assets/CommandPalette-q51_0qRZ.js +0 -1
- package/dist/assets/ConflictDrawer-CdWv_PbN.js +0 -1
- package/dist/assets/DiffViewer-BQP5f73U.js +0 -7
- package/dist/assets/HideInsteadOfDeleteModal-C9r6ah5p.js +0 -1
- package/dist/assets/IconPickerModal-B81Tnf5i.js +0 -1
- package/dist/assets/ImportXmlModal-C0cMaS59.js +0 -1
- package/dist/assets/LocalizationEditor-DniDtrZV.js +0 -1
- package/dist/assets/NewButtonModal-BXpX1Ld5.js +0 -1
- package/dist/assets/NewGroupModal-Bh7lXq52.js +0 -1
- package/dist/assets/NewTabModal-Pntdk3in.js +0 -1
- package/dist/assets/RuleEditorPanel-BUGKgc0N.js +0 -1
- package/dist/assets/ScalingEditorPanel-p3-Yw3CO.js +0 -1
- package/dist/assets/TabDisplayRulesPanel-CSNshwaw.js +0 -1
- package/dist/assets/UrlComposerModal-WKSTwUcW.js +0 -1
- package/dist/assets/WebResourceBrowser-BK-gVU2g.js +0 -1
- package/dist/assets/XmlDrawer-CQJElnD1.js +0 -2
- package/dist/assets/dnd-Cq8OftAq.js +0 -5
- package/dist/assets/fluent-icons-BqJj6rDi.js +0 -1
- package/dist/assets/fluent-ui-QADO660t.js +0 -43
- package/dist/assets/index-D9lerlVA.css +0 -1
- package/dist/assets/index-Di2_5czx.js +0 -136
- package/dist/assets/ruleKinds-B9hACGaq.js +0 -1
- package/dist/assets/useReplaceWebResourceConfirm-BUWBVNSC.js +0 -1
- package/dist/assets/useStableKeys-p2OkzZWO.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
html,body,#root{width:100%;height:100%;margin:0;padding:0}body{overflow:hidden}*{scrollbar-width:thin;scrollbar-color:rgba(128,128,128,.45) transparent}*::-webkit-scrollbar{width:10px;height:10px}*::-webkit-scrollbar-track{background:transparent}*::-webkit-scrollbar-thumb{background-color:#80808059;border-radius:8px;border:2px solid transparent;background-clip:content-box}*::-webkit-scrollbar-thumb:hover{background-color:#80808099;background-clip:content-box}*::-webkit-scrollbar-corner{background:transparent}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const u={CommandClientTypeRule:"Client (Unified Interface / legacy)",CrmClientTypeRule:"Client (web / Outlook)",CrmOfflineAccessStateRule:"Offline access",CrmOutlookClientTypeRule:"Outlook client",CrmOutlookClientVersionRule:"Outlook client version",CustomRule:"Your JavaScript",DeviceTypeRule:"Device",EntityPrivilegeRule:"Table privilege",EntityPropertyRule:"Table property",EntityRule:"Table",FeatureControlRule:"Feature control bit",FormEntityContextRule:"Form's table",FormStateRule:"Form state",FormTypeRule:"Form type",HideForTabletExperienceRule:"Hide on tablets",MiscellaneousPrivilegeRule:"Other privilege",OptionSetRule:"Choice value",OrganizationSettingRule:"Organization setting",OrRule:"Any of (Or)",OutlookItemTrackingRule:"Outlook item tracking",OutlookRenderTypeRule:"Outlook or web",OutlookVersionRule:"Outlook version",PageRule:"Page address",RawRule:"Other rule (kept as XML)",RecordPrivilegeRule:"Record privilege",ReferencingAttributeRequiredRule:"Referencing column required",RelationshipTypeRule:"Relationship type",SelectionCountRule:"Selected records",SkuRule:"Deployment (online / on-premises)",ValueRule:"Column value"},n=[{label:"Client and device",kinds:["CommandClientTypeRule","CrmClientTypeRule","DeviceTypeRule","CrmOutlookClientVersionRule"]},{label:"Form",kinds:["FormStateRule","FormTypeRule","FormEntityContextRule"]},{label:"Table",kinds:["EntityRule","EntityPrivilegeRule","EntityPropertyRule","OptionSetRule"]},{label:"Selection and record",kinds:["SelectionCountRule","ValueRule","RecordPrivilegeRule"]},{label:"Other",kinds:["MiscellaneousPrivilegeRule","OrganizationSettingRule","FeatureControlRule","PageRule","SkuRule","HideForTabletExperienceRule","RelationshipTypeRule","ReferencingAttributeRequiredRule"]},{label:"Outlook",kinds:["CrmOfflineAccessStateRule","CrmOutlookClientTypeRule","OutlookItemTrackingRule","OutlookRenderTypeRule","OutlookVersionRule"]},{label:"Combine steps",kinds:["OrRule"]},{label:"Your code",kinds:["CustomRule"]}],o=new Set(["CustomRule","OutlookItemTrackingRule","RecordPrivilegeRule","SelectionCountRule"]),l=new Set(["CrmOutlookClientVersionRule","DeviceTypeRule","EntityPrivilegeRule","EntityPropertyRule","FeatureControlRule","FormEntityContextRule","FormTypeRule","HideForTabletExperienceRule","MiscellaneousPrivilegeRule","OptionSetRule","OrganizationSettingRule","OutlookRenderTypeRule","ReferencingAttributeRequiredRule","RelationshipTypeRule"]),r=new Set([...Array.from(l),"HideIfNetBreezeNotAvailableRule","HideIfServiceMetadataAvailableRule","HideIfSharepointS2SConfigurationEnabledRule","HideIfExportToExcelNotEnabledRule","IsExportToExcelOnlineEnabledRule","HideIfDisabledForMobileRule","HideIfHybridSSSNotEnabledRule","HideIfEmailSignatureNotEnabledRule","HideIfReverseHybridSSSNotEnabledRule","HideIfDelveNotAvailableRule","HideIfTestExchangeServerNotEnabledRule","HideIfSSSTroubleshootingNotEnabledRule","HideIfCurrentUserIsNotSystemAdministratorRule","HideIfPowerBITileNotAvailableRule","HideIfProcessActiveRule","HideIfProcessInactiveRule","HideIfProcessUnificationIsDisabledRule","HideIfO365UserDoesNotHaveExchangeSubscriptionsRule","HideIfEmailIsApprovedByAdminRule","HideIfUserIsNotTenantAdminRule","HideIfEmailIsApprovedByAdminBasedOnESPRule","HideIfProductRecommendationsNotEnabledRule"]);function R(e,t,i=!1){return e==="RawRule"||i&&e==="OrRule"?!1:t==="enable"?!l.has(e):!o.has(e)}export{r as D,o as E,n as R,u as a,R as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as e}from"./fluent-icons-CQEhzzaC.js";import{a as r}from"./monaco-BIO15LCS.js";import{R as u,as as g}from"./index-6so8O90C.js";import{D as x,d as h,e as f,f as j,i as b,t as y,b as l,j as C,h as o}from"./fluent-ui-BEjALNLO.js";function E(){const[n,t]=r.useState(null),i=r.useRef(null),d=u(a=>a.connectionVersion),s=r.useCallback(a=>{i.current?.(a),i.current=null,t(null)},[]),p=r.useCallback(a=>new Promise(c=>{i.current?.("cancel"),i.current=c,t({name:a.name,managed:a.managed})}),[]);r.useEffect(()=>()=>s("cancel"),[d,s]);const m=e.jsx(x,{open:n!==null,onOpenChange:(a,c)=>!c.open&&s("cancel"),children:e.jsx(h,{style:{maxWidth:520},children:e.jsxs(f,{children:[e.jsx(j,{children:n?.managed?"Use the existing web resource?":"Replace the existing web resource?"}),e.jsxs(b,{style:{display:"flex",flexDirection:"column",gap:y.spacingVerticalS},children:[n?.managed?e.jsxs(l,{children:["A managed web resource named ",e.jsx("strong",{children:n.name})," already exists. It can't be replaced: keep it as it is, or rename the file and upload it again."]}):e.jsxs(l,{children:["A web resource named ",e.jsx("strong",{children:n?.name})," already exists. Replacing it changes its content everywhere it is used (other ribbons, forms, apps)."]}),e.jsx(g,{prefix:"In"})]}),e.jsxs(C,{children:[e.jsx(o,{appearance:"secondary",onClick:()=>s("cancel"),children:"Cancel"}),e.jsx(o,{appearance:n?.managed?"primary":"secondary",onClick:()=>s("keep"),children:"Keep existing"}),!n?.managed&&e.jsx(o,{appearance:"primary",onClick:()=>s("replace"),children:"Replace"})]})]})})});return{onExisting:p,dialog:m}}export{E as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d}from"./monaco-BIO15LCS.js";import{g as y}from"./dnd-C1w9VFfC.js";let c=0;const g=(n,t)=>Array.from({length:t},()=>`${n}#${++c}`);function p(n,t){const[e,o]=d.useState(null),f=d.useMemo(()=>g(n,t.length),[n,t]),l=!!e&&e.scope===n&&e.keys.length===t.length&&(e.items===t||e.pending);e?.pending&&o({...e,items:l?t:e.items,pending:!1});const r=l?e.keys:f,a=s=>o({scope:n,items:t,pending:!0,keys:s});return{keys:r,add:()=>a([...r,...g(n,1)]),remove:s=>a(r.filter((u,i)=>i!==s)),move:(s,u)=>a(y(r,s,u)),update:()=>a(r)}}export{p as u};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a1 as v,a2 as ie,a3 as re,a4 as V,a5 as le,p as ce}from"./index-6so8O90C.js";import{D as ue,E as me}from"./ruleKinds-BKTUiZ1-.js";import{C as de,i as fe}from"./crmParameters-rgfZhhzN.js";const pe=/^[a-zA-Z_$][a-zA-Z_$0-9.]*$/,he=/^[a-zA-Z_][a-zA-Z_0-9]*$/,ge=/^[+-]?\d+$/,be=/^[+-]?(\d+(\.\d*)?|\.\d+)$/,H=/^(true|false|1|0)$/,W={JavaScriptFunction:["FunctionName","Library"],Url:["Address"],CustomRule:["FunctionName","Library"],CommandClientTypeRule:["Type"],CrmClientTypeRule:["Type"],CrmOfflineAccessStateRule:["State"],CrmOutlookClientTypeRule:["Type"],CrmOutlookClientVersionRule:["Major"],DeviceTypeRule:["Type"],EntityPrivilegeRule:["PrivilegeType","PrivilegeDepth"],EntityPropertyRule:["PropertyName","PropertyValue"],FeatureControlRule:["FeatureControlBit","ExpectedValue"],FormEntityContextRule:["EntityName"],FormStateRule:["State"],FormTypeRule:["Type"],MiscellaneousPrivilegeRule:["PrivilegeName"],OptionSetRule:["OptionSet","StateCode","ObjectTypeCode"],OrganizationSettingRule:["Setting"],OutlookItemTrackingRule:["TrackedInCrm"],OutlookRenderTypeRule:["Type"],OutlookVersionRule:["Version"],PageRule:["Address"],RecordPrivilegeRule:["PrivilegeType"],RelationshipTypeRule:["AppliesTo"],SkuRule:["Sku"],ValueRule:["Field","Value"],BoolParameter:["Value"],CrmParameter:["Value"],DecimalParameter:["Value"],IntParameter:["Value"],StringParameter:["Value"]},ye=new Set(["ValueRule.Value","StringParameter.Value"]),$e={SelectionCountRule:["Minimum","Maximum"],CrmOutlookClientVersionRule:["Major","Minor","Build","Revision"],IntParameter:["Value"],Url:["WinMode"]},Ae={DecimalParameter:["Value"]},Re={BoolParameter:["Value"],Url:["PassParams"],OutlookItemTrackingRule:["TrackedInCrm"],EntityPropertyRule:["PropertyValue"],FeatureControlRule:["ExpectedValue"],RelationshipTypeRule:["AllowCustomRelationship","AllowSystemRelationship"]},Se=["Default","InvertResult"],Ie=new Set(["BoolParameter","CrmParameter","DecimalParameter","IntParameter","StringParameter"]),O=s=>Array.from(s.children);function q(s,l,g){const u=[],f=s.tagName;for(const p of W[f]??[]){const m=s.getAttribute(p);(m===null||!m.trim()&&!ye.has(`${f}.${p}`))&&u.push(`${l}: ${f} has no ${p}`)}const b=(p,m,i)=>{for(const d of p??[]){const R=s.getAttribute(d);R===null||R===""&&W[f]?.includes(d)||m.test(R.trim())||u.push(`${l}: ${f} ${d}="${R}" is not ${i}`)}};if(b($e[f],ge,"a whole number"),b(Ae[f],be,"a number"),b(Re[f],H,"true or false"),g&&b(Se,H,"true or false"),f==="JavaScriptFunction"||f==="CustomRule"){const p=s.getAttribute("FunctionName");p?.trim()&&!pe.test(p)&&u.push(`${l}: FunctionName "${p}" isn't a JavaScript function name (letters, digits, _, $ and dots)`)}if((f==="JavaScriptFunction"||f==="CustomRule")&&/^\$webresource:\s*$/i.test(s.getAttribute("Library")??"")&&u.push(`${l}: ${f} Library names no web resource`),f==="EntityRule"){const p=s.getAttribute("Context");p!==null&&!he.test(p)&&u.push(`${l}: EntityRule Context "${p}" isn't valid`)}f==="Url"&&/^https?:\/\/$/i.test(s.getAttribute("Address")?.trim()??"")&&u.push(`${l}: Url has no address`);for(const p of O(s).filter(m=>Ie.has(m.tagName)))f==="Url"&&!p.getAttribute("Name")?.trim()&&u.push(`${l}: a ${p.tagName} of the Url has no Name`),f!=="Url"&&p.hasAttribute("Name")&&u.push(`${l}: a ${p.tagName} of ${f} can't have a Name`),u.push(...q(p,l,!1));return u}function we(s){const l=s.getAttribute("Id")??"";if(s.tagName==="CommandDefinition"){const b=`Command ${l}`,p=O(s).find(m=>m.tagName==="Actions");return O(p??s).filter(m=>m.tagName==="JavaScriptFunction"||m.tagName==="Url").flatMap(m=>q(m,b,!1))}if(s.tagName!=="EnableRule"&&s.tagName!=="DisplayRule")return[];const g=`${s.tagName==="EnableRule"?"Enable":"Display"} rule ${l}`,u=O(s);if(u.length===0)return[`${g} has no steps — add one, or remove the rule from its commands`];const f=[];for(const b of u){if(b.tagName!=="OrRule"){f.push(...q(b,g,!0));continue}const p=O(b).filter(m=>m.tagName==="Or");p.length<2&&f.push(`${g}: an OrRule needs at least 2 alternatives (it has ${p.length})`);for(const m of p){const i=O(m);i.length===0&&f.push(`${g}: an alternative of its OrRule has no steps`);for(const d of i)d.tagName==="OrRule"?f.push(`${g}: an OrRule can't contain another OrRule`):f.push(...q(d,g,!0))}}return f}const Ne=["Mscrm.HideOnModern","Mscrm.ShowOnlyOnModern"];function E(s,l){const g=s.indexOf(l);return g<0?void 0:`Line ${s.slice(0,g).split(/\r?\n/).length}`}function _e(s,l,g){const u=[],b=new DOMParser().parseFromString(s,"application/xml"),p=b.querySelector("parsererror");if(p){const i=(p.textContent??"").replace(/This page contains the following errors:/i,"").replace(/Below is a rendering of the page up to the first error\.?/i,"").trim()||"Unknown",d=i.match(/line\s+(\d+)/i);return u.push({message:`XML parse error: ${i}`,lineHint:d?`Line ${d[1]}`:void 0}),u}const m=new Set([]);return b.querySelectorAll("[Id]").forEach(i=>{const d=i.getAttribute("Id")??"";if(/\s/.test(d)){const R=E(s,`Id="${d}"`);u.push({message:`Element ID "${d}" contains invalid whitespace characters`,elementId:d,lineHint:R})}}),b.querySelectorAll("[LabelText]").forEach(i=>{const d=i.getAttribute("LabelText")??"",R=d.match(/^\$LocLabels:(.+)$/);if(R&&m.size>0&&!m.has(R[1])){const $=i.getAttribute("Id")??"",S=E(s,$?`Id="${$}"`:`LabelText="${d}"`);u.push({message:`Button label reference "$LocLabels:${R[1]}" has no matching LocLabel entry`,elementId:$||void 0,lineHint:S})}}),(s.includes("& ")||s.includes(`&
|
|
2
2
|
`))&&u.push({message:'URL may contain an unescaped "&" — all ampersands in XML must be written as &',lineHint:E(s,"& ")??E(s,`&
|
|
3
3
|
`)}),b.querySelectorAll("Group").forEach(i=>{const d=[];i.querySelectorAll(":scope > Controls > Button, :scope > Controls > FlyoutAnchor, :scope > Controls > SplitButton").forEach(R=>{const $=parseInt(R.getAttribute("Sequence")??"0",10);if(d.includes($)){const S=i.getAttribute("Id")??"?";u.push({message:`Two elements share Sequence "${$}" in group "${S}"`,elementId:S,lineHint:E(s,`Sequence="${$}"`)})}d.push($)})}),u.push(...Ee(b,s)),u}const X=new Set(["BoolParameter","CrmParameter","DecimalParameter","IntParameter","StringParameter"]);function A(s){return Array.from(s.children)}function te(s,l){return l==="enable"?ue.has(s):me.has(s)}function Ee(s,l){const g=[],u=(m,i,d)=>g.push({message:m,elementId:d,lineHint:E(l,i)}),f=(m,i,d)=>g.push({message:m,elementId:d,lineHint:E(l,i),severity:"warning"}),b=s.querySelector("RibbonDiffXml > RuleDefinitions"),p=[{tag:"EnableRule",label:"Enable",container:"enable"},{tag:"DisplayRule",label:"Display",container:"display"}];for(const{tag:m,label:i,container:d}of p)b?.querySelectorAll(`:scope > ${m}s > ${m}`).forEach(R=>{const $=R.getAttribute("Id")??"",S=A(R);S.length===0&&u(`${i} rule "${$}" has no steps — the schema requires at least one`,`Id="${$}"`,$);const D=I=>{te(I.tagName,d)&&f(`${i} rule "${$}" contains ${I.tagName}, which RibbonTypes.xsd only allows in ${d==="enable"?"display":"enable"} rules`,`<${I.tagName}`,$)};for(const I of S){if(I.tagName!=="OrRule"){D(I);continue}const T=A(I);T.filter(w=>w.tagName==="Or").length<2&&u(`OrRule in ${i.toLowerCase()} rule "${$}" needs at least 2 <Or> children (found ${T.filter(w=>w.tagName==="Or").length})`,"<OrRule",$);for(const w of T){const C=A(w);C.length===0&&u(`Empty <Or> in rule "${$}"`,"<Or",$);for(const L of C)L.tagName==="OrRule"?u(`Rule "${$}": an <Or> cannot contain another OrRule`,"<OrRule",$):D(L)}}});return b||s.querySelectorAll("OrRule").forEach(m=>{const i=m.querySelectorAll(":scope > Or").length;i<2&&u(`OrRule requires at least 2 <Or> children (found ${i})`,"<OrRule")}),s.querySelectorAll("JavaScriptFunction, CustomRule").forEach(m=>{for(const i of A(m)){if(!X.has(i.tagName))continue;i.hasAttribute("Name")&&u(`${i.tagName} inside <${m.tagName}> must not have a Name attribute (only <Url> parameters are named)`,`<${i.tagName} Name=`);const d=i.getAttribute("Value")??"";i.tagName==="CrmParameter"&&!de.has(d)&&u(`CrmParameter Value "${d}" is not a valid CrmParameterValue`,`Value="${d}"`)}}),s.querySelectorAll("Url").forEach(m=>{for(const i of A(m)){if(!X.has(i.tagName))continue;i.getAttribute("Name")||u(`${i.tagName} inside <Url> requires a Name (the query-string key)`,`<${i.tagName}`);const d=i.getAttribute("Value")??"";i.tagName==="CrmParameter"&&!fe(d)&&u(`CrmParameter Value "${d}" is not allowed in a <Url> action (CrmNamedParameterValue)`,`Value="${d}"`)}}),s.querySelector("RibbonDiffXml > Scalings")&&u('<Scalings> is not allowed in RibbonDiffXml — scaling changes are CustomActions with Location="{tabId}.Scaling._children"',"<Scalings"),s.querySelectorAll("CustomAction > CommandUIDefinition > Tab").forEach(m=>{const i=m.getAttribute("Id")??"",d=A(m).map(S=>S.tagName),R=d.indexOf("Scaling"),$=d.indexOf("Groups");(R<0||$>=0&&R>$)&&u(`Tab "${i}" needs a <Scaling Id> element before <Groups>`,`Id="${i}"`,i)}),s.querySelectorAll("TabDisplayRule > DisplayRules").forEach(()=>{u("TabDisplayRule rules must be direct children — remove the <DisplayRules> wrapper","<TabDisplayRule")}),g}const Te=["LabelText","ToolTipTitle","ToolTipDescription","Alt","Title","Description"],Ce=new Set(["powerFx","customApi"]),Le={powerFx:"Power Fx",customApi:"Custom API"};function ve(s){return[...new Set(s.actions.map(l=>l.kind).filter(l=>Ce.has(l)))]}const K=/^\$LocLabels:(.+)$/,ne=/^\$webresource:([^?#]+)/i,J=new Set(["ModernImage","Image16by16","Image32by32"]),Q=new Set(["Tab","Group"]),oe=new Set(["main_system_library.js"]),Oe=new Set(["FlyoutAnchor","SplitButton"]),Pe=new Set(["Button","FlyoutAnchor","SplitButton","TextBox","ComboBox","CheckBox"]),Y=/^(.+)\.Scaling\._children$/,Z=s=>/^(Mscrm|Microsoft)\./.test(s);function ae(s){const l=[],g=[],u=new DOMParser;for(const f of Object.keys(s))for(const[b,p]of s[f]){const m=u.parseFromString(p,"application/xml");if(m.querySelector("parsererror")){g.push({severity:"error",code:"xml-parse",message:`${f} element ${b} is not well-formed XML`,elementId:b});continue}l.push({part:f,key:`${f}:${b}`,el:m.documentElement})}return{elements:l,errors:g}}function N(s){return[s,...Array.from(s.getElementsByTagName("*"))]}function se(s){return typeof s=="string"?ce(s):s}function Be(s){let l;try{l=se(s)}catch{return[]}const g=new Map;for(const{el:u}of ae(l).elements)for(const f of N(u))for(const b of Array.from(f.attributes)){const p=ne.exec(b.value.trim())?.[1],m=p?.toLowerCase();p&&m&&!oe.has(m)&&!g.has(m)&&g.set(m,p)}return[...g.values()]}const ee=s=>{const l=s.trim();return l&&!l.includes(".")?`Mscrm.Templates.${l}`:l};function qe(s,l={}){let g;try{g=se(s)}catch(e){return[{severity:"error",code:"xml-parse",message:e instanceof Error?e.message:String(e)}]}const{elements:u,errors:f}=ae(g),b=l.changedKeys?new Set(l.changedKeys):null,p=e=>!b||b.has(e),m=new Set(l.newKeys??[]),i=(e,n,t,a,o=!1)=>{const r=(Array.isArray(n)?n:[n]).some(p);f.push({severity:o||!r?"warning":"error",code:e,message:r?t:`${t} (already in the published customizations)`,elementId:a})},d=u.filter(e=>e.part==="customActions"),R=u.filter(e=>e.part==="commandDefinitions");for(const{part:e,key:n,el:t}of u)if(!(e!=="commandDefinitions"&&e!=="enableRules"&&e!=="displayRules"))for(const a of we(t))i("schema",n,a,t.getAttribute("Id")??void 0);const $=new Map((l.commands??[]).map(e=>[e.id,e]));for(const{key:e,el:n}of R){const t=n.getAttribute("Id")??"",a=$.get(t);if(!a||!p(e))continue;const o=ve(a);o.length!==0&&i("dropped-action",e,`Command ${t} has a ${o.map(r=>Le[r]??r).join(" / ")} action — classic ribbon commands can't run it, so it would be dropped; remove the action`,t)}const S=new Set;for(const{el:e}of d)if(e.tagName==="CustomAction")for(const n of Array.from(e.getElementsByTagName("*")))n.getAttribute("Command")===v&&S.add(n.getAttribute("Id")??"");for(const{key:e,el:n}of d){if(n.tagName!=="HideCustomAction")continue;const t=n.getAttribute("Location")??"";!S.has(t)&&!ie({id:t,commandId:v})||i("open-record-hidden",e,`${t} is hidden, but it carries the record open override (${v}) — Unified Interface may then open records as usual or fail to open them; unhide it, or turn the override off`,t,!0)}for(const{key:e,el:n}of R){if(n.getAttribute("Id")!==v)continue;const t=A(n).filter(o=>o.tagName==="DisplayRules").flatMap(o=>A(o).map(r=>r.getAttribute("Id")??r.tagName));if(t.length===0)continue;const a=t.includes("Mscrm.HideOnModern")?Ne.filter(o=>t.includes(o)):[];i("open-record-hidden",e,`${v} has display rules (${t.join(", ")})${a.length>0?` — ${a.join(" + ")} hide its button`:""}: where they hide the "Open record" button, the record open override may stop working; the button must stay shown`,v,!0)}for(const{key:e,el:n}of d)for(const t of Array.from(n.getElementsByTagName("*"))){if(!Oe.has(t.tagName)||A(t).some(o=>o.tagName==="Menu"))continue;const a=t.getAttribute("Id")??"";if(re(t.getAttribute("PopulateDynamically"))){t.getAttribute("PopulateQueryCommand")?.trim()||i("menu-missing",e,`${t.tagName} ${a} is populated dynamically but has no PopulateQueryCommand — its drop-down may stay empty`,a,!0);continue}i("menu-missing",e,`${t.tagName} ${a} has no <Menu> — it would publish as an empty drop-down`,a)}const D=new Set(l.menuControlsIds??[]);for(const{key:e,el:n}of d){const t=n.getAttribute("Location")??"",a=t.endsWith("._children")&&D.has(t.slice(0,-10));for(const o of Array.from(n.getElementsByTagName("*"))){const r=a||!!o.parentElement?.closest("Menu");for(const c of Te){const y=o.getAttribute(c);if(!y?.startsWith("$LocLabels:"))continue;const h=y.slice(11);h.length<=V||i("label-id-length",e,`${o.tagName} ${o.getAttribute("Id")??""} uses label ${h} (${h.length} characters)`+(r?`: a menu item's label id may have at most ${V} characters, or the publish fails after the import — give the control a shorter id`:`: label ids over ${V} characters fail inside menus; consider a shorter control id`),o.getAttribute("Id")??void 0,!r)}}}if(l.known?.commandIds){const e=new Set([...g.commandDefinitions.keys(),...l.known.commandIds]);for(const{key:n,el:t}of d)for(const a of Array.from(t.getElementsByTagName("*")))if(!Q.has(a.tagName))for(const o of["Command","PopulateQueryCommand"]){const r=a.getAttribute(o);if(!r||e.has(r))continue;const c=a.getAttribute("Id")??"";i("undefined-command",n,`${a.tagName} ${c} uses ${o==="Command"?"command":"PopulateQueryCommand"} ${r}, which is defined neither in the customizations nor in the loaded ribbon`,c,Z(r))}}const I={EnableRule:l.known?.enableRuleIds?new Set([...g.enableRules.keys(),...l.known.enableRuleIds]):null,DisplayRule:l.known?.displayRuleIds?new Set([...g.displayRules.keys(),...l.known.displayRuleIds]):null};for(const{key:e,el:n}of R){const t=n.getAttribute("Id")??"",a=A(n).filter(o=>o.tagName==="EnableRules"||o.tagName==="DisplayRules").flatMap(A);for(const o of a){const r=I[o.tagName],c=o.getAttribute("Id");!r||!c||r.has(c)||i("undefined-rule",e,`Command ${t} uses ${o.tagName==="EnableRule"?"enable":"display"} rule ${c}, which is defined neither in the customizations nor in the loaded ribbon`,t,Z(c))}}for(const{part:e,key:n,el:t}of u){if(e!=="enableRules"&&e!=="displayRules")continue;const a=e==="enableRules"?"enable":"display",o=t.getAttribute("Id")??"",r=A(t).flatMap(c=>c.tagName==="OrRule"?A(c).filter(y=>y.tagName==="Or").flatMap(A):[c]);for(const c of r)te(c.tagName,a)&&i("rule-placement",n,`${a==="enable"?"Enable":"Display"} rule ${o} contains ${c.tagName}, which the ribbon schema only allows in ${a==="enable"?"display":"enable"} rules`,o,!0)}const T=new Set;for(const e of Object.values(l.loadedAttributes??{}))for(const n of Object.values(e))K.test(n)&&T.add(n);for(const{key:e,el:n}of u)if(n.tagName!=="LocLabel")for(const t of N(n))for(const a of Array.from(t.attributes)){const o=K.exec(a.value)?.[1];if(!o||g.locLabels.has(o))continue;const r=t.getAttribute("Id")??void 0;r&&l.loadedAttributes?.[r]?.[a.name]===a.value||T.has(a.value)||i("loclabel-missing",e,`${[t.tagName,r,a.name].filter(Boolean).join(" ")} references $LocLabels:${o}, which has no <LocLabel> in these customizations — the text won't resolve unless another solution defines the label`,r,!0)}const w=new Map;for(const{key:e,el:n}of d){const t=n.getAttribute("Location")??"",a=n.getAttribute("Sequence");if(n.tagName!=="CustomAction"||!t.endsWith("._children")||!a)continue;const o=`${t}|${a}`;w.set(o,[...w.get(o)??[],{key:e,id:n.getAttribute("Id")??e}])}for(const[e,n]of w){if(n.length<2||!n.some(o=>p(o.key)))continue;const[t,a]=e.split("|");i("duplicate-sequence",n.map(o=>o.key),`${n.map(o=>o.id).join(" and ")} have the same Sequence (${a}) in ${t} — their order isn't defined; give one another Sequence`,n[0].id,!0)}for(const{key:e,el:n}of u)for(const t of N(n))for(const a of Array.from(t.attributes)){if(a.name!=="Library"&&!J.has(a.name))continue;const o=/^\/?WebResources\/(.+)$/i.exec(a.value.trim())?.[1];o&&i("webresource-path",e,`${t.tagName} ${t.getAttribute("Id")??""} ${a.name} is the path ${a.value} — use $webresource:${o}, the only form that makes the solution depend on the web resource`.replace(/\s+/g," "),t.getAttribute("Id")??void 0,!0)}if(l.webResources){const e=new Set;for(const{el:n}of u)for(const t of N(n))for(const a of Array.from(t.attributes)){const o=ne.exec(a.value.trim())?.[1],r=o?.toLowerCase();if(!o||!r||oe.has(r)||e.has(r))continue;const c=l.webResources[r];if(!c)continue;const y=t.getAttribute("Id")??void 0;c.exists?!c.inSolution&&!c.managed&&(e.add(r),f.push({severity:"warning",code:"webresource-not-in-solution",message:`Web resource ${o} isn't in the selected solution — the ribbon won't import into another environment without it`,elementId:y})):(e.add(r),f.push({severity:"warning",code:"webresource-missing",message:`Web resource ${o} (${t.tagName} ${a.name}) doesn't exist in this environment — ${J.has(a.name)?"the button will show no icon":"the action or rule that loads it will fail when it runs"}`,elementId:y}))}}const C=new Map,L=e=>{let n=C.get(e);return n||C.set(e,n=new Map),n};for(const[e,n]of Object.entries(l.tabScaling??{})){for(const t of n.maxSizes)L(e).set(t.id,{...t,tag:"MaxSize"});for(const t of n.scales)L(e).set(t.id,{...t,tag:"Scale"})}const F=new Map(Object.entries(l.groupTemplates??{}).map(([e,n])=>[e,ee(n)])),z=new Map(Object.entries(l.templateLayouts??{}));for(const{part:e,el:n}of u)if(e==="templates")for(const t of N(n).filter(a=>a.tagName==="GroupTemplate")){const a=A(t).filter(o=>o.tagName==="Layout").map(o=>o.getAttribute("Title")??"");z.set(t.getAttribute("Id")??"",a)}const x=[];for(const{key:e,el:n}of d){for(const r of Array.from(n.getElementsByTagName("Group"))){const c=r.getAttribute("Template");c&&F.set(r.getAttribute("Id")??"",ee(c))}const t=[],a=Y.exec(n.getAttribute("Location")??"")?.[1],o=A(n).find(r=>r.tagName==="CommandUIDefinition");if(a&&o)for(const r of A(o))t.push([a,r]);for(const r of Array.from(n.getElementsByTagName("Tab")))for(const c of A(r).filter(y=>y.tagName==="Scaling"))for(const y of A(c))t.push([r.getAttribute("Id")??"",y]);for(const[r,c]of t){if(c.tagName!=="MaxSize"&&c.tagName!=="Scale")continue;const y={id:c.getAttribute("Id")??"",tag:c.tagName,groupId:c.getAttribute("GroupId")??"",size:c.getAttribute("Size")??"",sequence:parseInt(c.getAttribute("Sequence")??"",10),key:e};L(r).set(y.id,y),x.push(y)}}for(const[e,n]of C){const t=new Map;for(const a of n.values())Number.isNaN(a.sequence)||t.set(a.sequence,[...t.get(a.sequence)??[],a]);for(const[a,o]of t){const r=[...new Set(o.flatMap(h=>h.key?[h.key]:[]))];if(o.length<2||r.length===0)continue;const c=o.find(h=>h.key&&h.tag==="MaxSize"&&h.id===`${h.groupId}.MaxSize`),y=c?`move group ${c.groupId} to another position (its MaxSize takes the group's Sequence; #66 picks a free one automatically)`:"give each step its own Sequence";i("scaling-collision",r,`Scaling of tab ${e}: ${o.map(h=>`${h.tag} ${h.id}`).join(" and ")} have the same Sequence ${a} — Unified Interface then drops every custom control of the table; ${y}`,o.find(h=>h.key)?.id)}}for(const e of x){const n=F.get(e.groupId),t=n?z.get(n):void 0;!t?.length||t.includes(e.size)||i("scaling-size",e.key??[],`${e.tag} ${e.id} has Size "${e.size}", which isn't a layout of template ${n} used by group ${e.groupId} (${t.join(", ")})`,e.id,!0)}const j=new Set(l.known?.elementIds??[]),M=new Map;for(const{key:e,el:n}of d){if(!(n.getAttribute("Location")??"").endsWith("._children"))continue;const t=A(n).find(o=>o.tagName==="CommandUIDefinition"),a=t?A(t)[0]:void 0;if(!(!a||a.tagName==="MaxSize"||a.tagName==="Scale"))for(const o of N(a)){const r=o.getAttribute("Id");if(!r||o.closest("Scaling"))continue;const c=M.get(r)??[];c.includes(e)||M.set(r,[...c,e])}}for(const[e,n]of M)n.length>1?i("duplicate-id",n,`Id ${e} is added by more than one CustomAction (${n.map(t=>t.replace(/^customActions:ca:/,"")).join(", ")})`,e):m.has(n[0])&&j.has(e)&&i("duplicate-id",n,`Id ${e} is added as a new element, but the ribbon already has an element with this id`,e);if(l.places){const{entityLogicalName:e,tabByCollection:n}=l.places,t=new Set(["Mscrm.Tabs",`Mscrm.SubGrid.${e}.ContextualTabs`]);for(const{key:a,el:o}of d){const r=o.getAttribute("Location")??"",c=/^(.+)\._children$/.exec(r)?.[1];if(!c||Y.test(r)||!p(a))continue;const y=A(o).find(k=>k.tagName==="CommandUIDefinition"),h=y?A(y)[0]:void 0,P=h?.getAttribute("Id")??"";if(!h||!P||!(Pe.has(h.tagName)||Q.has(h.tagName)))continue;const B=c.split("{!EntityLogicalName}").join(e),U=n[B];if(U!==void 0){le(U)&&i("orphan-location",a,`${h.tagName} ${P} is added to ${c}, on the tab ${U}: Unified Interface doesn't show that tab and the ribbon doesn't return what is added there, so it won't show anywhere — add it to the table's main tab instead`,P,!0);continue}const G=k=>k.replace(/\.(Controls|Groups)$/,"");t.has(B)||[c,B,G(c),G(B)].some(k=>M.has(k))||i("orphan-location",a,`${h.tagName} ${P} is added at ${r}, but this table's ribbon has no ${c} — it won't show anywhere (check the Location, or move it to an existing group)`,P,!0)}}const _=l.publisherPrefix?.trim().toLowerCase();if(_&&m.size>0){const e=new Set([...j,...l.known?.commandIds??[],...l.known?.enableRuleIds??[],...l.known?.displayRuleIds??[]]),n=o=>{const r=o.split(".");for(let c=r.length;c>0;c--)if(e.has(r.slice(0,c).join(".")))return!0;return!1},t=o=>{const r=o.toLowerCase();return r.startsWith(`${_}.`)||r.startsWith(`${_}_`)},a=new Set;for(const{part:o,key:r,el:c}of u)if(!(!m.has(r)||o==="templates"||o==="tabDisplayRules"))for(const y of N(c)){if(y!==c&&y.closest("Actions, EnableRules, DisplayRules, EnableRule, DisplayRule"))continue;const h=y.getAttribute("Id")??y.getAttribute("HideActionId");!h||a.has(h)||t(h)||n(h)||(a.add(h),f.push({severity:"warning",code:"id-prefix",message:`${y.tagName} id ${h} doesn't start with the publisher prefix "${_}." — ids without it can collide with other solutions`,elementId:h}))}}return f}export{_e as a,qe as v,Be as w};
|
package/dist/icons/icon.svg
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="4 8 56 48" width="56" height="48">
|
|
2
|
-
<!-- Variant
|
|
3
|
-
Same chassis
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<!-- Variant L — "Insider build" / CBS
|
|
3
|
+
Same K chassis + small gold triangle filling the top-right vertex of
|
|
4
|
+
the hex (Microsoft Insiders gold, #FFB900). Shipped for prerelease
|
|
5
|
+
versions (e.g. 0.6.0-beta.1); see the tool-icon plugin in vite.config.ts. -->
|
|
6
6
|
|
|
7
7
|
<path d="M 18 8 L 46 8 L 60 32 L 46 56 L 18 56 L 4 32 Z" fill="#0E5A9C"/>
|
|
8
8
|
<polygon points="46,8 60,32 46,56 18,56" fill="#2B8FD9"/>
|
|
9
9
|
|
|
10
|
+
<!-- Insider stamp — gold triangle in top-right vertex -->
|
|
11
|
+
<polygon points="46,8 40,8 49,15" fill="#FFB900"/>
|
|
12
|
+
|
|
10
13
|
<!-- Tool glyph — command bar with three buttons, in white -->
|
|
11
14
|
<rect x="14" y="23" width="36" height="18" rx="3.5" stroke="#fff" stroke-width="2.5" fill="none"/>
|
|
12
15
|
<rect x="19" y="28.5" width="7" height="7" rx="1.5" fill="#fff"/>
|
package/dist/index.html
CHANGED
|
@@ -4,20 +4,26 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Command Bar Studio</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-6so8O90C.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/monaco-BIO15LCS.js">
|
|
9
|
-
<link rel="modulepreload" crossorigin href="./assets/fluent-icons-
|
|
10
|
-
<link rel="modulepreload" crossorigin href="./assets/fluent-ui-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="./assets/dnd-
|
|
9
|
+
<link rel="modulepreload" crossorigin href="./assets/fluent-icons-CQEhzzaC.js">
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/fluent-ui-BEjALNLO.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="./assets/dnd-C1w9VFfC.js">
|
|
12
12
|
<link rel="stylesheet" crossorigin href="./assets/monaco-DdLsZAcA.css">
|
|
13
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
13
|
+
<link rel="stylesheet" crossorigin href="./assets/index-D5GCH8nj.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
16
16
|
<div id="root">
|
|
17
|
-
<p
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
<p
|
|
18
|
+
style="
|
|
19
|
+
font-family: "Segoe UI", system-ui, sans-serif;
|
|
20
|
+
padding: 24px;
|
|
21
|
+
max-width: 720px;
|
|
22
|
+
"
|
|
23
|
+
>
|
|
24
|
+
Loading Command Bar Studio… If this message stays, the tool couldn't start: use
|
|
25
|
+
Power Platform ToolBox 1.2.7 or later (desktop app or VS Code extension), and report
|
|
26
|
+
it at github.com/mohsinonxrm/pptb-mxrm-commandbar-studio/issues.
|
|
21
27
|
</p>
|
|
22
28
|
</div>
|
|
23
29
|
</body>
|
package/index.html
CHANGED
|
@@ -7,10 +7,16 @@
|
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
<div id="root">
|
|
10
|
-
<p
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
<p
|
|
11
|
+
style="
|
|
12
|
+
font-family: "Segoe UI", system-ui, sans-serif;
|
|
13
|
+
padding: 24px;
|
|
14
|
+
max-width: 720px;
|
|
15
|
+
"
|
|
16
|
+
>
|
|
17
|
+
Loading Command Bar Studio… If this message stays, the tool couldn't start: use
|
|
18
|
+
Power Platform ToolBox 1.2.7 or later (desktop app or VS Code extension), and report
|
|
19
|
+
it at github.com/mohsinonxrm/pptb-mxrm-commandbar-studio/issues.
|
|
14
20
|
</p>
|
|
15
21
|
</div>
|
|
16
22
|
<script type="module" src="/src/main.tsx"></script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mohsinonxrm/pptb-commandbar-studio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-beta.1",
|
|
4
4
|
"displayName": "Command Bar Studio",
|
|
5
5
|
"description": "Visual designer for Dataverse classic ribbon / command bar customizations — the spiritual successor to Ribbon Workbench, built for Power Platform ToolBox",
|
|
6
6
|
"author": "Mohsin On xRM",
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import{y as n,z as Pn}from"./fluent-icons-BqJj6rDi.js";import{p as je,m as Yn,g as Jn,n as Oe,o as Zn,q as Qn,r as es,t as ns,v as ss,x as Ke,y as ts,z as os,A as is,B as as,d as Se,D as rs,F as ls,G as cs,H as bn,I as ds,J as us,K as Xe,L as hs,M as ms,N as X,O as Nn,k as _e,P as Ie,Q as ps,R as bs,S as fn,T as fs,U as Ve,V as gs,W as gn,X as ys,Y as Dn,Z as K,_ as An,$ as ws,a0 as Fe,a1 as xs,a as Be,u as D,a2 as Cs,a3 as vs,a4 as js,a5 as yn}from"./index-Di2_5czx.js";import{a as A,R as se}from"./monaco-BIO15LCS.js";import{w as Rs,v as En}from"./xmlValidator-BkeotXuB.js";import{M as U,f as O,ae as Ss,b as F,B as Tn,F as Re,I as Ln,t as E,D as Is,i as $s,j as ks,k as Ps,l as Ns,a5 as Ds,ao as As,O as wn,an as Es,a1 as Ts,a6 as Ls,d as qe,ap as zs,m as Ms}from"./fluent-ui-QADO660t.js";import"./dnd-Cq8OftAq.js";import"./ruleKinds-B9hACGaq.js";import"./crmParameters-rgfZhhzN.js";let xn=0;async function He(e){const t=typeof window<"u"?window.toolboxAPI:void 0;xn++===0&&await Cn(()=>t?.preventClose?.());try{return await e()}finally{--xn===0&&await Cn(()=>t?.releasePreventClose?.())}}const Us=2e3;async function Cn(e){let t;try{await Promise.race([e(),new Promise(o=>t=setTimeout(o,Us))])}catch{}finally{clearTimeout(t)}}function me(e,t){const o=e.match(new RegExp(`\\s${t}="([^"]*)"`));return o?o[1]:null}function vn(e,t,o){const r=e.indexOf(o,t);return e.slice(t,r===-1?void 0:r).match(/<result\s[^>]*>/g)??[]}function jn(e){const t=e.find(o=>me(o,"result")!=="success");if(t){const o=me(t,"errorcode")??"",r=me(t,"errortext")??"unknown error";return{ok:!1,message:`Dataverse rejected the ribbon (${o}): ${r}`}}return null}function Os(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 i=e.search(/<ribbon\s[^>]*processed="true"/);return i===-1?{ok:!1,message:"Import completed, but Dataverse did not process the application ribbon."}:jn(vn(e,i,"</ribbon>"))??{ok:!0,message:"Application ribbon imported."}}const o=new Set(t.names.filter(Boolean).map(i=>i.toLowerCase())),r=/<entityRibbon\s[^>]*>/g;let a;for(;a=r.exec(e);){const i=(me(a[0],"id")??"").toLowerCase();if(o.has(i))return me(a[0],"processed")!=="true"?{ok:!1,message:`Dataverse did not process the ribbon for ${i}.`}:jn(vn(e,a.index,"</entityRibbon>"))??{ok:!0,message:`Ribbon for ${i} imported.`}}return{ok:!1,message:`Import completed, but Dataverse did not apply a ribbon for ${t.names.join(" / ")} (no entityRibbon result in the import job). Nothing was changed.`}}const J=window.dataverseAPI;async function Xs(e,t,o){return await o("The import"),J.execute({operationName:"ImportSolution",operationType:"action",parameters:{CustomizationFile:e,ImportJobId:t,OverwriteUnmanagedCustomizations:!0,PublishWorkflows:!1}})}async function Vs(e,t){await t("Publishing");const o=e.map(r=>`<entity>${X(r)}</entity>`).join("");return J.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:`<importexportxml><entities>${o}</entities></importexportxml>`}})}function Rn(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 Bs(e){const t=e.titles.map(o=>`<Title languagecode="${o.languageCode}" description="${X(o.description)}"/>`).join("");return`<LocLabel Id="${X(e.id)}"><Titles>${t}</Titles></LocLabel>`}async function zn(e){const t=e.entity?.logicalName??"{!EntityLogicalName}",o={deletedContainerIds:e.plan.deletedContainerIds??[],movedButtons:e.plan.movedButtons??[],editedLocLabelIds:e.plan.editedLocLabelIds??[],editedTabIds:e.plan.editedTabIds??[],resequencedTabs:e.plan.resequencedTabs??[]},r=e.locLabels.filter(l=>o.editedLocLabelIds.includes(l.id)),a=e.languageCode??1033;for(const l of e.plan.renamedLabels??[]){const m=r.find(I=>I.id===l.id)??e.locLabels.find(I=>I.id===l.id),R=[{languageCode:a,description:l.text},...(m?.titles??[]).filter(I=>I.languageCode!==a)],y=r.findIndex(I=>I.id===l.id);y>=0?r[y]={id:l.id,titles:R}:r.push({id:l.id,titles:R})}let i=r.length?je(`<RibbonDiffXml><LocLabels>${r.map(Bs).join("")}</LocLabels></RibbonDiffXml>`):Yn();for(const l of e.locations){const m=Jn({current:l.current,baseline:l.baseline,commands:e.commands,enableRules:e.enableRules,displayRules:e.displayRules,locLabels:e.locLabels,entityLogicalName:t,location:l.current.location,languageCode:e.languageCode});i=Oe(i,je(m))}const d=[],u=[];for(const l of e.locations)for(const m of l.current.tabs){if(!o.editedTabIds.includes(m.id))continue;if(m.tabDisplayRules.length>0){const y=Zn(m,e.entity===null);y&&u.push(y)}const R=new Set(m.tabDisplayRules.map(y=>y.tabCommand));for(const y of l.baseline.tabs.find(I=>I.id===m.id)?.tabDisplayRules??[])R.has(y.tabCommand)||d.push(y.tabCommand)}u.length>0&&(i=Oe(i,je(`<RibbonDiffXml><RuleDefinitions><TabDisplayRules>${u.join("")}</TabDisplayRules></RuleDefinitions></RibbonDiffXml>`)));const f=[...e.commands.filter(l=>e.plan.editedCommandIds.includes(l.id)).map(Qn)],$={enable:e.enableRules.filter(l=>e.plan.editedEnableRuleIds.includes(l.id)).map(ns),display:e.displayRules.filter(l=>e.plan.editedDisplayRuleIds.includes(l.id)).map(es)};(f.length||$.enable.length||$.display.length)&&(i=Oe(i,je(`<RibbonDiffXml><CommandDefinitions>${f.join("")}</CommandDefinitions><RuleDefinitions><DisplayRules>${$.display.join("")}</DisplayRules><EnableRules>${$.enable.join("")}</EnableRules></RuleDefinitions></RibbonDiffXml>`)));const S=(l,m)=>{for(const R of Array.from(l.keys()))m.includes(R)||l.delete(R)},v=e.locations.flatMap(l=>l.current.tabs.filter(m=>!l.baseline.tabs.some(R=>R.id===m.id)).map(ss));S(i.commandDefinitions,[...e.plan.editedCommandIds,...v]),S(i.enableRules,e.plan.editedEnableRuleIds),S(i.displayRules,e.plan.editedDisplayRuleIds);const h=await Ke(e.entity?.logicalName??null),C=ts(h),b=e.plan.deletedButtonIds.filter(l=>!C.has(l));if(b.length>0)throw new Error(`Can't delete ${b.join(", ")}: not defined in this table's unmanaged customizations (it comes from a managed solution or the platform). Undo the delete and hide the button instead.`);const w=os(h),P=o.deletedContainerIds.filter(l=>!w.has(l));if(P.length>0)throw new Error(`Can't delete ${P.join(", ")}: not added by this table's unmanaged customizations (it comes from a managed solution or the platform). Undo the delete.`);const j=o.movedButtons.filter(l=>!C.has(l.id)).map(l=>l.id);if(j.length>0)throw new Error(`Can't move ${j.join(", ")}: not defined in this table's unmanaged customizations. Undo the move.`);const W=is(h),Z=(e.plan.uncustomisedCommandIds??[]).filter(l=>h.commandDefinitions.has(l)&&!as(l,W));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 _=new Set;for(const l of e.locations)for(const m of l.current.tabs)for(const R of m.groups)for(const y of Se(R))for(const I of rs(y))_.add(I);const Q=e.plan.uncustomisedCommandIds??[],Y=new Set,ee=new Set;for(const l of e.commands)if(!(!_.has(l.id)||Q.includes(l.id))){l.enableRules.forEach(m=>Y.add(m)),l.displayRules.forEach(m=>ee.add(m));for(const m of l.rawRuleRefs??[]){const R=/^\s*<(EnableRule|DisplayRule)\b[^>]*?\sId="([^"]+)"/.exec(m.xml);R&&(R[1]==="EnableRule"?Y:ee).add(R[2])}}let k=ls(h,i,{retainedCommandIds:_,editedCommandIds:e.plan.editedCommandIds,editedEnableRuleIds:e.plan.editedEnableRuleIds,editedDisplayRuleIds:e.plan.editedDisplayRuleIds,deletedControlIds:e.plan.deletedButtonIds,unhiddenControlIds:e.plan.unhiddenButtonIds,deletedContainerIds:o.deletedContainerIds,movedControls:o.movedButtons,resequencedContainers:o.resequencedTabs,removedTabCommands:d,uncustomisedCommandIds:Q,retainedEnableRuleIds:Y,retainedDisplayRuleIds:ee});for(const l of e.plan.renamedLabels??[])l.newLabel&&(k=cs(k,l.containerId,`$LocLabels:${l.id}`));const c=new Set([...bn(h),...bn(k)].map(l=>l.id)),g={};for(const l of e.locations)for(const[m,R]of Object.entries(l.baseline.scalingByTab??{}))g[m]={maxSizes:R.maxSizes.filter(y=>!c.has(y.id)).map(y=>y.sequence),scales:R.scales.filter(y=>!c.has(y.id)).map(y=>y.sequence)};const L=ds(k,g);if(L.problems.length>0)throw new Error(`Not published: ${L.problems.join("; ")}.`);return k=L.parts,{scalingChanges:L.changes,xml:hs(k),parts:k,elementCount:Xe(k),preservedCount:Xe(h),changedCount:Xe(i),changedKeys:us(h,k),newKeys:Object.keys(k).flatMap(l=>Array.from(k[l].keys()).filter(m=>!h[l].has(m)).map(m=>`${l}:${m}`)),layerDefinitionIds:{commandIds:Array.from(h.commandDefinitions.keys()),enableRuleIds:Array.from(h.enableRules.keys()),displayRuleIds:Array.from(h.displayRules.keys())},layer:h}}function Mn(e,t){const o=[],r={},a={},i={},d={},u=new Set,f=new Set,$=new Set;for(const{current:h,baseline:C}of e.locations)for(const b of[C,h])for(const w of b.tabs)for(const P of w.groups)for(const j of Se(P))for(const W of j.menu?.sections??[])$.add(W.controlsId);for(const{current:h,baseline:C}of e.locations){Object.assign(i,C.templateLayouts);for(const b of C.tabs){o.push(b.id),b.label&&(d[b.id]={Title:b.label});for(const w of b.groups){u.add(w.id),o.push(w.id),w.label&&(d[w.id]={Title:w.label,Label:w.label});for(const P of Se(w))o.push(P.id),P.source&&(d[P.id]=P.source.attributes)}}for(const b of h.tabs)for(const w of b.groups)f.add(w.id);for(const b of[C,h])for(const w of b.tabs)for(const P of w.groups)P.template&&(a[P.id]=P.template)}const S=h=>u.has(h.groupId)&&!f.has(h.groupId);for(const{baseline:h}of e.locations)for(const[C,b]of Object.entries(h.scalingByTab??{}))r[C]={...b,maxSizes:b.maxSizes.filter(w=>!S(w)),scales:b.scales.filter(w=>!S(w))};const v=(h,C)=>{if(!h)return;const b=new Set(C??[]);return h.map(w=>w.id).filter(w=>!b.has(w))};return{changedKeys:t.changedKeys,newKeys:t.newKeys,commands:e.commands,known:{commandIds:v(e.baselineCommands,t.layerDefinitionIds?.commandIds),enableRuleIds:v(e.baselineEnableRules,t.layerDefinitionIds?.enableRuleIds),displayRuleIds:v(e.baselineDisplayRules,t.layerDefinitionIds?.displayRuleIds),elementIds:o},loadedAttributes:d,publisherPrefix:e.publisherPrefix,tabScaling:r,groupTemplates:a,templateLayouts:i,menuControlsIds:$,...e.entity?{places:{entityLogicalName:e.entity.logicalName,tabByCollection:Object.fromEntries(ms(e.locations.map(h=>h.baseline),e.entity.logicalName))}}:{}}}function qs(e,t){return new Promise((o,r)=>{const a=setTimeout(()=>r(new Error(`it didn't finish within ${Math.round(t/1e3)} s`)),t);e.then(i=>{clearTimeout(a),o(i)},i=>{clearTimeout(a),r(i)})})}async function Sn(e,t={}){const o=await zn(e),r=Mn(e,o),a=[],i=Rs(o.parts);if(t.lookupWebResources&&i.length>0)try{r.webResources=await t.lookupWebResources(i)}catch(d){a.push({severity:"warning",code:"webresource-lookup",message:`Couldn't check the ${i.length} referenced web resource(s): ${d instanceof Error?d.message:String(d)}`})}return{findings:[...En(o.parts,r),...a],xml:o.xml}}async function Fs(e,t,o={}){const r=o.attempts??3,a=o.contentKeys??[];let i={missing:[],unexpected:[],differing:[]};for(let u=0;u<r;u++){u>0&&await new Promise(f=>setTimeout(f,o.delayMs??5e3));try{i=Dn(t,await Ke(e),{contentKeys:a})}catch(f){return{ok:!1,missing:[],unexpected:[],differing:[],message:`Couldn't read the published ribbon layer to verify it (${f instanceof Error?f.message:String(f)}).`}}if(i.missing.length===0&&i.unexpected.length===0&&i.differing.length===0){const f=a.length;return{ok:!0,...i,message:"Verified: the published ribbon layer has every element that was imported"+(f>0?`, and the ${f} element(s) this publish changed have the imported content.`:".")}}}const d=u=>u.slice(0,5).join(", ")+(u.length>5?", …":"");return{ok:!1,...i,message:"The published ribbon layer doesn't match what was imported"+(i.missing.length?`; missing: ${d(i.missing)}`:"")+(i.unexpected.length?`; unexpected: ${d(i.unexpected)}`:"")+(i.differing.length?`; different content: ${d(i.differing)}`:"")+". Reload the table and check before publishing again."}}class We extends Error{constructor(t,o,r=!1){const a=r?"another solution import ran in the environment meanwhile, and what it changed may not be published yet":Un(o);super(r?`${t}'s ribbon customizations may have changed in Dataverse since you started publishing: ${a}. Importing could overwrite that change, so nothing was imported. Publish again: the table is published first, so the change is kept.`:`${t}'s ribbon customizations changed in Dataverse since you started publishing (${a}): other ribbon changes for it were published meanwhile, from another session, tool or solution import. Importing would overwrite that change, so nothing was imported. Reload the table to get the change, then publish again.`),this.scopeLabel=t,this.changes=o,this.importRan=r,this.name="RibbonLayerChangedError",this.summary=a}scopeLabel;changes;importRan;summary}function Un(e){const t=o=>o.slice(0,5).join(", ")+(o.length>5?", …":"");return[e.unexpected.length?`added: ${t(e.unexpected)}`:"",e.missing.length?`removed: ${t(e.missing)}`:"",e.differing.length?`changed: ${t(e.differing)}`:""].filter(Boolean).join("; ")}function Ws(e){const t=e instanceof Error?e.message:String(e);return/there is (?:another|a previous) \[(\w+)\] running/i.exec(t)?.[1]??null}const Ks=e=>Object.keys(e).flatMap(t=>Array.from(e[t].keys()).map(o=>`${t}:${o}`));function On(e,t){const o=[],r=[],a=[];for(const i of Object.keys(e)){for(const[d,u]of e[i]){const f=t[i].get(d);f===void 0?o.push(`${i}:${d}`):f!==u&&a.push(`${i}:${d}`)}for(const d of t[i].keys())e[i].has(d)||r.push(`${i}:${d}`)}return{missing:o,unexpected:r,differing:a}}const Xn=e=>e.missing.length+e.unexpected.length+e.differing.length>0;async function _s(e,t,o,r){const a=r.kind==="imported"?r.attempts??3:1;let i={missing:[],unexpected:[],differing:[]};for(let d=0;d<a;d++){d>0&&r.kind==="imported"&&await new Promise(f=>setTimeout(f,r.delayMs??5e3));const u=await Ke(e);if(i=r.kind==="read"?On(o,u):Dn(o,u,{contentKeys:Ks(o)}),!Xn(i))return}throw new We(t,i)}function In(e,t){return He(()=>Hs(e,t)).finally(()=>Nn({afterPublish:!0}))}async function Hs(e,t){const o=e.guard??_e(),r=Ie.getState(),a=e.entity?e.entity.logicalName:"Application ribbon",i={onProgress:t,...e.busy},d=e.entity===null;if(d&&!e.ribbonCustomizationIds?.length)throw new Error("The selected solution does not contain Application Ribbons. Add it in make.powerapps.com (Solutions → your solution → Add existing → Application Ribbons) and reload the solution.");const u=async(c="Publishing customizations…")=>{t?.(c),await gn("Publish",async()=>{d?(await o("Publishing"),await J.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:"<importexportxml><ribbons><ribbon></ribbon></ribbons></importexportxml>"}})):await Vs([e.entity.logicalName],o)},i)},f=e.languageCode??await ps(),$=async c=>{t?.(`Reading existing ribbon customizations for ${a}…`),c&&r.logInfo("publish",`Reading unmanaged ribbon layer for ${a}.`);const g=await zn({...e,languageCode:f}),L=En(g.parts,Mn({...e,publisherPrefix:e.solution.publisherPrefix},g)),l=L.filter(m=>m.severity==="error");if(c||l.length>0){r.logInfo("publish",`RibbonDiffXml for ${a}: ${g.preservedCount} existing element(s) preserved, ${g.changedCount} element(s) from this session, ${g.elementCount} total.`);for(const m of g.scalingChanges)r.logWarn("publish",gs(m));for(const m of L)m.severity==="warning"&&r.logWarn("publish",m.message)}if(l.length>0){for(const m of l)r.logError("publish",m.message);throw new Error(`The pre-publish check found ${l.length} error(s), so nothing was imported: `+l.map(m=>m.message).join("; "))}return g},S=e.publishCustomizations!==!1?await $(!1):null;t?.("Checking that no other solution operation is running…"),await bs(i);const v=await Js(e.solution);let h=!1;const C=c=>(S&&!h&&c instanceof Error&&(c.message+=` (${a} was published first, so customizations imported elsewhere for it and not yet published are now published.)`),c);if(S){r.logInfo("publish",`Publishing ${a} first, so ribbon changes imported elsewhere but not yet published are kept.`);try{await u(`Publishing ${a} first (keeps changes imported elsewhere but not published)…`)}catch(c){throw c instanceof Error&&(c.message=`Publishing ${a} first failed, so nothing was imported: ${c.message}`),c}}let b;try{b=await $(!0)}catch(c){throw S&&c instanceof Error&&!c.message.startsWith("The pre-publish check")&&(c.message=`${a}'s customizations changed when it was published first (changes imported elsewhere and not yet published): ${c.message} Reload the table to get them, then publish again.`),C(c)}if(S){const c=On(S.layer,b.layer);Xn(c)&&r.logInfo("publish",`Publishing ${a} first published ribbon changes imported elsewhere (${Un(c)}); they are kept.`)}const w=e.entity?.schemaName||e.entity?.logicalName||"",P=d?fn({applicationRibbonDiffXml:b.xml}):fn({entities:[{schemaName:w,localizedName:e.entity?.displayName||w,ribbonDiffXml:b.xml}]}),j=d?[{type:50,schemaName:":RibbonDiffXml",behavior:0}]:[{type:1,schemaName:e.entity.logicalName,behavior:2}],W=et({...e.solution,languageCode:f,rootComponents:j,details:v});t?.("Packaging solution ZIP…");const Z=fs({"customizations.xml":Ve(P),"solution.xml":Ve(W),"[Content_Types].xml":Ve('<?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 _="";for(let c=0;c<Z.length;c++)_+=String.fromCharCode(Z[c]);const Q=btoa(_),Y=async(c,g)=>{t?.(`Importing ${a} ribbon${c}…`);const L=crypto.randomUUID();r.logInfo("publish",`Importing solution${c} (import job ${L})…`);let l=!1;await gn("Import",async()=>{if(await o("Importing"),l)throw new We(a,{missing:[],unexpected:[],differing:[]},!0);await _s(e.entity?.logicalName??null,a,g.layer,g.as);try{await Xs(Q,L,o)}catch(N){throw ys(N)&&Ws(N)?.toLowerCase()==="import"&&(l=!0),N}h=!0},i);const m=150,R=2e3;let y=await J.getImportJobStatus(L),I=0;for(;!Rn(y)&&I<m;)await new Promise(N=>setTimeout(N,R)),y=await J.getImportJobStatus(L),I++,I%10===0&&t?.(`Still importing… (${I*2}s elapsed)`);if(!Rn(y))throw new Error(`Solution import did not complete within ${m*R/1e3} seconds. Check Solutions › History for import job ${L}.`);t?.("Verifying the import…");const $e=await J.retrieve("importjob",L,["data"]),B=Os($e.data,d?{kind:"application"}:{kind:"entity",names:[w,e.entity.logicalName]});if(!B.ok)throw r.logError("publish",B.message),new Error(B.message);return r.logInfo("publish",B.message),L};let ee;try{ee=await Y("",{layer:b.layer,as:{kind:"read"}})}catch(c){throw C(c)}let k;if(e.publishCustomizations!==!1){await u();{r.logInfo("publish","Refreshing Unified Interface command-bar metadata (second import of the same package)…");try{await Y(" (refreshing Unified Interface metadata)",{layer:b.parts,as:{kind:"imported",delayMs:e.verifyDelayMs}}),await u()}catch(c){if(c instanceof We)k={ok:!1,...c.changes,message:`Your changes were imported and published, but ${a}'s ribbon customizations changed in Dataverse after that (${c.summary}): other changes were published meanwhile. They weren't imported a second time to refresh Unified Interface's command-bar metadata, since that would overwrite the other change, so new or changed buttons may not appear in the app until the table's ribbon is published again. Reload the table to see the other change.`},r.logWarn("publish",k.message);else throw new Error(`Your changes were imported and published, but refreshing Unified Interface's command-bar metadata failed (${c instanceof Error?c.message:String(c)}). New or changed buttons may not appear in the app until you publish again.`)}}k||(t?.("Verifying the published ribbon…"),k=await Fs(e.entity?.logicalName??null,b.parts,{delayMs:e.verifyDelayMs,contentKeys:b.changedKeys}),k.ok?r.logInfo("publish",k.message):r.logWarn("publish",k.message))}else r.logWarn("publish","Imported without publishing. New or changed buttons appear in Unified Interface only after you publish from Command Bar Studio (which re-imports once to refresh the command-bar metadata).");return t?.(e.publishCustomizations!==!1?`${a} ribbon published.`:`${a} ribbon imported (not published).`),{elementCount:b.elementCount,preservedCount:b.preservedCount,importJobId:ee,verification:k,parts:b.parts,changedKeys:b.changedKeys}}function Gs(e,t){return He(()=>Ys(e,t)).finally(()=>Nn({afterPublish:!0}))}async function Ys(e,t){const o=t?.guard??_e(),r=Ie.getState(),a=t?.pollIntervalMs??2e3,i=t?.timeoutMs??600*1e3;e?.("Starting asynchronous publish (PublishAllXmlAsync)..."),r.logInfo("publish","Calling PublishAllXmlAsync action."),await o("Publishing");const u=(await J.execute({operationName:"PublishAllXmlAsync",operationType:"action"}))?.AsyncOperationId;if(!u)throw new Error("PublishAllXmlAsync did not return AsyncOperationId.");r.logInfo("publish",`PublishAllXmlAsync job id: ${u}`),e?.("Async publish job started. Waiting for completion...");const f=Date.now();let $=0,S;for(;Date.now()-f<i;){$+=1;const v=await J.retrieve("asyncoperation",u,["asyncoperationid","statecode","statuscode","name","message","friendlymessage","completedon"]);if(S=v.statuscode,v.statecode===3||!!v.completedon){if(typeof v.statuscode=="number"&&v.statuscode!==30){const C=v.friendlymessage||v.message||`statuscode=${v.statuscode}`;throw new Error(`Asynchronous publish failed: ${C}`)}return e?.("Asynchronous publish completed successfully."),r.logInfo("publish",`PublishAllXmlAsync completed in ${$} poll(s).`),{asyncOperationId:u,statusCode:v.statuscode}}e?.(`Waiting for async publish job... (poll ${$})`),await new Promise(C=>setTimeout(C,a))}throw new Error(`Asynchronous publish timed out after ${Math.round(i/1e3)} seconds (last status: ${S??"unknown"}).`)}const Vn=[["AddressTypeCode","addresstypecode"],["City","city"],["County","county"],["Country","country"],["Fax","fax"],["FreightTermsCode","freighttermscode"],["Latitude","latitude"],["Line1","line1"],["Line2","line2"],["Line3","line3"],["Longitude","longitude"],["Name","name"],["PostalCode","postalcode"],["PostOfficeBox","postofficebox"],["PrimaryContactName","primarycontactname"],["ShippingMethodCode","shippingmethodcode"],["StateOrProvince","stateorprovince"],["Telephone1","telephone1"],["Telephone2","telephone2"],["Telephone3","telephone3"],["UPSZone","upszone"],["UTCOffset","utcoffset"],["UTCConversionTimeZoneCode","utcconversiontimezonecode"]];async function Js(e){let t;try{t=(await J.queryData(`solutions?$select=description&$expand=publisherid&$filter=uniquename eq '${e.uniqueName.replace(/'/g,"''")}'`)).value?.[0]}catch(d){throw new Error(`Couldn't read solution ${e.uniqueName} and its publisher (${d instanceof Error?d.message:String(d)}), so nothing was imported: an import without them would clear the publisher's details.`)}const o=t?.publisherid;if(!t||!o)throw new Error(`Couldn't read solution ${e.uniqueName} and its publisher, so nothing was imported: an import without them would clear the publisher's details.`);const r=o.customizationoptionvalueprefix;if(typeof r!="number")throw new Error(`Couldn't read the option-value prefix of publisher ${e.publisherUniqueName}, so nothing was imported: a wrong one would change the publisher.`);const a=d=>typeof d=="string"?d:"",i=[1,2].map(d=>Object.fromEntries(Vn.map(([,u])=>[u,o[`address${d}_${u}`]]).filter(([,u])=>u!=null&&u!==""))).map((d,u)=>({number:u+1,...d}));return{solutionDescription:a(t.description),publisherDescription:a(o.description),publisherEmail:a(o.emailaddress),publisherWebsite:a(o.supportingwebsiteurl),publisherOptionValuePrefix:r,publisherAddresses:i.filter(d=>Object.keys(d).length>1)}}const Zs=e=>X(e).replace(/\r/g,"
").replace(/\n/g,"
").replace(/\t/g,"	"),$n=(e,t)=>e?`<Descriptions>
|
|
2
|
-
<Description description="${Zs(e)}" languagecode="${t}"/>
|
|
3
|
-
</Descriptions>`:"<Descriptions/>",Qs=e=>e.length===0?"<Addresses/>":`<Addresses>${e.map(t=>`
|
|
4
|
-
<Address>
|
|
5
|
-
<AddressNumber>${t.number}</AddressNumber>${Vn.filter(([,o])=>o in t).map(([o,r])=>`
|
|
6
|
-
<${o}>${X(String(t[r]))}</${o}>`).join("")}
|
|
7
|
-
</Address>`).join("")}
|
|
8
|
-
</Addresses>`;function et(e){const t=e.publisherUniqueName?.trim()||"DefaultPublisher",o=e.publisherName?.trim()||t,r=e.publisherPrefix?.trim()||"new",a=e.languageCode||1033,i=e.friendlyName?.trim()||e.uniqueName,d=e.rootComponents.length===0?"<RootComponents/>":`<RootComponents>
|
|
9
|
-
${e.rootComponents.map(u=>{const f=[`type="${u.type}"`];return u.schemaName&&f.push(`schemaName="${X(u.schemaName)}"`),u.id&&f.push(`id="{${X(u.id)}}"`),f.push(`behavior="${u.behavior}"`),`<RootComponent ${f.join(" ")} />`}).join(`
|
|
10
|
-
`)}
|
|
11
|
-
</RootComponents>`;return`<?xml version="1.0" encoding="utf-8"?>
|
|
12
|
-
<ImportExportXml version="9.1.0.0" SolutionPackageVersion="9.1" languagecode="${a}" generatedBy="CommandBarStudio">
|
|
13
|
-
<SolutionManifest>
|
|
14
|
-
<UniqueName>${X(e.uniqueName)}</UniqueName>
|
|
15
|
-
<LocalizedNames>
|
|
16
|
-
<LocalizedName description="${X(i)}" languagecode="${a}"/>
|
|
17
|
-
</LocalizedNames>
|
|
18
|
-
${$n(e.details.solutionDescription,a)}
|
|
19
|
-
<Version>${X(e.version)}</Version>
|
|
20
|
-
<Managed>0</Managed>
|
|
21
|
-
<Publisher>
|
|
22
|
-
<UniqueName>${X(t)}</UniqueName>
|
|
23
|
-
<LocalizedNames>
|
|
24
|
-
<LocalizedName description="${X(o)}" languagecode="${a}"/>
|
|
25
|
-
</LocalizedNames>
|
|
26
|
-
${$n(e.details.publisherDescription,a)}
|
|
27
|
-
<EMailAddress>${X(e.details.publisherEmail)}</EMailAddress>
|
|
28
|
-
<SupportingWebsiteUrl>${X(e.details.publisherWebsite)}</SupportingWebsiteUrl>
|
|
29
|
-
<CustomizationPrefix>${X(r)}</CustomizationPrefix>
|
|
30
|
-
<CustomizationOptionValuePrefix>${e.details.publisherOptionValuePrefix}</CustomizationOptionValuePrefix>
|
|
31
|
-
${Qs(e.details.publisherAddresses)}
|
|
32
|
-
</Publisher>
|
|
33
|
-
${d}
|
|
34
|
-
<MissingDependencies/>
|
|
35
|
-
</SolutionManifest>
|
|
36
|
-
</ImportExportXml>`}const nt=Pn({root:{display:"flex",flexDirection:"column",gap:E.spacingVerticalS},box:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:E.spacingHorizontalM,rowGap:E.spacingVerticalXS,padding:`${E.spacingVerticalS} ${E.spacingHorizontalM}`,backgroundColor:E.colorNeutralBackground3,borderRadius:E.borderRadiusMedium},label:{color:E.colorNeutralForeground3},value:{display:"flex",flexWrap:"wrap",alignItems:"center",columnGap:E.spacingHorizontalS,minWidth:0},secondary:{color:E.colorNeutralForeground3,wordBreak:"break-all"}});function st({rows:e,confirmWord:t,onConfirmationChange:o,disabled:r}){const a=nt(),[i,d]=A.useState({status:"loading"}),[u,f]=A.useState(""),$=K(j=>j.environment),S=K(j=>j.connectionUrl),v=K(j=>j.connectionVersion);A.useEffect(()=>{let j=!0;return d({status:"loading"}),An().then(W=>j&&d({status:"ready",connection:W})).catch(()=>j&&d({status:"ready",connection:null})),()=>{j=!1}},[$,S,v]);const h=i.status==="ready"?i.connection:null,C=ws(h?.environment),b=i.status==="ready"&&Fe(h?.environment),w=i.status==="ready"&&(!b||xs(u,t)),P=h?.environment;return A.useEffect(()=>{o(w,P)},[w,P,o]),n.jsxs("div",{className:a.root,children:[C&&n.jsx(U,{intent:"warning",children:n.jsxs(O,{children:[n.jsx(Ss,{children:"Production environment"}),"This changes the live environment."]})}),n.jsxs("div",{className:a.box,children:[n.jsx(F,{className:a.label,children:"Environment"}),n.jsx("div",{className:a.value,children:i.status==="loading"?n.jsx(F,{children:"Reading the connection…"}):h?n.jsxs(n.Fragment,{children:[n.jsx(F,{weight:"semibold",children:h.name}),h.environment&&n.jsx(Tn,{size:"small",appearance:C?"filled":"tint",color:C?"warning":"informative",children:h.environment}),n.jsx(F,{size:200,className:a.secondary,children:h.url})]}):n.jsx(F,{children:"Unknown (the tool has no connection)"})}),e.map(j=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx(F,{className:a.label,children:j.label}),n.jsx("div",{className:a.value,children:j.value})]},j.label))]}),b&&n.jsx(Re,{label:n.jsxs(n.Fragment,{children:["Type ",n.jsx("strong",{children:t})," to confirm"]}),hint:"Required on a Production environment.",children:n.jsx(Ln,{value:u,onChange:(j,W)=>f(W.value),disabled:r,autoComplete:"off","aria-label":`Type ${t} to confirm`})})]})}const tt=Pn({content:{display:"flex",flexDirection:"column",gap:E.spacingVerticalM},progressList:{display:"flex",flexDirection:"column",gap:E.spacingVerticalXS},progressRow:{display:"flex",alignItems:"center",gap:E.spacingHorizontalS}}),kn=({findings:e,showScope:t})=>n.jsx("ul",{style:{margin:`${E.spacingVerticalXS} 0 0`,paddingLeft:20},children:e.map((o,r)=>n.jsxs("li",{children:[t&&n.jsxs("strong",{children:[o.scope,": "]}),o.message]},r))}),de=["HomepageGrid","SubGrid","Form"],ot=3e4,mt=()=>{const e=tt(),t=Be(s=>s.bulkPublishOpen),o=Be(s=>s.closeBulkPublish),r=Be(s=>s.openXmlDrawer),a=D(s=>s.ribbons),i=D(s=>s.baseline),d=D(s=>s.commands),u=D(s=>s.displayRules),f=D(s=>s.enableRules),$=D(s=>s.baselineCommands),S=D(s=>s.baselineEnableRules),v=D(s=>s.baselineDisplayRules),h=D(s=>s.locLabels),C=D(s=>s.baselineLocLabels),b=D(s=>s.layers),w=D(s=>s.pendingUnhides),P=D(s=>s.orphans),j=D(s=>s.pendingOrphanDeletes),W=D(s=>s.customisedCommandIds),Z=D(s=>s.uncustomisedCommandIds),_=D(s=>s.baseLanguageCode),Q=D(s=>s.baseLanguageUnknown),Y=D(s=>s.setLayerSnapshot),ee=D(s=>s.markPublished),k=D(s=>s.mutationsSincePublish),c=K(s=>s.activeSolution),g=K(s=>s.activeEntity),L=K(s=>s.connectionUrl),l=K(s=>s.publisherPrefix),m=K(s=>s.solutionRibbonComponentIds),R=Array.isArray(m)&&m.length>0,[y,I]=A.useState(!1),[$e,B]=A.useState({}),[N,ke]=A.useState(!1),[pe,Bn]=A.useState(!1),[ae,Ge]=A.useState("targeted"),[Ye,Pe]=A.useState(!1),Je=ae==="allAsync"&&!Ye,Ze=K(s=>s.connectionName||s.connectionUrl||"this environment"),[Qe,Ne]=A.useState({confirmed:!1}),qn=se.useCallback((s,p)=>Ne({confirmed:s,environment:p}),[]),en=Qe.confirmed,[Fn,nn]=A.useState(0),[sn,re]=A.useState(""),[De,tn]=A.useState(""),[be,on]=A.useState(c?.version??"1.0.0.0"),[fe,ge]=A.useState([]),[Wn,an]=A.useState([]),[Kn,ye]=A.useState([]),rn=se.useMemo(()=>{const p=(be||c?.version||"1.0.0.0").split(".").map(q=>Number.parseInt(q,10)||0);for(;p.length<4;)p.push(0);return p[3]+=1,p.slice(0,4).join(".")},[c?.version,be]);se.useEffect(()=>{on(c?.version??"1.0.0.0")},[c?.version]);const we=se.useCallback((s,p,q)=>Cs({locations:s.map(M=>({current:a[M],baseline:i[M]})),excludeCommandIds:q,locLabels:h,baselineLocLabels:C,layer:b[p]??void 0,unhiddenLayerHideIds:w[p],deletedOrphans:P[p].filter(M=>j[p].includes(M.id)),customisedCommandIds:W,uncustomisedCommandIds:Z[p],commands:d,baselineCommands:$,enableRules:f,baselineEnableRules:S,displayRules:u,baselineDisplayRules:v}),[a,i,d,$,f,S,u,v,h,C,b,w,P,j,W,Z]),H=se.useMemo(()=>g?we(de,"entity"):null,[g,we]),ne=se.useMemo(()=>{const s=new Set;if(g)for(const p of de)for(const q of a[p].tabs)for(const M of q.groups)for(const z of Se(M))z.commandId&&s.add(z.commandId);return we(["Application"],"application",s)},[we,g,a]),le=ne.hasChanges&&R,ue=[...H?.unsupported??[],...ne.unsupported],ln=[...H?.warnings??[],...ne.warnings],G=[...g&&H?.hasChanges?[g.logicalName]:[],...le?["Application ribbon"]:[]],_n=g&&H?.hasChanges?g.logicalName:"application ribbon",[Ae,xe]=A.useState("idle"),[Ee,Te]=A.useState([]),[Hn,Le]=A.useState(""),te=t&&!!c&&ue.length===0&&G.length>0,cn=c?.id,dn=c?.publisherPrefix||l,un=se.useCallback(async()=>{const s={commands:d,enableRules:f,displayRules:u,locLabels:h,baselineCommands:$,baselineEnableRules:S,baselineDisplayRules:v,publisherPrefix:dn,languageCode:_},p={lookupWebResources:M=>vs(M,cn)},q=[];if(g&&H?.hasChanges){const{findings:M}=await Sn({...s,entity:{logicalName:g.logicalName,schemaName:g.schemaName},locations:de.map(z=>({current:a[z],baseline:i[z]})),plan:H},p);q.push(...M.map(z=>({...z,scope:g.logicalName})))}if(le){const{findings:M}=await Sn({...s,entity:null,locations:[{current:a.Application,baseline:i.Application}],plan:ne},p);q.push(...M.map(z=>({...z,scope:"Application ribbon"})))}return q},[g,H,ne,le,a,i,d,f,u,h,$,S,v,dn,cn,_]);se.useEffect(()=>{if(!te||y||N)return;let s=!1;return xe("running"),Le(""),qs(un(),ot).then(p=>{s||(Te(p),xe("done"))}).catch(p=>{s||(Te([]),Le(p instanceof Error?p.message:String(p)),xe("failed"))}),()=>{s=!0}},[te,y,N,un]);const ce=Ee.filter(s=>s.severity==="error"),Ce=Ee.filter(s=>s.severity==="warning"),hn=new Set(Ee.map(s=>s.scope)).size>1,mn=te&&(Ae==="running"||ce.length>0),Gn=()=>He(async()=>{if(!c||ue.length>0||G.length===0||mn||!en||Q||Je)return;I(!0);const s=_e(),p=K.getState().connectionVersion,q=()=>K.getState().connectionVersion!==p,M=await An().catch(()=>null);if(q()){I(!1);return}if(Fe(M?.environment)&&!Fe(Qe.environment)){Ne({confirmed:!1}),nn(x=>x+1),I(!1),Ie.getState().logWarn("publish",`${M?.name??"The connection"} is a Production environment now: type the confirmation to publish.`);return}re(""),ge([]),ye([]),an(G),B(Object.fromEntries(G.map(x=>[x,"pending"])));let z=!1;const oe=[],Me={},ie=[],ve=[],Ue=Ie.getState(),he=x=>x instanceof Error?x.message:String(x);De.trim()&&Ue.logInfo("publish",`Publish comment: ${De.trim()}`);const pn={commands:d,enableRules:f,displayRules:u,locLabels:h,baselineCommands:$,baselineEnableRules:S,baselineDisplayRules:v,publishCustomizations:!0,languageCode:_,solution:{uniqueName:c.uniqueName,friendlyName:c.friendlyName,version:pe?rn:be,publisherUniqueName:c.publisherUniqueName,publisherName:c.publisherName,publisherPrefix:c.publisherPrefix||l,publisherOptionValuePrefix:c.publisherOptionValuePrefix}};if(g&&H?.hasChanges){const x=g.logicalName;B(T=>({...T,[x]:"publishing"}));try{const T=await In({...pn,guard:s,entity:{logicalName:g.logicalName,schemaName:g.schemaName,displayName:g.displayName},locations:de.map(V=>({current:a[V],baseline:i[V]})),plan:H},V=>re(V));oe.push(...de),Me.entity=T.parts,js(L,g.logicalName,T.changedKeys),T.verification&&ve.push({scope:x,result:T.verification}),B(V=>({...V,[x]:"success"}))}catch(T){z=!0,ie.push({scope:x,message:he(T)}),Ue.logError("publish",`Ribbon publish failed (${x}): ${he(T)}`),B(V=>({...V,[x]:"error"}))}}else g&&oe.push(...de);if(le&&!q()){const x="Application ribbon";B(T=>({...T,[x]:"publishing"}));try{const T=await In({...pn,guard:s,entity:null,locations:[{current:a.Application,baseline:i.Application}],ribbonCustomizationIds:m??[],plan:ne},V=>re(V));oe.push("Application"),Me.application=T.parts,T.verification&&ve.push({scope:x,result:T.verification}),B(V=>({...V,[x]:"success"}))}catch(T){z=!0,ie.push({scope:x,message:he(T)}),Ue.logError("publish",`Application ribbon publish failed: ${he(T)}`),B(V=>({...V,[x]:"error"}))}}else ne.hasChanges||oe.push("Application");if(!z&&ae==="allAsync")try{await Gs(x=>re(x),{guard:s})}catch(x){z=!0,ie.push({scope:"Publish all customizations",message:he(x)})}if(q()){le&&!ie.some(x=>x.scope==="Application ribbon")&&ie.push({scope:"Application ribbon",message:"Not published: the tool's connection changed during the publish."}),ye(ve),ge(ie),ke(!1),I(!1);return}if(ee(oe,Me),g&&oe.includes("HomepageGrid")&&H?.hasChanges){const x=await yn(g.logicalName);x&&Y("entity",x)}if(oe.includes("Application")&&le){const x=await yn(null);x&&Y("application",x)}z||re("Done."),ye(ve),ge(ie),ke(!z),I(!1)}),ze=()=>{I(!1),B({}),an([]),ke(!1),re(""),ge([]),ye([]),xe("idle"),Te([]),Le(""),Ne({confirmed:!1}),Ge("targeted"),Pe(!1),tn(""),nn(s=>s+1),o()};return n.jsx(Is,{open:t,onOpenChange:()=>!y&&ze(),children:n.jsxs($s,{style:{maxWidth:"640px",maxHeight:"92vh",display:"flex",flexDirection:"column"},children:[n.jsx(ks,{children:"Publish to Dataverse"}),n.jsxs(Ps,{style:{flex:1,minHeight:0,overflow:"hidden"},children:[n.jsx(Ns,{style:{overflowY:"auto",maxHeight:"100%"},children:n.jsxs("div",{className:e.content,children:[!c&&n.jsx(U,{intent:"warning",children:n.jsx(O,{children:"No solution selected. Please select a solution first."})}),Q&&!N&&n.jsx(U,{intent:"error",layout:"multiline",children:n.jsx(O,{children:"The organization's base language couldn't be read when the table loaded, so labels are shown in English. Reload the table before publishing: publishing now could write English texts as the base language's titles."})}),ue.length>0&&!N&&n.jsx(U,{intent:"error",layout:"multiline",children:n.jsxs(O,{children:[n.jsx("strong",{children:"These changes can't be published yet. Undo them to publish:"}),n.jsx("ul",{style:{margin:`${E.spacingVerticalXS} 0 0`,paddingLeft:20},children:ue.map(s=>n.jsx("li",{children:s},s))})]})}),ln.length>0&&!N&&n.jsx(U,{intent:"info",layout:"multiline",children:n.jsxs(O,{children:[n.jsx("strong",{children:"Good to know:"}),n.jsx("ul",{style:{margin:`${E.spacingVerticalXS} 0 0`,paddingLeft:20},children:ln.map(s=>n.jsx("li",{children:s},s))})]})}),te&&!N&&!y&&Ae==="running"&&n.jsxs("div",{className:e.progressRow,children:[n.jsx(Ds,{size:"tiny"}),n.jsx(F,{children:"Checking the ribbon customizations before publishing…"})]}),te&&!N&&Ae==="failed"&&n.jsx(U,{intent:"warning",layout:"multiline",children:n.jsxs(O,{children:["The pre-publish check couldn't complete (",Hn,"). Publishing runs the check again before anything is imported."]})}),te&&!N&&ce.length>0&&n.jsx(U,{intent:"error",layout:"multiline",children:n.jsxs(O,{children:[n.jsxs("strong",{children:["Publishing is blocked: the pre-publish check found ",ce.length," error",ce.length!==1?"s":"",". Fix"," ",ce.length!==1?"them":"it",", then reopen this dialog:"]}),n.jsx(kn,{findings:ce,showScope:hn})]})}),te&&!N&&Ce.length>0&&n.jsx(U,{intent:"warning",layout:"multiline",children:n.jsxs(O,{children:[n.jsxs("strong",{children:[Ce.length," warning",Ce.length!==1?"s":""," — you can still publish:"]}),n.jsx(kn,{findings:Ce,showScope:hn})]})}),ne.hasChanges&&!R&&!N&&n.jsx(U,{intent:"warning",layout:"multiline",children:n.jsxs(O,{children:["You changed the Application ribbon, but this solution doesn't include the Application Ribbons component, so those changes stay pending. In make.powerapps.com open the solution, choose ",n.jsx("strong",{children:"Add existing → Application Ribbons"}),", then reload here."]})}),n.jsx(U,{intent:"info",layout:"multiline",children:n.jsxs(O,{children:["Publishing writes this table's complete ribbon customization: what is already published, plus your changes. Ribbon changes on this table that were imported elsewhere but ",n.jsx("strong",{children:"not published"})," are published first, so they are kept. Publishing takes about 1–4 minutes (the ribbon is imported twice so Unified Interface picks up the change). Users may need to refresh the page, or navigate away and back, to see the update. You have ",n.jsx("strong",{children:k})," change(s) since the last publish."]})}),fe.length>0&&n.jsx(U,{intent:"error",layout:"multiline",children:n.jsxs(O,{children:[n.jsxs("strong",{children:["Publish failed (",fe.length," error",fe.length!==1?"s":"",")"]}),n.jsx("ul",{style:{margin:`${E.spacingVerticalXS} 0 0`,paddingLeft:20},children:fe.map((s,p)=>n.jsxs("li",{style:{fontFamily:E.fontFamilyMonospace},children:[n.jsxs("strong",{children:[s.scope,":"]})," ",s.message]},p))}),n.jsxs("div",{style:{marginTop:E.spacingVerticalS},children:["Full details are in the ",n.jsx("strong",{children:"Console"})," tab of the bottom panel."]})]})}),!y&&!N&&n.jsxs(n.Fragment,{children:[n.jsx(st,{rows:[{label:"Solution",value:c?n.jsx(F,{weight:"semibold",children:c.friendlyName||c.uniqueName}):n.jsx(F,{children:"None selected"})},{label:"Will publish",value:n.jsx(F,{weight:"semibold",children:G.length>0?G.join(", "):"nothing (there are no changes to publish)"})},{label:"Writes",value:n.jsxs(F,{children:["Publishes ",G.length===1?"it":"them"," first (keeps changes imported elsewhere but not published),"," ",G.length===1?"imports its":"imports each one's"," ribbon customization twice, replacing what the solution's layer has, then publishes"," ",ae==="allAsync"?"every unpublished customization in the environment":G.length===1?"it":"them","."]})}],confirmWord:_n,onConfirmationChange:qn},Fn),n.jsx(Re,{label:"Afterwards",children:n.jsxs(As,{value:ae==="targeted"?"Publish only these ribbons":"Also publish all customizations (PublishAllXmlAsync)",selectedOptions:[ae],onOptionSelect:(s,p)=>{(p.optionValue==="targeted"||p.optionValue==="allAsync")&&(Ge(p.optionValue),Pe(!1))},children:[n.jsx(wn,{value:"targeted",children:"Publish only these ribbons"}),n.jsx(wn,{value:"allAsync",children:"Also publish all customizations (PublishAllXmlAsync)"})]})}),ae==="allAsync"&&n.jsx(U,{intent:"warning",layout:"multiline",children:n.jsxs(O,{children:[n.jsxs(F,{block:!0,children:["This publishes ",n.jsx("strong",{children:"every"})," unpublished customization in"," ",n.jsx("strong",{children:Ze}),", not only these ribbons: forms, views, tables and other people's work in progress included."]}),n.jsx(Es,{checked:Ye,onChange:(s,p)=>Pe(p.checked===!0),label:`Publish all unpublished customizations in ${Ze}`})]})}),n.jsx(Re,{label:"Solution version",children:n.jsx(Ln,{size:"small",value:pe?rn:be,onChange:(s,p)=>on(p.value),disabled:pe})}),n.jsx(Ts,{label:"Increment solution version",checked:pe,onChange:(s,p)=>Bn(p.checked===!0)}),n.jsx(Re,{label:"Publish comment",hint:"Written to the Console log with this publish; it isn't stored in Dataverse.",children:n.jsx(Ls,{resize:"vertical",value:De,onChange:(s,p)=>tn(p.value)})}),n.jsx(qe,{appearance:"subtle",onClick:()=>{r(),ze()},children:"View RibbonDiffXml"})]}),N&&n.jsx(U,{intent:"info",layout:"multiline",children:n.jsx(O,{children:"Unified Interface caches command bars by metadata version, and publishing a ribbon doesn't always change that version. If the app still shows the old command bar, hard-refresh the page (Ctrl+F5) or sign out and back in; it can take several minutes to appear for users who already had the table open."})}),Kn.map(s=>n.jsx(U,{intent:s.result.ok?"success":"warning",layout:"multiline",children:n.jsxs(O,{children:[n.jsxs("strong",{children:[s.scope,":"]})," ",s.result.message]})},s.scope)),(y||N)&&n.jsxs("div",{className:e.progressList,children:[Wn.map(s=>{const p=$e[s]??"pending";return n.jsxs("div",{className:e.progressRow,children:[n.jsx(Tn,{appearance:"filled",color:p==="success"?"success":p==="error"?"danger":p==="publishing"?"informative":"subtle",size:"small",children:p}),n.jsx(F,{children:s}),p==="publishing"&&n.jsx(zs,{thickness:"large",style:{flex:1}})]},s)}),sn&&n.jsx(U,{intent:"info",children:n.jsx(O,{children:sn})})]})]})}),n.jsxs(Ms,{children:[n.jsx(qe,{appearance:"secondary",onClick:ze,disabled:y,children:N?"Close":"Cancel"}),!N&&n.jsx(qe,{appearance:"primary",onClick:()=>{Gn()},disabled:y||!c||G.length===0||ue.length>0||mn||!en||Q||Je,children:y?"Publishing...":"Publish"})]})]})]})})};export{mt as BulkPublishModal,mt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as e,h as N,z as Be,cq as ue}from"./fluent-icons-BqJj6rDi.js";import{a as S,u as b,i as Pe,b as We,d as $e,C as Le,w as Te,E as Oe,e as Ve,f as He,h as Ue,j as _e,k as Xe}from"./index-Di2_5czx.js";import{a as m}from"./monaco-BIO15LCS.js";import{u as Je,C as me}from"./useStableKeys-p2OkzZWO.js";import{M as qe}from"./MonacoEditor-uzfuRCpJ.js";import{ai as Ke,aj as Ge,ak as Ye,b as d,t as n,d as u,al as Qe,ac as Ze,ad as z,a7 as X,F as j,S as J,B as I,M as C,f as w,I as $}from"./fluent-ui-QADO660t.js";import"./dnd-Cq8OftAq.js";import"./crmParameters-rgfZhhzN.js";const es=Be({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}}),ss=[],ds=()=>{const l=es(),L=S(s=>s.commandEditorOpen),k=S(s=>s.commandEditorId),M=S(s=>s.closeCommandEditor),pe=S(s=>s.openCommandEditor),q=S(s=>s.openRuleEditor),he=S(s=>s.openWebResourceBrowser),T=b(s=>s.commands),be=b(s=>s.upsertCommand),xe=b(s=>s.renameCommandId),K=b(s=>s.ribbons),G=b(s=>s.displayRules),Y=b(s=>s.enableRules),je=b(s=>s.past),fe=b(s=>s.upsertEnableRule),ge=b(s=>s.upsertDisplayRule),[f,ve]=m.useState("actions"),[p,Q]=m.useState(""),[ye,Z]=m.useState(""),[Ce,ee]=m.useState(""),[se,A]=m.useState(null),[E,ae]=m.useState(!1),[ne,D]=m.useState(!1),[O,g]=m.useState(null),[re,V]=m.useState(null),[le,F]=m.useState(""),[we,B]=m.useState(!1),[R,ie]=m.useState(null),r=T.find(s=>s.id===k),v=Je(`actions:${r?.id??""}`,r?.actions??ss),Re=Pe(We(r?.id)),Ne=s=>{const a=s.trim();return a.startsWith("$webresource:")?a.slice(13).trim():a},Se=s=>{if(!s)return"";const a=Uint8Array.from(atob(s),o=>o.charCodeAt(0));return new TextDecoder().decode(a)},ze=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)},ke=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(()=>{r&&Q(r.id)},[r]),m.useEffect(()=>{L&&k&&!r&&M()},[L,k,r,M]);const P=m.useMemo(()=>r?p.trim()?/\s/.test(p)?"Command ID cannot contain whitespace.":p!==r.id&&T.some(s=>s.id.toLowerCase()===p.toLowerCase())?"A command with this ID already exists.":"":"Command ID is required.":"",[p,r,T]),H=m.useMemo(()=>Object.entries(K).flatMap(([s,a])=>a.tabs.flatMap(o=>o.groups.flatMap(i=>$e(i).filter(c=>c.commandId===k).map(c=>({location:s,tab:o,group:i,button:c}))))),[K,k]),oe=H.length;if(!r)return null;const te=async(s,a)=>{const o=r.actions[s];if(!o||o.kind!=="javascript")return;const i=Ne(o.library);if(!i){g("JavaScript library must be a valid $webresource path."),A(s),ae(a),F(""),ie(null);return}A(s),ae(a),D(!0),g(null),V(null),B(!1),ie(i);try{const c=await He(i);if(!c){F(""),g(`Web resource not found: ${i}`);return}const t=await Ue(c.id);F(Se(t))}catch(c){g(c instanceof Error?c.message:"Failed to load web resource content."),F("")}finally{D(!1)}},Ee=async()=>{if(!E||se===null||!R)return;const s=Xe();D(!0),g(null),V(null);try{const a=await _e(R,ze(le),ke(R),{displayName:R.split("/").pop(),guard:s});V([a.solutionWarning,a.publishWarning].filter(Boolean).join(" ")||null),B(!1)}catch(a){g(a instanceof Error?a.message:"Failed to save web resource content.")}finally{D(!1)}},y=s=>{be({...r,...s})},x=(s,a)=>{const o=[...r.actions];o[s]=a,y({actions:o}),v.update()},W=s=>{y({actions:r.actions.filter((a,o)=>o!==s)}),v.remove(s),A(a=>a===null||a===s?null:a>s?a-1:a)},U=s=>{const a=s==="javascript"?{kind:"javascript",library:"",functionName:"",params:[]}:{kind:"url",address:"https://",params:[]};y({actions:[...r.actions,a]}),v.add()},Fe=(s,a)=>{const o=se===a;if(s.kind==="javascript")return e.jsxs("div",{className:l.actionCard,children:[e.jsxs("div",{className:l.actionHeader,children:[e.jsx(I,{appearance:"filled",color:"success",size:"small",children:"JavaScript"}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(N,{}),onClick:()=>W(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($,{style:{flex:1},value:s.library,onChange:(i,c)=>x(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:()=>{Te.set(i=>{x(a,{...s,library:`$webresource:${i.name}`})}),he()},children:"Browse…"})]})}),e.jsx(j,{label:"Function name",children:e.jsx($,{value:s.functionName,onChange:(i,c)=>x(a,{...s,functionName:c.value}),placeholder:"MyNamespace.myFunction"})}),e.jsx(C,{intent:"info",children:e.jsx(w,{children:"Read-only function preview and Monaco editing are available in the web resource browser integration path."})}),e.jsx(X,{children:"Parameters (positional)"}),e.jsx(me,{params:s.params,onChange:i=>x(a,{...s,params:i}),urlMode:!1}),e.jsxs("div",{className:l.row,children:[e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{te(a,!1)},children:"Function preview"}),e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{te(a,!0)},children:"Open in Monaco"})]}),o&&e.jsxs("div",{className:l.codePanel,children:[e.jsxs("div",{className:l.row,children:[e.jsx(d,{weight:"semibold",children:E?"Monaco Editor":"Function Preview"}),R&&e.jsx(d,{size:200,style:{fontFamily:n.fontFamilyMonospace},children:R})]}),O&&e.jsx(C,{intent:"error",children:e.jsx(w,{children:O})}),re&&e.jsx(C,{intent:"warning",children:e.jsx(w,{children:re})}),ne?e.jsx(d,{style:{color:n.colorNeutralForeground3},children:"Loading source…"}):e.jsx("div",{style:{height:240},children:e.jsx(qe,{language:"javascript",value:le,readOnly:!E,onChange:i=>{F(i),B(!0)},options:{wordWrap:"on"}})}),e.jsxs("div",{className:l.row,children:[e.jsx(u,{appearance:"subtle",size:"small",onClick:()=>{A(null),g(null),B(!1)},children:"Close"}),E&&e.jsx(Oe,{prefix:"Saves to"}),E&&e.jsx(u,{appearance:"primary",size:"small",onClick:()=>{Ee()},disabled:!we||ne||!!O,children:"Save Web Resource"})]})]})]},v.keys[a]);if(s.kind==="url"){const i=s.address.trim().startsWith("https://");return e.jsxs("div",{className:l.actionCard,children:[e.jsxs("div",{className:l.actionHeader,children:[e.jsx(I,{appearance:"filled",color:"informative",size:"small",children:"URL"}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(N,{}),onClick:()=>W(a),"aria-label":"Remove action"})]}),e.jsx(C,{intent:"warning",children:e.jsx(w,{children:e.jsx(d,{className:l.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($,{value:s.address,onChange:(c,t)=>x(a,{...s,address:t.value}),placeholder:"https://..."})}),e.jsx(j,{label:"Open in (WinMode)",children:e.jsxs(J,{value:String(s.winMode??0),onChange:(c,t)=>x(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:()=>x(a,{...s,passParams:s.passParams?void 0:!0}),children:[s.passParams?"✓ PassParams ON":"PassParams OFF"," — appends typename, type, id, orgname…"]})}),e.jsx(X,{children:"Parameters (named)"}),e.jsx(me,{params:s.params,onChange:c=>x(a,{...s,params:c}),urlMode:!0})]},v.keys[a])}return s.kind==="powerFx"||s.kind==="customApi"?e.jsxs("div",{className:l.actionCard,children:[e.jsxs("div",{className:l.actionHeader,children:[e.jsxs(I,{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(N,{}),onClick:()=>W(a),"aria-label":"Remove action"})]}),e.jsx(C,{intent:"error",children:e.jsxs(w,{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."]})})]},v.keys[a]):s.kind==="outlookCommand"||s.kind==="raw"?e.jsxs("div",{className:l.actionCard,children:[e.jsxs("div",{className:l.actionHeader,children:[e.jsx(I,{appearance:"outline",size:"small",children:s.kind==="outlookCommand"?"Outlook command":s.tagName}),e.jsx(u,{appearance:"subtle",size:"small",icon:e.jsx(N,{}),onClick:()=>W(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})]},v.keys[a]):null},Ie=()=>e.jsxs(e.Fragment,{children:[r.actions.map((s,a)=>Fe(s,a)),r.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:l.row,children:[e.jsx(j,{label:"Action type",style:{minWidth:"220px"},children:e.jsxs(J,{onChange:(s,a)=>{const o=a.value;o&&U(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(ue,{}),appearance:"secondary",size:"small",onClick:()=>U("javascript"),children:"Add JavaScript function"}),e.jsx(u,{icon:e.jsx(ue,{}),appearance:"secondary",size:"small",onClick:()=>U("url"),children:"Add URL action"})]})]}),Me=()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{label:"Command ID",children:e.jsx($,{value:p,onChange:(s,a)=>Q(a.value),style:{fontFamily:n.fontFamilyMonospace}})}),P&&e.jsx(d,{style:{color:n.colorPaletteRedForeground1,fontSize:n.fontSizeBase100},children:P}),e.jsx(u,{appearance:"secondary",size:"small",disabled:!p.trim()||!!P||p===r.id,onClick:()=>{if(!p.trim()||P)return;const s=p.trim();xe(r.id,s)&&pe(s)},children:"Apply ID change"}),e.jsx(d,{style:{color:n.colorNeutralForeground3,fontSize:n.fontSizeBase200},children:"Naming convention: Publisher.EntityName.ButtonName.Command"}),e.jsx(C,{intent:"warning",children:e.jsx(w,{children:e.jsxs(d,{className:l.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."]})})})]}),ce=s=>{const a=s==="enable"?r.enableRules:r.displayRules,o=(s==="enable"?Y:G).map(t=>t.id).filter(t=>!a.includes(t)),i=s==="enable"?ye:Ce,c=()=>{const t=new Set([...Y.map(_=>_.id),...G.map(_=>_.id)]),h=Ve("New",s==="enable"?"Enable":"Display",t);s==="enable"?fe({id:h,steps:[]}):ge({id:h,steps:[]}),q(h,s)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:l.rulePills,children:[a.map(t=>e.jsxs("div",{className:l.ruleRow,children:[e.jsx(I,{appearance:"outline",size:"medium",className:l.ruleChip,onClick:()=>q(t,s),role:"button",tabIndex:0,children:t}),e.jsx(u,{appearance:"subtle",size:"small",className:l.ruleRemoveBtn,icon:e.jsx(N,{}),"aria-label":`Unbind ${t}`,onClick:()=>{y(s==="enable"?{enableRules:r.enableRules.filter(h=>h!==t)}:{displayRules:r.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:l.row,children:[e.jsx(j,{label:`Bind existing ${s} rule`,style:{minWidth:"260px"},children:e.jsxs(J,{value:i,onChange:(t,h)=>s==="enable"?Z(h.value):ee(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"?(y({enableRules:[...r.enableRules,i]}),Z("")):(y({displayRules:[...r.displayRules,i]}),ee("")))},children:"Bind selected"}),e.jsxs(u,{appearance:"subtle",size:"small",onClick:c,children:["Create new ",s," rule"]})]}),s==="enable"&&e.jsx(C,{intent:"info",children:e.jsxs(w,{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."]})})]})},Ae=()=>e.jsxs(e.Fragment,{children:[e.jsxs(d,{children:["Referenced by ",e.jsx("strong",{children:oe})," button(s)."]}),H.length>0&&e.jsx("div",{className:l.versionsList,children:H.map(s=>e.jsx("div",{className:l.versionRow,children:e.jsxs("div",{children:[e.jsx(d,{weight:"semibold",style:{fontFamily:n.fontFamilyMonospace},children:s.button.id}),e.jsxs(d,{className:l.versionMeta,children:[s.location," → ",s.tab.label," → ",s.group.label]})]})},`${s.location}:${s.tab.id}:${s.group.id}:${s.button.id}`))})]}),de=je.filter(s=>s.target===r.id||s.detail.includes(r.id)).slice().reverse(),De=()=>e.jsx(e.Fragment,{children:de.length===0?e.jsx(d,{style:{color:n.colorNeutralForeground3},children:"No command-specific history entries yet."}):e.jsx("div",{className:l.versionsList,children:de.map((s,a)=>e.jsxs("div",{className:l.versionRow,children:[e.jsxs("div",{children:[e.jsx(d,{weight:"semibold",children:s.op}),e.jsx(d,{className:l.versionMeta,children:s.detail})]}),e.jsx(d,{className:l.versionMeta,children:new Date(s.ts).toLocaleString()})]},`${s.ts}-${a}`))})});return e.jsxs(Ke,{position:"end",open:L,onOpenChange:()=>M(),className:l.drawer,children:[e.jsx(Ge,{children:e.jsx(Ye,{action:e.jsx(u,{appearance:"subtle",icon:e.jsx(N,{}),onClick:M,"aria-label":"Close command editor"}),children:e.jsx(d,{size:400,weight:"semibold",style:{fontFamily:n.fontFamilyMonospace},children:r.id})})}),e.jsxs(Qe,{className:l.body,children:[e.jsxs(Ze,{selectedValue:f,onTabSelect:(s,a)=>ve(a.value),children:[e.jsx(z,{value:"actions",children:"Actions"}),e.jsx(z,{value:"enableRules",children:"Enable rules"}),e.jsx(z,{value:"displayRules",children:"Display rules"}),e.jsx(z,{value:"settings",children:"Settings"}),e.jsxs(z,{value:"references",children:["References (",oe,")"]}),e.jsx(z,{value:"versions",children:"Versions"})]}),e.jsx(X,{}),e.jsx(Le,{commandId:r.id}),e.jsxs("fieldset",{disabled:Re,className:l.readOnly,children:[f==="actions"&&Ie(),f==="enableRules"&&ce("enable"),f==="displayRules"&&ce("display"),f==="settings"&&Me()]}),f==="references"&&Ae(),f==="versions"&&De()]})]})};export{ds as CommandEditorPanel,ds as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as a,E as ae,z as ne}from"./fluent-icons-BqJj6rDi.js";import{a as p}from"./monaco-BIO15LCS.js";import{a as s,u as c,an as se,Z as le,ao as ie,ab as x,ai as re,ap as ce,d as de}from"./index-Di2_5czx.js";import{t,B as ue,b as I}from"./fluent-ui-QADO660t.js";import"./dnd-Cq8OftAq.js";const pe=ne({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}}),ke=()=>{const l=pe(),S=s(e=>e.commandPaletteOpen),j=s(e=>e.setCommandPaletteOpen),D=s(e=>e.openBulkPublish),H=s(e=>e.openXmlDrawer),b=s(e=>e.openImportXml),O=s(e=>e.openCommandEditor),z=s(e=>e.openRuleEditor),P=s(e=>e.openNewGroup),W=s(e=>e.openNewButton),G=s(e=>e.openLocalizationEditor),E=s(e=>e.themeMode),V=s(e=>e.setThemeMode),F=c(e=>e.undo),U=c(e=>e.redo),q=c(e=>e.commands),K=c(e=>e.displayRules),Z=c(e=>e.enableRules),L=c(e=>e.ribbons),w=c(e=>e.locLabels),y=se(),A=le(e=>e.entities),Q=ie(e=>e.requestEntitySwitch),Y=x(e=>e.location),J=x(e=>e.tabId),m=x(e=>e.selectedButtonId),M=x(e=>e.selectedGroupId),[i,R]=p.useState(""),[C,u]=p.useState(0),B=p.useRef(null),n=p.useCallback(()=>{j(!1),R(""),u(0)},[j]);p.useEffect(()=>{S&&setTimeout(()=>B.current?.focus(),50)},[S]);const _=()=>{const e=[],r=L[Y].tabs.find(o=>o.id===J),te=r?.groups[0]?.id??null,N=M??te,X=re(ce(r?.groups.find(o=>o.id===M),m)?.kind),oe=[{id:"publish",label:"Publish all",subtitle:"Save and publish changes to Dataverse",kind:"action",action:()=>{D(),n()}},{id:"view-xml",label:"View RibbonDiffXml",subtitle:"Open XML drawer",kind:"action",action:()=>{H(),n()}},{id:"import-xml",label:"Import XML",subtitle:"Import RibbonDiffXml from clipboard",kind:"action",action:()=>{n();const o="Couldn't read the clipboard here: paste the XML into the editor (Ctrl+V).",g=navigator.clipboard?.readText?.();if(!g)return b("",o);g.then(k=>k.trim().startsWith("<")?b(k):b("","The clipboard doesn't hold XML: paste the XML into the editor."),()=>b("",o))}},{id:"new-group",label:"New group",subtitle:"Create a new ribbon group in current tab",kind:"action",action:()=>{P(),n()}},{id:"new-button",label:"New button",subtitle:N?"Create a new button in selected/current group":"Select a tab/group with at least one group first",kind:"action",action:()=>{N&&(W(N),n())}},{id:"edit-labels",label:"Edit localized labels",subtitle:X?"The selected control is shown read-only":m?"Open localization editor for selected button":"Select a button first",kind:"action",action:()=>{!m||X||(G(m),n())}},{id:"toggle-theme",label:`Toggle theme (${E==="dark"?"Dark":"Light"})`,subtitle:"Switch between light and dark",kind:"action",action:()=>{V(E==="dark"?"light":"dark"),n()}},{id:"undo",label:"Undo",subtitle:"Ctrl+Z",kind:"action",action:()=>{F(),n()}},{id:"redo",label:"Redo",subtitle:"Ctrl+Shift+Z",kind:"action",action:()=>{U(),n()}}];if(e.push(...oe),!i.startsWith("@")&&!i.startsWith("/")){const o=Object.entries(L).flatMap(([g,k])=>k.tabs.flatMap(v=>v.groups.flatMap($=>de($).map(d=>({id:`btn-${d.id}`,label:y(d.label,w,void 0,d.source?.labelToken)||d.id,subtitle:`${g} → ${y(v.label,w,void 0,v.source?.titleToken)} → ${y($.label,w,void 0,$.source?.titleToken)}`,keywords:`${d.label} ${d.id}`,kind:"button",action:()=>{n()}})))));e.push(...o.slice(0,20))}return q.forEach(o=>{e.push({id:`cmd-${o.id}`,label:o.id,subtitle:`${o.actions.length} action(s)`,kind:"command",action:()=>{O(o.id),n()}})}),K.forEach(o=>{e.push({id:`dr-${o.id}`,label:o.id,subtitle:`Display rule — ${o.steps.length} step(s)`,kind:"rule",action:()=>{z(o.id,"display"),n()}})}),Z.forEach(o=>{e.push({id:`er-${o.id}`,label:o.id,subtitle:`Enable rule — ${o.steps.length} step(s)`,kind:"rule",action:()=>{z(o.id,"enable"),n()}})}),(i.startsWith("@")||!i)&&A.slice(0,30).forEach(o=>{e.push({id:`ent-${o.logicalName}`,label:o.displayName,subtitle:o.logicalName,kind:"entity",action:()=>{Q(o),n()}})}),e},h=i.startsWith("@")||i.startsWith("/")?i.slice(1):i,T=_(),f=h?T.filter(e=>e.label.toLowerCase().includes(h.toLowerCase())||(e.subtitle??"").toLowerCase().includes(h.toLowerCase())||(e.keywords??"").toLowerCase().includes(h.toLowerCase())):T,ee=e=>{e.key==="ArrowDown"?(e.preventDefault(),u(r=>Math.min(r+1,f.length-1))):e.key==="ArrowUp"?(e.preventDefault(),u(r=>Math.max(r-1,0))):e.key==="Enter"?f[C]?.action():e.key==="Escape"&&n()};return S?a.jsx("div",{className:l.backdrop,onClick:n,role:"presentation",children:a.jsxs("div",{className:l.palette,onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[a.jsxs("div",{className:l.searchRow,children:[a.jsx(ae,{style:{color:t.colorNeutralForeground3,flexShrink:0}}),a.jsx("input",{ref:B,className:l.searchInput,value:i,onChange:e=>{R(e.target.value),u(0)},onKeyDown:ee,placeholder:"Search commands, buttons, entities… Use @ for entities, / for actions","aria-label":"Command palette search"})]}),a.jsxs("div",{className:l.results,role:"listbox",children:[f.map((e,r)=>a.jsxs("div",{className:`${l.item} ${r===C?l.itemSelected:""}`,onClick:e.action,role:"option","aria-selected":r===C,onMouseEnter:()=>u(r),children:[a.jsx(ue,{appearance:"outline",size:"small",children:e.kind}),a.jsxs("div",{className:l.itemLabel,children:[a.jsx(I,{children:e.label}),e.subtitle&&a.jsx(I,{className:l.itemSub,block:!0,children:e.subtitle})]})]},e.id)),f.length===0&&a.jsx("div",{className:l.item,children:a.jsx(I,{style:{color:t.colorNeutralForeground3},children:"No results"})})]}),a.jsxs("div",{className:l.footer,children:[a.jsx("span",{children:"↑↓ navigate"}),a.jsx("span",{children:"↵ select"}),a.jsx("span",{children:"Esc close"}),a.jsx("span",{children:"@ entities"}),a.jsx("span",{children:"/ actions"})]})]})}):null};export{ke as CommandPalette,ke as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as e,h as k,bK as C,b4 as D,z as B}from"./fluent-icons-BqJj6rDi.js";import{a as c}from"./monaco-BIO15LCS.js";import{a as u,u as I}from"./index-Di2_5czx.js";import{ai as M,aj as R,ak as H,aa as L,d as N,al as E,b as a,t as o,M as h,f as x,a5 as F,B as z,T as O}from"./fluent-ui-QADO660t.js";import"./dnd-Cq8OftAq.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=B({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"}}),_=()=>{const i=T(),l=u(n=>n.conflictDrawerOpen),s=u(n=>n.conflictElementId),r=u(n=>n.closeConflictDrawer),d=u(n=>n.openXmlDrawer),m=I(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(M,{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{_ as ConflictDrawer,_ as default};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./monaco-BIO15LCS.js","./monaco-DdLsZAcA.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{R as g,a as b,_ as H}from"./monaco-BIO15LCS.js";import{y as s,h as E,z as C}from"./fluent-icons-BqJj6rDi.js";import{a as x,u,g as N}from"./index-Di2_5czx.js";import{ai as O,aj as _,ak as V,aa as $,d as S,al as X,M as I,f as T,b as A,B as D,a5 as G,t as r}from"./fluent-ui-QADO660t.js";import"./dnd-Cq8OftAq.js";const P=g.lazy(()=>H(()=>import("./monaco-BIO15LCS.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
|
-
`),c=o.split(`
|
|
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
|
-
`+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(`
|
|
6
|
-
|
|
7
|
-
`)}const Z=()=>{const n=U(),o=x(e=>e.diffViewerOpen),l=x(e=>e.diffViewerMode),c=x(e=>e.closeDiffViewer),d=x(e=>e.themeMode),[a,f]=g.useState(!0),t=u(e=>e.ribbons),i=u(e=>e.baseline),p=u(e=>e.commands),m=u(e=>e.displayRules),h=u(e=>e.enableRules),y=u(e=>e.locLabels),R=d==="dark",j=b.useMemo(()=>B(t,i,p,m,h,y,!0),[o]),w=b.useMemo(()=>B(t,i,p,m,h,y,!1),[o,t,i,p,m,h,y]),{added:k,removed:L}=F(j,w),v=g.useRef(null),z=g.useCallback(e=>{v.current=e,e.updateOptions({renderSideBySide:a})},[]);return g.useEffect(()=>{v.current?.updateOptions({renderSideBySide:a})},[a]),s.jsxs(O,{className:n.drawer,open:o,position:"end",size:"full",onOpenChange:(e,M)=>!M.open&&c(),children:[s.jsx(_,{children:s.jsx(V,{action:s.jsx(S,{appearance:"subtle",icon:s.jsx(E,{}),onClick:c,"aria-label":"Close"}),children:s.jsx($,{children:l==="compare"?"Compare to baseline":"Diff viewer"})})}),s.jsx(X,{style:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,overflow:"hidden"},children:s.jsxs("div",{className:n.body,children:[s.jsx(I,{intent:"info",children:s.jsx(T,{children:s.jsx(A,{size:200,children:l==="compare"?"Showing current state vs. last published baseline.":"Showing the change introduced by this history entry."})})}),s.jsxs("div",{className:n.toggleRow,children:[s.jsxs(D,{appearance:"tint",color:"success",children:["+",k," lines"]}),s.jsxs(D,{appearance:"tint",color:"danger",children:["-",L," lines"]}),s.jsx("div",{style:{flex:1}}),s.jsx(S,{appearance:a?"primary":"subtle",size:"small",onClick:()=>f(!0),children:"Side by side"}),s.jsx(S,{appearance:a?"subtle":"primary",size:"small",onClick:()=>f(!1),children:"Unified"})]}),s.jsx("div",{className:n.editorWrap,children:s.jsx(b.Suspense,{fallback:s.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:s.jsx(G,{size:"medium",label:"Loading diff editor…"})}),children:s.jsx(P,{original:j,modified:w,language:"xml",theme:R?"vs-dark":"vs",height:"100%",onMount:z,options:{readOnly:!0,renderSideBySide:a,lineNumbers:"on",minimap:{enabled:!1},scrollBeyondLastLine:!1,automaticLayout:!0,wordWrap:"on"}})})})]})})]})};export{Z as DiffViewer,Z as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as c}from"./fluent-icons-BqJj6rDi.js";import{a as s,u as n,an as b,aH as p,aI as m,ap as f}from"./index-Di2_5czx.js";import"./monaco-BIO15LCS.js";import"./fluent-ui-QADO660t.js";import"./dnd-Cq8OftAq.js";const R=()=>{const o=s(e=>e.hideInsteadOfDelete),a=s(e=>e.closeHideInsteadOfDelete),i=s(e=>e.announce),t=n(e=>o?f(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),r=n(e=>e.locLabels),u=b();return!o||!t||!l?null:c.jsx(p,{open:!0,buttonLabel:u(t.label,r,void 0,t.source?.labelToken),commandId:t.commandId,deleteBlockedReason:m(t,l),onConfirmHide:()=>{n.getState().hideOobButton(o.location,o.tabId,o.groupId,o.buttonId),i("Button hidden"),a()},onConfirmDisplayRule:()=>{n.getState().hideWithDisplayRules(t.commandId)&&i("Button hidden"),a()},onCancel:a})};export{R as HideInsteadOfDeleteModal,R as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as o,h as pe,E as Y,J as me,z as he}from"./fluent-icons-BqJj6rDi.js";import{u as be}from"./useReplaceWebResourceConfirm-BUWBVNSC.js";import{a as Q,u as fe,ab as I,Z as J,l as K,au as ye,av as ee,aw as we,E as Se,j as xe,ax as ke,P as L,ay as Ce,az as ve,aA as Re,aB as je,k as W}from"./index-Di2_5czx.js";import{a as l,R as oe}from"./monaco-BIO15LCS.js";import{D as Be,i as Ie,k as Ae,j as Pe,aa as Ne,d as A,l as $e,ac as Te,ad as M,I as H,C as Ee,O as ze,a1 as Fe,t as r,b as p,B as De,m as Le}from"./fluent-ui-QADO660t.js";import"./dnd-Cq8OftAq.js";const We=[{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"]}],Me=["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 He(n){for(const y of We)if(y.keywords.some(m=>n.includes(m)))return y.category;return"General"}const re=Me.map(n=>({name:n,category:He(n)})),Ue=["All",...Array.from(new Set(re.map(n=>n.category))).sort()],Ge=he({surface:{width:"720px",maxWidth:"95vw",height:"min(580px, 90vh)",maxHeight:"90vh",overflow:"hidden"},dialogBody:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},body:{display:"flex",flexDirection:"column",flex:1,minHeight:0,overflow:"hidden",gap:r.spacingHorizontalS},toolbar:{display:"flex",alignItems:"center",gap:r.spacingHorizontalS,flexWrap:"wrap",flexShrink:0},categoryPicker:{minWidth:"180px",maxWidth:"220px"},iconGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(72px, 1fr))",gap:r.spacingHorizontalXS,overflowY:"auto",flex:1,minHeight:0,padding:r.spacingHorizontalXS},iconTile:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",padding:r.spacingHorizontalXS,borderRadius:r.borderRadiusMedium,border:"1px solid transparent",cursor:"pointer",minHeight:"64px",":hover":{backgroundColor:r.colorNeutralBackground3,border:`1px solid ${r.colorNeutralStroke1}`}},iconTileSelected:{backgroundColor:r.colorBrandBackground2,border:`1px solid ${r.colorBrandStroke1}`},iconLabel:{fontSize:r.fontSizeBase100,textAlign:"center",lineHeight:1.2,wordBreak:"break-word",color:r.colorNeutralForeground2},webResourceList:{flex:1,overflowY:"auto"},webResourceRow:{display:"flex",alignItems:"center",gap:r.spacingHorizontalS,padding:`${r.spacingHorizontalXS} ${r.spacingHorizontalS}`,cursor:"pointer",borderRadius:r.borderRadiusMedium,":hover":{backgroundColor:r.colorNeutralBackground3}},uploadArea:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:r.spacingHorizontalM,border:`2px dashed ${r.colorNeutralStroke2}`,borderRadius:r.borderRadiusMedium,color:r.colorNeutralForeground3}}),Ye=()=>{const n=Ge(),y=be(),m=Q(e=>e.iconPickerOpen),w=Q(e=>e.closeIconPicker),U=fe(e=>e.setButtonProp),v=I(e=>e.selectedButtonId),R=I(e=>e.selectedGroupId),G=I(e=>e.tabId),O=I(e=>e.location),P=J(e=>e.publisherPrefix),S=J(e=>e.activeSolution),[V,c]=l.useState(null),[_,j]=l.useState(null),[u,q]=l.useState("fluent"),[N,ae]=l.useState(""),[B,se]=l.useState("All"),[x,ne]=l.useState("regular"),[i,te]=l.useState(null),[k,$]=l.useState(""),[T,E]=l.useState([]),[X,Z]=l.useState(!1),[z,le]=l.useState(""),[b,f]=l.useState(!1);oe.useEffect(()=>{m||(c(null),j(null))},[m]),oe.useEffect(()=>{!m||u!=="webresource"||(Z(!0),K("svg").then(e=>E(e)).catch(()=>E([])).finally(()=>Z(!1)))},[m,u]);const ie=l.useMemo(()=>{const e=z.toLowerCase();return T.filter(a=>!e||a.name.toLowerCase().includes(e))},[z,T]),ce=l.useMemo(()=>{const e=N.toLowerCase();return re.filter(a=>(B==="All"||a.category===B)&&(e===""||a.name.toLowerCase().includes(e)))},[N,B]),de=async()=>{if(!i||!v||!R)return;const e=W(),a=L.getState();if(c(null),!S||S.isManaged){c("Select an unmanaged solution first — the icon is added to it as an SVG web resource.");return}f(!0);try{const s=await Ce(i,x,P,ve,{busy:{onProgress:t=>a.logInfo("webresource",t)},guard:e});s.publishError&&a.logWarn("webresource",`Publishing icon web resource ${s.name} failed: ${s.publishError}. Pick the icon again or publish customizations before using the button.`),U(O,G,R,v,{icon:ee(i),image16:`$webresource:${s.name}`,image32:`$webresource:${s.name}`}),a.logInfo("webresource",`${s.created?"Uploaded":"Reusing"} icon web resource ${s.name} (solution ${S.uniqueName}).`),w()}catch(s){const t=s instanceof Error?s.message:String(s);a.logError("webresource",`Fluent icon "${i}" could not be added as a web resource: ${t}`),c(`Could not add the icon as a web resource: ${t}`)}finally{f(!1)}},ue=async()=>{if(!k||!v||!R)return;const e=Re(k),a=W(),s=L.getState();c(null),j(null);const t=e.startsWith("$webresource:")?e.slice(13).trim():null;let g=null;if(t){f(!0);try{const h=T.find(F=>F.name===t),d=await je(t,h,a);d.solutionUniqueName&&s.logInfo("webresource",`Added web resource ${t} to solution ${d.solutionUniqueName}.`),g=d.solutionWarning??null}catch(h){const d=h instanceof Error?h.message:String(h);if(/^No web resource named /.test(d)){c(d);return}g=`The icon was set, but ${t} could not be added to the solution: ${d}`,s.logError("webresource",g)}finally{f(!1)}}if(U(O,G,R,v,{image16:e,image32:e}),g){j(g);return}w()},ge=async e=>{const a=W();if(!S||S.isManaged){c("Select an unmanaged solution first — the SVG is added to it as a web resource.");return}c(null),f(!0);try{const s=await new Promise((d,F)=>{const C=new FileReader;C.onerror=()=>F(C.error??new Error("Failed to read SVG")),C.onload=()=>{const D=String(C.result??"");d(D.includes(",")?D.split(",")[1]??"":D)},C.readAsDataURL(e)}),t=`${P||"new"}_/icons/${e.name}`,g=await xe(t,s,11,{displayName:e.name,guard:a,onExisting:y.onExisting});j([g.solutionWarning,g.publishWarning].filter(Boolean).join(" ")||null),$(`$webresource:${t}`),q("webresource");const h=await K("svg");E(h)}catch(s){if(s instanceof ke)return;const t=s instanceof Error?s.message:String(s);L.getState().logError("webresource",`SVG upload failed: ${t}`),c(`Upload failed: ${t}`)}finally{f(!1)}};return o.jsxs(o.Fragment,{children:[y.dialog,o.jsx(Be,{open:m,onOpenChange:(e,a)=>!a.open&&w(),children:o.jsx(Ie,{className:n.surface,children:o.jsxs(Ae,{className:n.dialogBody,children:[o.jsx(Pe,{action:o.jsx(A,{appearance:"subtle",icon:o.jsx(pe,{}),onClick:w,"aria-label":"Close"}),children:o.jsx(Ne,{children:"Choose Icon"})}),o.jsxs($e,{className:n.body,children:[o.jsxs(Te,{selectedValue:u,onTabSelect:(e,a)=>q(a.value),size:"small",children:[o.jsx(M,{value:"fluent",children:"Fluent icons"}),o.jsx(M,{value:"webresource",children:"Web resources"}),o.jsx(M,{value:"upload",children:"Upload SVG"})]}),u==="fluent"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:n.toolbar,children:[o.jsx(H,{contentBefore:o.jsx(Y,{}),placeholder:"Search icons…",value:N,onChange:(e,a)=>ae(a.value),size:"small",style:{flex:1}}),o.jsx(Ee,{className:n.categoryPicker,placeholder:"Category",value:B,onOptionSelect:(e,a)=>se(String(a.optionValue??"All")),children:Ue.map(e=>o.jsx(ze,{value:e,text:e,children:e},e))}),o.jsx(Fe,{label:x==="regular"?"Regular":"Filled",checked:x==="filled",onChange:(e,a)=>ne(a.checked?"filled":"regular")})]}),o.jsx("div",{className:n.iconGrid,children:ce.map(e=>o.jsxs("div",{className:`${n.iconTile} ${i===e.name?n.iconTileSelected:""}`,onClick:()=>te(e.name),role:"option","aria-selected":i===e.name,title:`${e.name} — ${e.category}`,children:[o.jsx(ye,{name:ee(e.name),size:24,variant:x}),o.jsx("span",{className:n.iconLabel,children:e.name})]},e.name))}),i&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:r.spacingHorizontalS,padding:r.spacingHorizontalXS,backgroundColor:r.colorNeutralBackground3,borderRadius:r.borderRadiusMedium,flexShrink:0},children:[o.jsxs(p,{size:200,style:{fontFamily:r.fontFamilyMonospace},children:['ModernImage="$webresource:',we(P||"new",i,x),'"']}),o.jsx(De,{appearance:"tint",color:"success",children:"Selected"})]})]}),u==="webresource"&&o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:r.spacingHorizontalS,flex:1},children:[o.jsx(H,{contentBefore:o.jsx(Y,{}),placeholder:"Search SVG web resources...",value:z,onChange:(e,a)=>le(a.value),size:"small"}),o.jsxs("div",{className:n.webResourceList,children:[X&&o.jsx(p,{size:200,style:{color:r.colorNeutralForeground3},children:"Loading web resources..."}),!X&&ie.slice(0,200).map(e=>{const a=`$webresource:${e.name}`,s=k===a;return o.jsx("div",{className:n.webResourceRow,onClick:()=>$(a),style:{backgroundColor:s?r.colorBrandBackground2:void 0},children:o.jsx(p,{size:200,style:{fontFamily:r.fontFamilyMonospace},children:a})},e.id)})]}),o.jsx(H,{placeholder:"$webresource:publisher_/icons/…",value:k,onChange:(e,a)=>$(a.value)}),o.jsx(p,{size:100,style:{color:r.colorNeutralForeground3},children:"Both image16 and image32 will be set to this path. Use SVG for best results across all DPI levels."})]}),u==="upload"&&o.jsxs("div",{className:n.uploadArea,children:[o.jsx(me,{fontSize:48,style:{opacity:.4}}),o.jsx(p,{children:"Drag an SVG file here, or click to browse"}),o.jsx(p,{size:200,style:{color:r.colorNeutralForeground3},children:"The file will be uploaded as a web resource in the active solution."}),o.jsx("input",{type:"file",accept:".svg",style:{display:"none"},id:"icon-upload-input",disabled:b,onChange:e=>{const a=e.target.files?.[0];e.target.value="",a&&ge(a)}}),o.jsx("label",{htmlFor:"icon-upload-input",style:{display:"inline-block",cursor:"pointer",padding:"6px 12px",background:r.colorBrandBackground,color:r.colorNeutralForegroundOnBrand,borderRadius:r.borderRadiusMedium,fontSize:r.fontSizeBase300},children:b?"Uploading...":"Browse for SVG"})]}),V&&o.jsx(p,{role:"alert",size:200,style:{color:r.colorPaletteRedForeground1,flexShrink:0},children:V}),_&&o.jsxs(p,{role:"status",size:200,style:{color:r.colorPaletteMarigoldForeground1,flexShrink:0},children:["Icon applied. ",_]})]}),o.jsxs(Le,{children:[o.jsx(Se,{prefix:"Saves to"}),o.jsx("div",{style:{flex:1}}),o.jsx(A,{appearance:"secondary",onClick:w,children:"Cancel"}),u==="fluent"&&o.jsx(A,{appearance:"primary",disabled:!i||b,onClick:()=>{de()},children:b?"Adding icon…":`Use ${i??"icon"}`}),u==="webresource"&&o.jsx(A,{appearance:"primary",disabled:!k||b,onClick:()=>{ue()},children:b?"Adding icon…":"Use web resource"})]})]})})})]})};export{Ye as IconPickerModal,Ye as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as a}from"./fluent-icons-BqJj6rDi.js";import{a as k}from"./monaco-BIO15LCS.js";import{ah as Te,D as Be,ai as He,aj as ze,ak as Fe,al as _e,am as Pe,a as Q,u as Ue,ab as We,Z as Je}from"./index-Di2_5czx.js";import{a as Ye}from"./xmlValidator-BkeotXuB.js";import{M as Ke}from"./MonacoEditor-uzfuRCpJ.js";import{D as Ve,i as Ze,j as Qe,k as et,l as tt,b as De,M as G,f as X,ae as le,m as ot,d as ee}from"./fluent-ui-QADO660t.js";import"./dnd-Cq8OftAq.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=(l,y)=>JSON.stringify(l)===JSON.stringify(y);function M(l){return l?Array.from(l.children):[]}function it(l){return Object.fromEntries(Array.from(l.attributes).map(y=>[y.name,y.value]))}function rt(l,y,c){const f=l.documentElement;if(f.tagName==="RibbonDiffXml")return f;const $=Array.from(l.getElementsByTagName("RibbonDiffXml")),S=Array.from(l.querySelectorAll("Entities > Entity")).flatMap(r=>{const A=M(r),v=A.find(D=>D.tagName==="RibbonDiffXml"),R=A.find(D=>D.tagName==="Name")?.textContent?.trim()??"";return v?[{name:R,rdx:v}]:[]}),w=$.find(r=>r.parentElement===f);if(S.length===0&&!w){if($.length===1)return $[0];throw new Error($.length===0?"No <RibbonDiffXml> element found.":`The XML has ${$.length} <RibbonDiffXml> elements and none belongs to a table or the application ribbon — paste just one.`)}const L=[...S.map(r=>r.name||"(unnamed table)"),...w?["the application ribbon"]:[]].join(", ");if(c){if(w)return w;throw new Error(`The XML has no application ribbon RibbonDiffXml (it has: ${L}). Open that table's ribbon to import its customizations.`)}const x=S.find(r=>r.name.toLowerCase()===y.toLowerCase());if(x)return x.rdx;throw new Error(`The XML has no RibbonDiffXml for ${y||"the loaded table"} (it has: ${L}). Load that table, or open the application ribbon for the application ribbon's customizations.`)}function at(l){switch(l){case"HomePageGrid":return"HomepageGrid";case"Form":return"Form";case"SubGridStandard":case"SubGridAssociated":return"SubGrid";default:return}}function lt(l){const y=l.languageCode??1033,c=l.entityLogicalName,f=new DOMParser().parseFromString(l.xml,"application/xml");if(f.querySelector("parsererror"))throw new Error("The XML is not well-formed.");const $=l.activeLocation==="Application",S=rt(f,c,$),w=new XMLSerializer,L=w.serializeToString(S),x=[],r=[],A=[],v=!!c&&new RegExp(`Mscrm\\.(HomepageGrid|SubGrid|Form)\\.${c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\.`,"i").test(L),R=$&&!(S===f.documentElement&&v);S!==f.documentElement?A.push(`Imported the RibbonDiffXml of ${R?"the application ribbon":c} from the document.`):$&&!R&&A.push(`The XML's Locations name the ${c} table, so it was imported as that table's customizations, not the application ribbon's.`);const D=R?"Application":fe.includes(l.activeLocation)?l.activeLocation:"HomepageGrid",j=Te(L,l.activeLocation,c),I=(e,t,o)=>{const s=new Map,n=new Map;for(const b of t)s.set(b.id,b),n.set(b.id,(n.get(b.id)??0)+1);for(const[b,g]of n)g>1&&A.push(`${o} ${b} is defined ${g} times in the XML — the last one was used.`);const u=Array.from(s.values()),i=[...e],p=[];let h=0;for(const b of u){const g=i.findIndex(T=>T.id===b.id);if(g>=0&&ve(i[g],b)){h++;continue}x.push(`${o} ${b.id} ${g>=0?"updated":"added"}`),g>=0?i[g]=b:i.push(b),p.push(b.id)}return{out:i,changedIds:p,unchanged:h}},m=I(l.commands,j.commands,"Command"),d=I(l.enableRules,j.enableRules,"Enable rule"),C=I(l.displayRules,j.displayRules,"Display rule"),B=I(l.locLabels,j.locLabels,"Label"),H=B.out,be=m.unchanged+d.unchanged+C.unchanged+B.unchanged,q=(e,t)=>e&&Pe(e,H,y)||t,N=JSON.parse(JSON.stringify(l.ribbons));let E=!1,z=0;const te=new Set,oe=e=>{if(R)return ce.slice().reverse();const t=pe.exec(e),o=t&&t[2]!=="{!EntityLogicalName}"?t[1]:D;return[o,...fe.filter(s=>s!==o),"Application"]},F=(e,t)=>{R&&e!=="Application"?A.push(`${t} is on the table's ribbon (${e}), not the application ribbon: the change is published with the table.`):!R&&e==="Application"&&A.push(`${t} was found only on the application ribbon: the change is published to the application ribbon and affects every table.`)},ne=[],O=(e,t)=>{e&&e!==t&&ne.push(e)},_=e=>{for(const t of oe(e))for(const o of N[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 oe(e)){const o=N[t].tabs.find(s=>s.id===e);if(o)return{location:t,tab:o}}},U=e=>{for(const t of oe(e)){const o=[];for(const s of N[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=M(S.querySelector(":scope > RuleDefinitions > TabDisplayRules")).map(e=>w.serializeToString(e)).join(""),se=e=>Te(`<RibbonDiffXml><UI><Ribbon><Tabs>${e}</Tabs></Ribbon></UI><RuleDefinitions><TabDisplayRules>${je}</TabDisplayRules></RuleDefinitions></RibbonDiffXml>`,l.activeLocation,c,H).ribbon.tabs[0],J=e=>w.serializeToString(e),ge=e=>se(`<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=q(t.labelToken,e.id),t.tooltipTitleToken&&(e.tooltipTitle=q(t.tooltipTitleToken,"")),t.tooltipBodyToken&&(e.tooltipBody=q(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 its text won't show unless another solution defines it (the pre-publish check warns).`)},$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),ie=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)?ie(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 ie(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?(E=!0,x.push(`Updated ${i.label} (${e}) on ${s.location}`),n.templateAlias||A.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)&&O(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 ie(n);K(i.group.buttons,xe(p,s)),F(i.location,n),O(e.getAttribute("Id"),`${n}.CustomAction`),E=!0,x.push(`Added ${p.label} (${n}) to ${i.group.id} on ${i.location}`)},Ce=(e,t)=>{const o=se(`<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:q(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 M(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),O(e.getAttribute("Id"),`${n}.CustomAction`),E=!0,x.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=se(J(t));if(!n)return r.push(`Tab ${s}: couldn't read the <Tab>.`);const u=n.tabDisplayRules.flatMap(T=>T.rules.map(Re=>Re.kind==="EntityRule"?at(Re.context):void 0)),i=R?"Application":u.find(T=>!!T)??pe.exec(s)?.[1]??D,h=Array.from(t.querySelectorAll(":scope > Groups > Group")).map(T=>Ce(T,void 0)).filter(T=>!!T),b=$e(t);Y({id:s,source:b});const g={...n,label:q(b.titleToken,s),source:b,sequence:t.getAttribute("Sequence")===null?o??n.sequence:n.sequence,groups:h};K(N[i].tabs,g),O(e.getAttribute("Id"),`${s}.CustomAction`),g.commandId&&(te.add(g.commandId),m.out.some(T=>T.id===g.commandId)||(m.out.push({id:g.commandId,enableRules:[],displayRules:[],actions:[]}),m.changedIds.push(g.commandId),A.push(`Tab ${s}: its Command ${g.commandId} has no CommandDefinition in the XML — an empty one was added.`))),E=!0,x.push(`Added tab ${g.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),O(e.getAttribute("HideActionId"),`${t}.HideAction`),E=!0,x.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=M(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)){O(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=M(S.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 N[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 te)V.add(e);const re=new Set,ae=new Set;for(const e of m.out)if(V.has(e.id)){e.enableRules.forEach(t=>re.add(t)),e.displayRules.forEach(t=>ae.add(t));for(const t of e.rawRuleRefs??[]){const o=nt.exec(t.xml);o&&(o[1]==="EnableRule"?re:ae).add(o[2])}}const Z=(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.`)};Z(m.changedIds,V,"Command","no button on the loaded ribbon uses it"),Z(d.changedIds,re,"Enable rule","no command a button uses references it"),Z(C.changedIds,ae,"Display rule","no command a button uses references it");const we=new Set(Array.from(J(S).matchAll(me),e=>e[1]));for(const e of ce)for(const t of N[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))we.add(u[1]);Z(B.changedIds,we,"Label","nothing references it");const qe=Array.from(S.querySelectorAll(":scope > RuleDefinitions > TabDisplayRules > TabDisplayRule"));for(const e of qe){const t=e.getAttribute("TabCommand")??"";te.has(t)||r.push(`TabDisplayRule for ${t}: only the display rules of tabs this import adds are imported.`);const o=M(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.`)}ne.length>0&&A.push(`Ids normalised: CBS publishes CustomAction / HideCustomAction ids as {control}.CustomAction, {control}.Override.CustomAction and {control}.HideAction, so ${ne.join(", ")} will be written under those ids.`),be+z>0&&x.push(`${be+z} control(s) / definition(s) were already up to date`);const ke=E||m.changedIds.length+d.changedIds.length+C.changedIds.length+B.changedIds.length>0;return{ribbons:E?N:l.ribbons,commands:m.out,enableRules:d.out,displayRules:C.out,locLabels:H,applied:x,notApplied:r,notes:A,changed:ke}}function ct(l,y){const c=Ue.getState(),f=lt({xml:l,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 y&&f.changed&&c.applyImport(f,`${f.applied.length} change(s)`),f}const he=({items:l})=>a.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:"20px",maxHeight:"160px",overflowY:"auto"},children:l.map((y,c)=>a.jsx("li",{children:a.jsx(De,{size:200,children:y})},c))}),$t=()=>{const l=Q(d=>d.importXmlOpen),y=Q(d=>d.importXmlSeed),c=Q(d=>d.importXmlNote),f=Q(d=>d.closeImportXml),[$,S]=k.useState(""),[w,L]=k.useState([]),[x,r]=k.useState(null),[A,v]=k.useState("");k.useEffect(()=>{l&&(S(y),L([]),r(null),v(""))},[l,y]);const R=d=>{S(d),x?.imported||r(null)},D=()=>{const d=Ye($);return L(d),d.every(C=>C.severity==="warning")},j=d=>{if(D()){v("");try{r({result:ct($,d),imported:d})}catch(C){r(null),v(C instanceof Error?C.message:String(C))}}},I=x?.imported===!0,m=x?.result;return a.jsx(Ve,{open:l,onOpenChange:()=>f(),children:a.jsxs(Ze,{style:{maxWidth:"960px",width:"92vw",height:"80vh",maxHeight:"860px"},children:[a.jsx(Qe,{children:"Import RibbonDiffXml"}),a.jsxs(et,{style:{height:"100%",display:"flex",flexDirection:"column"},children:[a.jsxs(tt,{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",gap:"8px"},children:[a.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."}),c&&!$&&a.jsx(G,{intent:"info",children:a.jsx(X,{children:c})}),a.jsx("div",{style:{flex:1,minHeight:0},children:a.jsx(Ke,{language:"xml",value:$,onChange:R,readOnly:I,height:"100%",options:{wordWrap:"on",lineNumbers:"on",padding:{top:8}}})}),w.length>0&&a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:w.map((d,C)=>a.jsx(G,{intent:d.severity==="warning"?"warning":"error",children:a.jsxs(X,{children:[d.message,d.lineHint?` (${d.lineHint})`:""]})},C))}),A&&a.jsx(G,{intent:"error",children:a.jsx(X,{children:A})}),m&&a.jsx(G,{intent:m.changed?"success":"info",layout:"multiline",children:a.jsxs(X,{children:[a.jsx(le,{children:I?m.changed?"Imported — review the changes, then publish":"Nothing to import — the session already has all of it":"Preview — nothing has changed yet"}),m.applied.length>0&&a.jsx(he,{items:m.applied})]})}),m&&m.notes.length>0&&a.jsx(G,{intent:"info",layout:"multiline",children:a.jsxs(X,{children:[a.jsx(le,{children:"Good to know"}),a.jsx(he,{items:m.notes})]})}),m&&m.notApplied.length>0&&a.jsx(G,{intent:"warning",layout:"multiline",children:a.jsxs(X,{children:[a.jsx(le,{children:I?"Not imported / won't be published":"Can't be imported / won't be published"}),a.jsx(he,{items:m.notApplied})]})})]}),a.jsx(ot,{children:I?a.jsx(ee,{appearance:"primary",onClick:f,children:"Close"}):a.jsxs(a.Fragment,{children:[a.jsx(ee,{appearance:"secondary",onClick:f,children:"Cancel"}),a.jsx(ee,{appearance:"secondary",onClick:()=>j(!1),disabled:!$.trim(),children:"Preview"}),a.jsx(ee,{appearance:"primary",onClick:()=>j(!0),disabled:!$.trim(),children:"Import"})]})})]})]})})};export{$t as ImportXmlModal,$t as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as t,h as J,cq as V,co as Y,z as Q,d6 as Z}from"./fluent-icons-BqJj6rDi.js";import{R,a as L}from"./monaco-BIO15LCS.js";import{a as N,u as S,d as ee,aq as w,ar as te,as as oe,at as le}from"./index-Di2_5czx.js";import{D as ae,i as ie,k as ne,j as se,aa as re,B as W,d as z,l as de,I as ce,b as X,t as s,T as U,m as pe}from"./fluent-ui-QADO660t.js";import"./dnd-Cq8OftAq.js";const y={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:"🇪🇸"}},ge=Object.keys(y).map(Number),ue=Q({surface:{width:"760px",maxWidth:"95vw",maxHeight:"80vh"},body:{display:"flex",flexDirection:"column",gap:s.spacingHorizontalM,overflowY:"auto"},chipRow:{display:"flex",flexWrap:"wrap",gap:s.spacingHorizontalXS,alignItems:"center"},chip:{cursor:"pointer",userSelect:"none"},table:{width:"100%",borderCollapse:"collapse"},th:{textAlign:"left",fontSize:s.fontSizeBase100,fontWeight:s.fontWeightSemibold,color:s.colorNeutralForeground3,paddingBottom:s.spacingHorizontalXS,borderBottom:`1px solid ${s.colorNeutralStroke2}`},td:{verticalAlign:"top",paddingTop:s.spacingHorizontalXS,paddingBottom:s.spacingHorizontalXS,paddingRight:s.spacingHorizontalS,borderBottom:`1px solid ${s.colorNeutralStroke3}`},langCell:{whiteSpace:"nowrap",width:"160px"},actionCell:{width:"40px"},insertBreakBtn:{fontSize:s.fontSizeBase100,height:"20px",minWidth:"unset",padding:`0 ${s.spacingHorizontalXS}`},noteBar:{backgroundColor:s.colorNeutralBackground3,borderRadius:s.borderRadiusMedium,padding:`${s.spacingHorizontalXS} ${s.spacingHorizontalS}`,fontSize:s.fontSizeBase100,color:s.colorNeutralForeground3}}),Se=()=>{const i=ue(),u=N(e=>e.localizationEditorOpen),h=N(e=>e.localizationEditorButtonId),f=N(e=>e.closeLocalizationEditor),p=S(e=>e.locLabels),B=S(e=>e.upsertLocLabel),_=S(e=>e.batch),K=S(e=>e.setButtonProp),D=S(e=>e.ribbons),d=S(e=>e.baseLanguageCode),C=R.useMemo(()=>{if(h){for(const[e,o]of Object.entries(D))for(const a of o.tabs)for(const c of a.groups)for(const l of ee(c))if(l.id===h)return{button:l,location:e,tabId:a.id,groupId:c.id}}},[D,h]),n=C?.button,j=n?.source,b=n?w(j?.labelToken,te(n.id),n.label,p,d):null,m=n?w(j?.tooltipTitleToken,oe(n.id),n.tooltipTitle,p,d):null,x=n?w(j?.tooltipBodyToken,le(n.id),n.tooltipBody,p,d):null,T=n?[[b,j?.labelToken],[m,j?.tooltipTitleToken],[x,j?.tooltipBodyToken]].filter(([e,o])=>e===null&&o).map(([,e])=>e.slice(11)).filter((e,o,a)=>a.indexOf(e)===o):[],E=L.useCallback(()=>{const e=p.find(l=>l.id===b),o=p.find(l=>l.id===m),a=p.find(l=>l.id===x),c=new Set([d]);return e?.titles.forEach(l=>c.add(l.languageCode)),o?.titles.forEach(l=>c.add(l.languageCode)),a?.titles.forEach(l=>c.add(l.languageCode)),Array.from(c).sort((l,r)=>l===d?-1:r===d?1:l-r).map(l=>l===d?{lcid:l,label:n?.label??"",tooltipTitle:n?.tooltipTitle??"",tooltipBody:n?.tooltipBody??""}:{lcid:l,label:e?.titles.find(r=>r.languageCode===l)?.description??"",tooltipTitle:o?.titles.find(r=>r.languageCode===l)?.description??"",tooltipBody:a?.titles.find(r=>r.languageCode===l)?.description??""})},[p,b,m,x,d,n]),[g,k]=L.useState([]),[$,H]=L.useState("");R.useEffect(()=>{u&&k(E())},[u,E]);const I=(e,o,a)=>{k(c=>c.map(l=>l.lcid===e?{...l,[o]:a}:l))},A=(e,o,a)=>{if(!a)return;const c=a.selectionStart??a.value.length,l=a.selectionEnd??a.value.length,r=g.find(G=>G.lcid===e)?.[o]??"",v=r.slice(0,c)+""+r.slice(l);I(e,o,v)},F=()=>{const e=parseInt($,10);!e||g.find(o=>o.lcid===e)||(k(o=>[...o,{lcid:e,label:"",tooltipTitle:"",tooltipBody:""}]),H(""))},O=e=>{e!==d&&k(o=>o.filter(a=>a.lcid!==e))},M=()=>{if(!n)return;const e=l=>g.filter(r=>r[l]).map(r=>({languageCode:r.lcid,description:r[l]})),o=g.find(l=>l.lcid===d),a={};o&&b&&o.label&&o.label!==n.label&&(a.label=o.label),o&&m&&o.tooltipTitle!==(n.tooltipTitle??"")&&(a.tooltipTitle=o.tooltipTitle||void 0),o&&x&&o.tooltipBody!==(n.tooltipBody??"")&&(a.tooltipBody=o.tooltipBody||void 0);const c=(l,r)=>!!l&&(p.some(v=>v.id===l)||e(r).some(v=>v.languageCode!==d));_(()=>{C&&Object.keys(a).length>0&&K(C.location,C.tabId,C.groupId,n.id,a),b&&c(b,"label")&&e("label").length>0&&B({id:b,titles:e("label")}),m&&c(m,"tooltipTitle")&&e("tooltipTitle").length>0&&B({id:m,titles:e("tooltipTitle")}),x&&c(x,"tooltipBody")&&e("tooltipBody").length>0&&B({id:x,titles:e("tooltipBody")})}),f()},q=g.find(e=>e.lcid===d);return t.jsx(ae,{open:u,onOpenChange:(e,o)=>!o.open&&f(),children:t.jsx(ie,{className:i.surface,children:t.jsxs(ne,{children:[t.jsxs(se,{action:t.jsx(z,{appearance:"subtle",icon:t.jsx(J,{}),onClick:f,"aria-label":"Close"}),children:[t.jsxs(re,{children:["Translations — ",q?.label||h||"Button"]}),t.jsxs(W,{appearance:"tint",size:"small",style:{marginLeft:8},children:[g.length," language",g.length!==1?"s":""]})]}),t.jsxs(de,{className:i.body,children:[t.jsxs("div",{className:i.chipRow,children:[g.map(e=>{const o=y[e.lcid];return t.jsxs(W,{className:i.chip,appearance:e.label?"filled":"outline",color:e.label?"brand":"informative",size:"medium",children:[o?.flag??"🌐"," ",o?.name??`LCID ${e.lcid}`,e.lcid!==d&&t.jsx("span",{style:{marginLeft:4,cursor:"pointer",opacity:.7},onClick:()=>O(e.lcid),"aria-label":`Remove ${o?.name}`,children:"×"})]},e.lcid)}),t.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[t.jsx(ce,{size:"small",style:{width:"180px"},placeholder:"LCID or language…",value:$,onChange:(e,o)=>H(o.value),list:"lcid-list",onKeyDown:e=>e.key==="Enter"&&F()}),t.jsx("datalist",{id:"lcid-list",children:ge.filter(e=>!g.find(o=>o.lcid===e)).map(e=>t.jsxs("option",{value:String(e),children:[y[e]?.flag," ",y[e]?.name," (",e,")"]},e))}),t.jsx(z,{size:"small",appearance:"subtle",icon:t.jsx(V,{}),onClick:F,"aria-label":"Add language"})]})]}),t.jsxs("div",{className:i.noteBar,children:["💡 LCID ",d," (",y[d]?.name??"base language",`) is the organisation's base language and cannot be removed. Use "Insert " to force a line break in long labels.`]}),T.length>0&&t.jsxs("div",{className:i.noteBar,children:[T.join(", ")," ",T.length===1?"is a label":"are labels"," of another solution, shared with the controls that use ",T.length===1?"it":"them",", so ",T.length===1?"it isn't":"they aren't"," edited here. Change the text in Properties to give this button a label of its own, then add translations."]}),t.jsxs("table",{className:i.table,children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:i.th,style:{width:"160px"},children:"Language"}),t.jsx("th",{className:i.th,children:"Label"}),t.jsx("th",{className:i.th,children:"Tooltip title"}),t.jsx("th",{className:i.th,children:"Tooltip body"}),t.jsx("th",{className:i.th,style:{width:"40px"}})]})}),t.jsx("tbody",{children:g.map(e=>{const o=y[e.lcid];return t.jsxs("tr",{children:[t.jsxs("td",{className:`${i.td} ${i.langCell}`,children:[t.jsxs(X,{size:200,children:[o?.flag??"🌐"," ",o?.name??`LCID ${e.lcid}`]}),t.jsx("br",{}),t.jsx(X,{size:100,style:{color:s.colorNeutralForeground3},children:e.lcid})]}),t.jsx("td",{className:i.td,children:t.jsx(P,{value:e.label,disabled:!b,onChange:a=>I(e.lcid,"label",a),onInsertBreak:a=>A(e.lcid,"label",a)})}),t.jsx("td",{className:i.td,children:t.jsx(P,{value:e.tooltipTitle,disabled:!m,onChange:a=>I(e.lcid,"tooltipTitle",a),onInsertBreak:a=>A(e.lcid,"tooltipTitle",a)})}),t.jsx("td",{className:i.td,children:t.jsx(he,{value:e.tooltipBody,disabled:!x,onChange:a=>I(e.lcid,"tooltipBody",a)})}),t.jsx("td",{className:`${i.td} ${i.actionCell}`,children:e.lcid!==d&&t.jsx(U,{content:"Remove this language",relationship:"label",children:t.jsx(z,{appearance:"subtle",size:"small",icon:t.jsx(Y,{}),onClick:()=>O(e.lcid),"aria-label":"Remove language"})})})]},e.lcid)})})]})]}),t.jsxs(pe,{children:[t.jsx(z,{appearance:"secondary",onClick:f,children:"Cancel"}),t.jsx(z,{appearance:"primary",onClick:M,children:"Save translations"})]})]})})})};function P({value:i,disabled:u,onChange:h,onInsertBreak:f}){const p=R.useRef(null);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("input",{ref:p,style:{width:"100%",fontFamily:"inherit",fontSize:13,padding:"3px 6px",border:"1px solid var(--colorNeutralStroke1)",borderRadius:4,boxSizing:"border-box"},value:i,disabled:u,onChange:B=>h(B.target.value)}),t.jsx(U,{content:"Insert Dataverse line break ()",relationship:"label",children:t.jsxs("button",{type:"button",disabled:u,onClick:()=>f(p.current),style:{fontSize:11,border:"none",background:"none",color:"var(--colorNeutralForeground3)",cursor:"pointer",padding:0,textAlign:"left",display:"flex",alignItems:"center",gap:2},children:[t.jsx(Z,{fontSize:12})," Insert ⏎"]})})]})}function he({value:i,disabled:u,onChange:h}){return t.jsx("textarea",{style:{width:"100%",fontFamily:"inherit",fontSize:13,padding:"3px 6px",border:"1px solid var(--colorNeutralStroke1)",borderRadius:4,boxSizing:"border-box",resize:"vertical",minHeight:"42px"},value:i,disabled:u,onChange:f=>h(f.target.value),rows:2})}export{Se as LocalizationEditor,Se as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as e}from"./fluent-icons-BqJj6rDi.js";import{a as S}from"./monaco-BIO15LCS.js";import{a as B,u as i,ab as b,Z as m,d as O,ac as G,P as K}from"./index-Di2_5czx.js";import{D as _,i as q,j as z,k as M,l as U,F as C,I as Y,S as Z,b as $,m as H,d as I}from"./fluent-ui-QADO660t.js";import"./dnd-Cq8OftAq.js";const tt=()=>{const n=B(t=>t.newButtonGroupId),l=B(t=>t.closeNewButton),v=i(t=>t.createButton),w=i(t=>t.upsertCommand),y=i(t=>t.batch),N=b(t=>t.selectButtonInContext),D=m(t=>t.publisherPrefix),E=m(t=>t.activeSolution),s=b(t=>t.location),k=b(t=>t.tabId),P=m(t=>t.activeEntity),R=n!==null,[r,p]=S.useState("New Button"),[x,h]=S.useState("button"),T=()=>{if(!n||!s)return;const t=E?.publisherPrefix?.trim()||D?.trim()||"new",a=P?.logicalName??"global",c=i.getState().ribbons,F=i.getState().commands,f=new Set(F.map(o=>o.id));for(const o of Object.values(c))for(const d of o.tabs)for(const L of d.groups)for(const A of O(L))f.add(A.id);const{id:g,commandId:j}=G(t,a,s,r,f),u=c[s].tabs.find(o=>o.groups.some(d=>d.id===n))?.id??k;if(!c[s].tabs.some(o=>o.id===u)){K.getState().logError("canvas",`Could not add the button: group ${n} was not found.`),l();return}y(()=>{v({location:s,tabId:u,groupId:n,button:{id:g,label:r,kind:x,templateAlias:"o1",commandId:j,hidden:!1,oob:!1,custom:!0,managed:!1}}),w({id:j,enableRules:[],displayRules:[],actions:[]})}),N(s,u,n,g),p("New Button"),h("button"),l()};return e.jsx(_,{open:R,onOpenChange:()=>l(),children:e.jsxs(q,{children:[e.jsx(z,{children:"New button"}),e.jsxs(M,{children:[e.jsxs(U,{children:[e.jsx(C,{label:"Label",required:!0,children:e.jsx(Y,{value:r,onChange:(t,a)=>p(a.value),autoFocus:!0})}),e.jsx(C,{label:"Kind",children:e.jsxs(Z,{value:x,onChange:(t,a)=>h(a.value),children:[e.jsx("option",{value:"button",children:"Button"}),e.jsx("option",{value:"flyout",children:"Flyout anchor"}),e.jsx("option",{value:"splitButton",children:"Split button"})]})}),e.jsx($,{size:200,style:{display:"block",marginTop:"8px"},children:"A command definition will be created automatically. You can edit it in the Command Editor."})]}),e.jsxs(H,{children:[e.jsx(I,{appearance:"secondary",onClick:l,children:"Cancel"}),e.jsx(I,{appearance:"primary",onClick:T,disabled:!r.trim(),children:"Create button"})]})]})]})})};export{tt as NewButtonModal,tt as default};
|