@sensinum/strapi-plugin-xecp 5.0.2 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +30 -16
  2. package/dist/admin/App-DCc6Nerz.js +30 -0
  3. package/dist/admin/App-FBmORCnP.mjs +2144 -0
  4. package/dist/admin/TruncatedTypography-CJdWCFOe.js +12 -0
  5. package/dist/admin/TruncatedTypography-D8gHowDS.mjs +49 -0
  6. package/dist/admin/{de-Bc7t3sCO.mjs → de-DPIfWiIq.mjs} +34 -2
  7. package/dist/admin/de-Dc27qqZI.js +1 -0
  8. package/dist/admin/{en-16Qqparh.mjs → en-CCG4TklL.mjs} +34 -2
  9. package/dist/admin/en-CPGWvai6.js +1 -0
  10. package/dist/admin/{fr-CMzm8jIl.mjs → fr-DnzU_m4o.mjs} +34 -2
  11. package/dist/admin/fr-uAOzHrhn.js +1 -0
  12. package/dist/admin/{index-Bgk0cBQK.mjs → index-B21jnMBg.mjs} +5 -5
  13. package/dist/admin/{index-ogQgaRcB.js → index-B2NfpbcT.js} +1 -1
  14. package/dist/admin/{index-BNa83Wfu.js → index-BHf1dfyp.js} +1 -1
  15. package/dist/admin/{index-DQgqKBmR.mjs → index-CwNAiNVu.mjs} +1 -1
  16. package/dist/admin/index-DTADzNmo.mjs +651 -0
  17. package/dist/admin/index-jgDj_iIg.js +1 -0
  18. package/dist/admin/index.js +1 -1
  19. package/dist/admin/index.mjs +1 -1
  20. package/dist/admin/pl-B1KyPSlZ.js +1 -0
  21. package/dist/admin/{pl-CuTaHdsS.mjs → pl-F5zNdZs4.mjs} +34 -2
  22. package/dist/server/index.js +10 -10
  23. package/dist/server/index.mjs +8376 -7795
  24. package/package.json +1 -1
  25. package/dist/admin/App-COKB0PXI.mjs +0 -1958
  26. package/dist/admin/App-CxQAwCC4.js +0 -30
  27. package/dist/admin/TruncatedTypography-72wp11m4.js +0 -12
  28. package/dist/admin/TruncatedTypography-Df3hMZdB.mjs +0 -34
  29. package/dist/admin/de-B5M8juGn.js +0 -1
  30. package/dist/admin/en-DXWBDgkB.js +0 -1
  31. package/dist/admin/fr-CPWgcURq.js +0 -1
  32. package/dist/admin/index-BnS-25UL.mjs +0 -610
  33. package/dist/admin/index-C0CxNaV6.js +0 -1
  34. package/dist/admin/pl-Blw4wk9g.js +0 -1
package/README.md CHANGED
@@ -43,7 +43,8 @@ This plugin brings Cross Environment Content Promotion (XECP) to Strapi: move se
43
43
  - **Selective Content Promotion**: Choose exactly what moves to the target.
44
44
  - **Sync Job Control**: Start, monitor, cancel, and resume snapshot syncs (extra requests queue while one is running).
45
45
  - **Configurable Scope**: Include or exclude content types from the promotion graph.
46
- - **Media-Aware Promotion**: Transfer media only when opted in (uploads, replaces, removes, reorders, alt changes).
46
+ - **Media-Aware Promotion**: Copy Media Library files when include media is on (media fields, Blocks images, and Markdown file links).
47
+ - **Draft or Publish**: Promote as a draft by default, or publish selected documents (and the related content they bring along) in the same step.
47
48
 
48
49
  ## 🎨 Admin Panel Features
49
50
 
@@ -61,7 +62,13 @@ Entity comparison requires a local snapshot of the target. XECP syncs target ent
61
62
 
62
63
  Snapshot syncs use a **shared queue**: only one sync job runs at a time on the instance. If a snapshot is requested while another sync is already running, the new job is queued (FIFO) and starts automatically when the active job finishes. A content type cannot have more than one running or queued sync at once.
63
64
 
64
- On the home page, operators pick a content type, review differences between local entries and the snapshot, select what to promote (including related content when applicable), and optionally opt in to media updates. XECP then pushes the selected content to the target.
65
+ On the home page, users pick a content type, review differences between local entries and the snapshot, select what to promote (including related content when applicable), and can turn on include media to copy Media Library files. XECP then pushes the selected entries to the target.
66
+
67
+ ### Draft or publish
68
+
69
+ Promoted content is saved as a **draft** on the target by default, so nothing goes live until it is published. Check **Publish** for a document in the promote dialog to publish it instead; related content promoted with it is published too, and only once its relations are in place. Content types without draft & publish are always published.
70
+
71
+ The promotion results show which entries were published and which were saved as drafts. Comparison reflects the target's published content, so drafts keep showing as **New** or **Changed** until they are published.
65
72
 
66
73
  ## ⚠️ Important Considerations
67
74
 
@@ -69,7 +76,7 @@ On the home page, operators pick a content type, review differences between loca
69
76
 
70
77
  Promotion and meaningful entity comparison require compatible schemas between source and target. If schemas do not match, the home page shows a schema-mismatch alert and blocks promote / get-snapshot actions until the environments are aligned.
71
78
 
72
- Schema comparison is **not** run for every content type in the app. It covers only content types configured under **Settings → Content Promotion → Configuration**, excluding UIDs listed in `excludedContentTypes` and `nonPromotableContentTypes` (and a small set of plugin-owned types). Components are compared only when they are used by that scoped set. If no content types are configured, the comparison scope is empty and is treated as a match.
79
+ Schema comparison is **not** run for every content type in the app. It covers only content types configured under **Settings → Content Promotion → Configuration**, excluding content types listed in `excludedContentTypes` and `nonPromotableContentTypes` (and a small set of plugin-owned content types). Components are compared only when they are used by that scoped set. If no content types are configured, the comparison scope is empty and is treated as a match.
73
80
 
74
81
  ### Entity comparison depth
75
82
 
@@ -81,6 +88,10 @@ If the graph is deeper than this limit, the home page can warn that max depth wa
81
88
 
82
89
  XECP uses Strapi's default Content API endpoints to retrieve, create, and update content on the target environment. All default endpoints used by XECP must remain available, and their standard response structures must not be modified. Replacing these endpoints or changing their responses may prevent snapshot synchronization, comparison, or content promotion from working correctly.
83
90
 
91
+ ### Private fields
92
+
93
+ Strapi's Content API never returns private fields (fields marked **Private** in the Content-Type Builder, or listed as private attributes in the app's configuration), so XECP cannot read their values on the target. Entity comparison ignores them: a change made only to a private field does not mark an entry as changed. A private field cannot be used as a unique key or as an environment-specific field. The comparison view shows how many fields of the selected content type are private, with the list in a tooltip.
94
+
84
95
  ### Target environment credentials
85
96
 
86
97
  The target API token is stored encrypted using the plugin `encryptionKey`. Use a dedicated **Custom** API token with at least:
@@ -92,21 +103,15 @@ The target API token is stored encrypted using the plugin `encryptionKey`. Use a
92
103
  | **Content-Type Builder** | `getContentTypes`, `getComponents` | Schema comparison |
93
104
  | **Upload** | `find`, `upload` | Media match (`GET /api/upload/files`) and upload / replace (`POST /api/upload`) |
94
105
 
95
- Grant these for every content type in Configuration that can be promoted or appears as related content. Do not grant delete unless required for other reasons — XECP does not delete remote entries.
106
+ Grant these for every content type in Configuration that can be promoted or appears as related content. Do not grant delete unless required for other reasons. XECP does not delete remote entries.
96
107
 
97
108
  ### Media uploads
98
109
 
99
- When promoting media, the plugin uses Strapi’s **Upload API**. Uploaded files are stored in the **API Uploads** folder. This destination is fixed by Strapi’s upload pipeline and **cannot be changed** by the plugin.
110
+ When include media is on, the plugin uses Strapi’s **Upload API** to reuse, replace, or upload library files. That setting covers schema **media** fields, **Blocks** image nodes, and **Markdown** (`richtext`) file links. There is no separate checkbox for Blocks or Markdown. Uploaded files are stored in the **API Uploads** folder. This destination is fixed by Strapi’s upload pipeline and **cannot be changed** by the plugin. Replacing images that already exist on the target environment causes them to **lose folder info** and appear in the **root** Media Library folder, while the folder file count is **not updated**. This is a **Strapi bug**, not XECP behaviour.
100
111
 
101
- **Media fields are updated only when the “Update media” checkbox is selected** for the promoted entries. That includes not only uploading or replacing files, but also:
112
+ With include media on, source files are copied to the target library and media fields / embedded URLs are pointed at those target files. Removing media from entity fields, reordering files, or changing media metadata (alternative text, caption) requires include media.
102
113
 
103
- - removing media from entity fields
104
- - reordering media
105
- - changing media metadata
106
-
107
- Without “Update media” selected, those field changes are not applied on the target.
108
-
109
- Replacing images that already exist on the target environment causes them to **lose folder info** and appear in the **root** Media Library folder, while the folder file count is **not updated**. This is a **Strapi bug**, not XECP behaviour.
114
+ With include media off, the entry is still promoted. New entries are created without media files. Updates keep the target’s existing library files.
110
115
 
111
116
  ## 🔧 Configuration
112
117
 
@@ -131,7 +136,7 @@ module.exports = {
131
136
  staleSyncLockMs: 6 * 60 * 1000,
132
137
  /**
133
138
  * Optional. Content types excluded from the promotion graph and remote push,
134
- * but still configurable as related types in settings.
139
+ * but still configurable as related content types in settings.
135
140
  */
136
141
  nonPromotableContentTypes: [],
137
142
  /**
@@ -139,6 +144,14 @@ module.exports = {
139
144
  * (not in settings, comparison, or promotion).
140
145
  */
141
146
  excludedContentTypes: [],
147
+ /**
148
+ * Optional. Fields each environment keeps for itself (for example per-environment
149
+ * counters). They are ignored when comparing content and are not overwritten on promote.
150
+ * Use dotted paths for fields inside components and dynamic zones.
151
+ */
152
+ environmentSpecificFields: {
153
+ 'api::article.article': ['views', 'stats.views'],
154
+ },
142
155
  },
143
156
  },
144
157
  };
@@ -150,8 +163,9 @@ Then configure the target environment and promotable content types under **Setti
150
163
 
151
164
  - `encryptionKey` (string, **required**): Exactly 32 characters. Encrypts the target environment API key.
152
165
  - `staleSyncLockMs` (number, optional): Maximum duration for a running sync job before it is considered stale.
153
- - `nonPromotableContentTypes` (string[], optional): UIDs excluded from promotion / remote push / content hashes, but allowed as related types in settings.
154
- - `excludedContentTypes` (string[], optional): UIDs fully ignored by XECP.
166
+ - `nonPromotableContentTypes` (string[], optional): content types excluded from promotion / remote push / content hashes, but allowed as related content types in settings.
167
+ - `excludedContentTypes` (string[], optional): content types fully ignored by XECP.
168
+ - `environmentSpecificFields` (object, optional): per content type, a list of field names (dotted paths for fields inside components and dynamic zones) that stay specific to each environment. They do not affect comparison status and promote leaves the target's value untouched. Works on any field except relations and whole components or dynamic zones; the unique key cannot be listed. Run a snapshot sync after changing this list.
155
169
 
156
170
  ### Environment variables
157
171
 
@@ -0,0 +1,30 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),C=require("@strapi/strapi/admin"),B=require("react-router-dom"),r=require("./index-BHf1dfyp.js"),re=require("./queryKeys-B_GC_f73.js"),s=require("@strapi/design-system"),A=require("@strapi/icons"),j=require("react"),S=require("react-intl"),Ge=require("zod"),T=require("./TruncatedTypography-CJdWCFOe.js"),E=require("@tanstack/react-query"),Ve=require("styled-components"),ke=e=>e&&e.__esModule?e:{default:e},te=ke(Ge),fe=ke(Ve),Ye=120*1e3,Xe=()=>{const{get:e}=C.useFetchClient();return E.useQuery({queryKey:[re.LICENSE_QUERY_KEY,"status"],staleTime:Ye,queryFn:async()=>{const{data:n}=await e(`/${r.URL_PREFIX}/license/status`);return n}})},Se=(e,n)=>n?e.find(o=>o.value===n)?.label??"":"",We=({name:e,onClear:n,onChange:o,options:a,value:i,placeholder:c,disabled:d})=>{const[l,u]=j.useState(()=>Se(a,i));return j.useEffect(()=>{u(Se(a,i))},[i,a]),t.jsx(s.Combobox,{name:e,autocomplete:"list",onClear:n,onChange:o,placeholder:c,onTextValueChange:u,value:i,textValue:l,disabled:d,width:"100%",children:a.map(({key:g,label:m,value:h})=>t.jsx(s.ComboboxOption,{value:h,children:m},g))})},Je="90vh",ie=({open:e,onClose:n,title:o,children:a,isConfirmButtonLoading:i=!1,confirmButtonText:c,isConfirmButtonDisabled:d=!1,onSubmit:l,cancelButtonText:u,showConfirmButton:g=!0,fillMaxHeight:m=!1,maxWidth:h})=>{const{formatMessage:p}=S.useIntl();return t.jsx(s.Modal.Root,{open:e,onOpenChange:()=>n(),children:t.jsxs(s.Modal.Content,{style:{...m&&{height:Je},...h&&{maxWidth:h}},children:[t.jsx(s.Modal.Header,{children:t.jsx(s.Modal.Title,{children:o})}),t.jsx(s.Modal.Body,{children:a}),t.jsx(s.Modal.Footer,{style:g?void 0:{justifyContent:"flex-end"},children:g?t.jsxs(t.Fragment,{children:[t.jsx(s.Modal.Close,{children:t.jsx(s.Button,{variant:"tertiary",onClick:n,children:u||p({id:r.getTranslation("common.button.close")})})}),t.jsx(s.Button,{loading:i,disabled:d,onClick:l,children:c||p({id:r.getTranslation("common.button.submit")})})]}):t.jsx(s.Modal.Close,{children:t.jsx(s.Button,{variant:"tertiary",onClick:n,children:u||p({id:r.getTranslation("common.button.close")})})})})]})})},V={all:["sync"],lists:()=>[...V.all,"list"],list:e=>[...V.lists(),{uid:e}]},Re="entities-comparison",Ze=({uid:e,page:n=1,pageSize:o=10,enabled:a=!0})=>{const{get:i}=C.useFetchClient();return E.useQuery({queryKey:[Re,{uid:e,page:n,pageSize:o}],queryFn:async()=>{const{data:c}=await i(`/${r.URL_PREFIX}/entity-comparison/${e}?page=${n}&pageSize=${o}`);return c},enabled:!!e&&a})},ve=e=>{e.invalidateQueries({queryKey:[Re]})},le=(e,n)=>{e.invalidateQueries({queryKey:n?V.list(n):V.lists()}),ve(e)},ze=()=>{const{post:e}=C.useFetchClient(),n=E.useQueryClient();return E.useMutation({mutationFn:async o=>await e(`/${r.URL_PREFIX}/snapshot/${o}/sync`),onSuccess:(o,a)=>{le(n,a)}})},Fe=({open:e,onClose:n,contentTypeUid:o})=>{const{formatMessage:a}=S.useIntl(),{mutate:i,isPending:c,error:d,reset:l}=ze(),u=()=>{n(),l()},g=()=>{i(o,{onSuccess:n})};return t.jsx(ie,{open:e,onClose:u,onSubmit:g,title:a({id:r.getTranslation("homePage.modal.getNewSnapshot.title")}),confirmButtonText:a({id:r.getTranslation("homePage.modal.getNewSnapshot.confirmButtonText")}),isConfirmButtonDisabled:c||!o,isConfirmButtonLoading:c,children:t.jsxs(s.Flex,{direction:"column",gap:4,alignItems:"stretch",children:[t.jsx(s.Typography,{variant:"omega",children:a({id:r.getTranslation("homePage.modal.getNewSnapshot.description")})}),d&&t.jsx(s.Typography,{variant:"omega",textColor:"danger500",children:T.formatApiError(d,a)})]})})},et=({contentTypeUid:e,selectedPromotionsLength:n,syncedAt:o,isGetSnapshotDisabled:a=!1,hasSnapshot:i,clearSelectedPromotions:c,canExecute:d,privateFields:l=[]})=>{const{formatMessage:u}=S.useIntl(),[g,m]=j.useState(!1),h=u({id:r.getTranslation("homePage.comparison.privateFields.tooltip")},{count:l.length,fields:l.join(", ")});return t.jsxs(s.Flex,{direction:"row",justifyContent:"space-between",alignItems:"center",marginBottom:1,marginTop:1,children:[e&&i?t.jsxs(s.Flex,{direction:"row",gap:3,alignItems:"center",children:[t.jsx(s.Typography,{variant:"omega",children:u({id:r.getTranslation("homePage.selectedEntities")},{count:n})}),n>0&&d?t.jsx(s.Button,{variant:"secondary",onClick:c,children:u({id:r.getTranslation("homePage.clearSelectedEntities")})}):null]}):null,o?t.jsxs(s.Flex,{direction:"row",gap:3,alignItems:"center",children:[t.jsxs(s.Flex,{direction:"row",gap:1,alignItems:"center",children:[t.jsx(s.Typography,{variant:"omega",textColor:"neutral600",children:u({id:r.getTranslation("homePage.lastSync")},{lastSync:new Date(o).toLocaleString()})}),t.jsx(s.Tooltip,{label:u({id:r.getTranslation("homePage.comparison.publishedOnlyHint")}),children:t.jsx(A.Information,{"aria-label":u({id:r.getTranslation("homePage.comparison.publishedOnlyHint")})})})]}),l.length>0?t.jsxs(t.Fragment,{children:[t.jsx(s.Typography,{variant:"omega",textColor:"neutral300","aria-hidden":!0,children:"|"}),t.jsxs(s.Flex,{direction:"row",gap:1,alignItems:"center",children:[t.jsx(s.Typography,{variant:"omega",textColor:"neutral600",children:u({id:r.getTranslation("homePage.comparison.privateFields.label")},{count:l.length})}),t.jsx(s.Tooltip,{label:h,children:t.jsx(A.Information,{"aria-label":h})})]})]}):null,d?t.jsx(s.Button,{variant:"secondary",onClick:()=>m(!0),disabled:a,children:u({id:r.getTranslation("homePage.getNewSnapshot")})}):null]}):null,d?t.jsx(Fe,{open:g,onClose:()=>m(!1),contentTypeUid:e}):null]})},tt=({canReadSettings:e})=>{const{formatMessage:n}=S.useIntl();return t.jsx(T.Alert,{title:n({id:r.getTranslation("homePage.alert.invalidLicense.title")}),variant:"danger",description:n({id:r.getTranslation(e?"homePage.alert.invalidLicense.description":"homePage.alert.invalidLicense.readOnlyDescription")}),action:e?t.jsx(s.Flex,{children:t.jsx(s.Link,{tag:B.Link,to:"/settings/xecp/about",children:n({id:r.getTranslation("homePage.alert.invalidLicense.linkText")})})}):void 0})},nt=({compareSchemasData:e,errorCompareSchemas:n})=>{const{formatMessage:o}=S.useIntl(),a=e&&!e?.isMatch,i=()=>o(a?{id:r.getTranslation("homePage.alert.schemaMismatch.title")}:{id:r.getTranslation("homePage.error")}),c=()=>{switch(!0){case a:return o({id:r.getTranslation("homePage.alert.schemaMismatch.description")});case!!n:return n;default:return o({id:r.getTranslation("homePage.somethingWentWrong")})}};return t.jsx(T.Alert,{title:i(),variant:"danger",children:c()})},ot=({contentTypeUid:e,hasExistingSnapshot:n,unconfiguredRelationsError:o,isGetSnapshotDisabled:a=!1,canExecute:i,canReadSettings:c})=>{const{formatMessage:d}=S.useIntl(),[l,u]=j.useState(!1);return!n&&!o?t.jsxs(t.Fragment,{children:[t.jsx(s.EmptyStateLayout,{content:d({id:r.getTranslation(i?"homePage.alert.noSync.description":"homePage.alert.noSync.readOnlyDescription")}),action:i?t.jsx(s.Button,{onClick:()=>u(!0),disabled:a,children:d({id:r.getTranslation("homePage.alert.noSync.linkText")})}):void 0}),i?t.jsx(Fe,{open:l,onClose:()=>u(!1),contentTypeUid:e}):null]}):t.jsxs(t.Fragment,{children:[o?t.jsx(T.Alert,{title:d({id:r.getTranslation("homePage.alert.unconfiguredRelations.title")}),variant:"danger",action:c?t.jsx(s.Link,{tag:B.Link,to:"/settings/xecp/configuration",children:d({id:r.getTranslation("homePage.alert.unconfiguredRelations.linkText")})}):void 0,description:d({id:r.getTranslation(c?"homePage.alert.unconfiguredRelations.description":"homePage.alert.unconfiguredRelations.readOnlyDescription")},{relations:o.unconfiguredRelations.join(", ")})}):null,t.jsx(s.EmptyStateLayout,{content:d({id:r.getTranslation("homePage.emptyState")})})]})},Te=e=>[e,...e.localizations??[]],Me=e=>(e??[]).flatMap(Te),st=(e,n)=>{const o=n?.find(a=>a.documentId===e);return o?Te(o):[]},at=e=>{const n=e[0];return n?{...n,localizations:e.slice(1)}:null},ce=(e,n)=>{if(!n)return e.uniqueKeyValue;const o=e?.[n];return typeof o=="string"||typeof o=="number"?String(o):e.uniqueKeyValue},ne=e=>({documentId:e.documentId,locale:e.locale??"default"}),Y=(e,n)=>e.documentId===n.documentId&&e.locale===n.locale,oe=(e,n)=>n.some(o=>Y(o,ne(e))),rt=e=>[...new Set(e.map(n=>n.documentId))],Ce=(e,n)=>{if(e.length===0)return!1;const o=e.filter(a=>n.has(a)).length;return o===0?!1:o===e.length?!0:"indeterminate"},be=(e,n,o)=>{const a=new Set(e);return o?a.add(n):a.delete(n),a},it=e=>e?.draftAndPublish===!1,lt=(e,n,o)=>e?"locked":n.some(a=>o.has(a))?"some":"none",ct=e=>(e??[]).filter(n=>!n.draftAndPublish),dt=(e,{mediaDocumentIds:n,publishDocumentIds:o})=>e.map(a=>({documentId:a,includeMedia:n.has(a),publish:o.has(a)})),Ie=(e,n)=>{const o=new Set(n),a=[...e].filter(i=>o.has(i));return a.length===e.size?e:new Set(a)},ut="homePage.missingUniqueKey",se={single:"homePage.hint.missingUniqueKey.single",allLocales:"homePage.hint.missingUniqueKey.allLocales",someLocales:"homePage.hint.missingUniqueKey.someLocales"},K=(e,n)=>e!=="up_to_date"&&n!=="missing_unique_key",mt=e=>{switch(!0){case e.every(n=>n.warning==="missing_unique_key"):return"allLocales";case e.some(n=>n.warning==="missing_unique_key"):return"someLocales";default:return null}},Le=(e,n,o)=>{if(!e)return"homePage.tooltip.noExecutePermission";switch(!0){case n==="up_to_date":return"homePage.tooltip.upToDate";case o==="missing_unique_key":return se.single;default:return null}},_e=(e,n)=>{if(!e)return"homePage.tooltip.noExecutePermission";switch(!0){case n.some(o=>K(o.status,o.warning)):return null;case n.every(o=>o.status==="up_to_date"):return"homePage.tooltip.allEntitiesUpToDate";case n.every(o=>o.warning==="missing_unique_key"):return se.allLocales;default:return se.someLocales}},xe=({checked:e,onCheckedChange:n,disable:o=!1,tooltipLabel:a=""})=>t.jsx("div",{onClick:i=>i.stopPropagation(),children:t.jsx(s.Tooltip,{label:o?a:"",align:"start",children:t.jsx(s.Checkbox,{checked:e,onCheckedChange:n,disabled:o})})}),de=({locale:e})=>{const{formatMessage:n}=S.useIntl();return e==="default"?t.jsx(s.Badge,{variant:"neutral",children:n({id:r.getTranslation("homePage.promotionResults.locale.nonLocalized")})}):t.jsx(s.Badge,{variant:"neutral",children:e})},gt=e=>{switch(e){case"new":return"homePage.table.status.new";case"changed":return"homePage.table.status.changed";case"up_to_date":return"homePage.table.status.upToDate";default:return"homePage.table.status.new"}},ht=e=>{switch(e){case"new":return"success";case"changed":return"danger";case"up_to_date":return"neutral";default:return"success"}},qe=({status:e})=>{const{formatMessage:n}=S.useIntl();return t.jsx(s.Badge,{variant:ht(e),children:n({id:r.getTranslation(gt(e))})})},pt=({shouldShow:e,message:n,tooltipLabel:o})=>e?t.jsx(s.Tooltip,{label:o,align:"start",children:t.jsxs(s.Flex,{direction:"row",gap:1,alignItems:"center",children:[t.jsx(A.WarningCircle,{fill:"warning500",width:20,height:20}),t.jsx(s.Typography,{variant:"pi",textColor:"warning500",children:n})]})}):null,ue=({uniqueKey:e,missingUniqueKeyScope:n,maxCharacters:o=40})=>{const{formatMessage:a}=S.useIntl();if(!n)return t.jsx(T.TruncatedTypography,{maxCharacters:o,text:e||"N/A",variant:"pi",textColor:"neutral600"});const i=a({id:r.getTranslation(ut)}),c=a({id:r.getTranslation(se[n])}),d=t.jsx(pt,{shouldShow:!0,tooltipLabel:c,message:i});return n==="someLocales"&&e?t.jsxs(s.Flex,{direction:"row",gap:2,alignItems:"center",children:[t.jsx(T.TruncatedTypography,{maxCharacters:o,text:e,variant:"pi",textColor:"neutral600"}),d]}):d},Ae=({entryTitle:e,uniqueKey:n,missingUniqueKeyScope:o,locale:a,titleMaxCharacters:i=60,checked:c,onCheckedChange:d,checkboxDisabled:l=!1,checkboxTooltipLabel:u,status:g})=>{const m=t.jsx(T.TruncatedTypography,{maxCharacters:i,text:e,variant:"omega",fontWeight:"semiBold"});return t.jsxs(t.Fragment,{children:[t.jsxs(s.Flex,{direction:"row",gap:4,alignItems:"center",children:[t.jsx(xe,{checked:c,onCheckedChange:d,disable:l,tooltipLabel:u}),a?t.jsxs(s.Flex,{direction:"row",gap:2,alignItems:"center",children:[t.jsx(de,{locale:a}),m]}):m,t.jsx(ue,{uniqueKey:n,missingUniqueKeyScope:o})]}),t.jsx(qe,{status:g})]})},yt=({entryTitle:e,uniqueKey:n,status:o,warning:a,locale:i,isChecked:c,onCheckItemChange:d,canExecute:l})=>{const{formatMessage:u}=S.useIntl(),g=!l||!K(o,a),m=Le(l,o,a);return t.jsx(s.Flex,{direction:"row",justifyContent:"space-between",alignItems:"center",background:"neutral0",style:{width:"100%",padding:"24px"},grow:1,gap:4,children:t.jsx(Ae,{entryTitle:e,uniqueKey:n,missingUniqueKeyScope:a==="missing_unique_key"?"single":null,locale:i,checked:c,onCheckedChange:d,checkboxDisabled:g,checkboxTooltipLabel:m?u({id:r.getTranslation(m)}):void 0,status:o})})},xt=({isAllCheckedInEntity:e,onCheckAllInEntity:n,entityWithLocalizations:o,selectedPromotions:a,onCheckItemChange:i,isIndeterminate:c,contentTypeMainField:d,canExecute:l})=>{const{formatMessage:u}=S.useIntl(),g=[{key:"checkbox"},{key:"locale",label:u({id:r.getTranslation("homePage.table.locale")})},{key:"entryTitle",label:u({id:r.getTranslation("homePage.table.entryTitle")})},{key:"key",label:u({id:r.getTranslation("homePage.table.key")})},{key:"status",label:u({id:r.getTranslation("homePage.table.status")})}],m=!o?.some(p=>K(p.status,p.warning)),h=_e(l,o??[]);return t.jsxs(s.Table,{colCount:g.length,rowCount:o?.length??0,children:[t.jsx(s.Thead,{children:t.jsx(s.Tr,{children:g.map(p=>t.jsx(s.Th,{children:p.key==="checkbox"?t.jsx(xe,{checked:c?"indeterminate":e,onCheckedChange:n,disable:m||!l,tooltipLabel:h?u({id:r.getTranslation(h)}):""}):t.jsx(s.Typography,{variant:"sigma",children:p.label})},p.key))})}),t.jsx(s.Tbody,{children:o?.map(p=>{const x=!l||!K(p.status,p.warning),P=Le(l,p.status,p.warning);return t.jsxs(s.Tr,{children:[t.jsx(s.Td,{children:t.jsx(xe,{checked:oe(p,a),onCheckedChange:i(p),disable:x,tooltipLabel:P?u({id:r.getTranslation(P)}):""})}),t.jsx(s.Td,{children:p?.locale?t.jsx(de,{locale:p.locale}):null}),t.jsx(s.Td,{children:t.jsx(T.TruncatedTypography,{maxCharacters:50,text:ce(p,d)||""})}),t.jsx(s.Td,{children:t.jsx(ue,{uniqueKey:p?.uniqueKeyValue,missingUniqueKeyScope:p?.warning==="missing_unique_key"?"single":null})}),t.jsx(s.Td,{children:t.jsx(qe,{status:p?.status})})]},`${p.documentId}-${p.locale}`)})})]})},ft=fe.default(s.Accordion.Trigger)`
2
+ width: 100%;
3
+ & > span:first-child {
4
+ width: 100%;
5
+ display: flex;
6
+ justify-content: space-between;
7
+ & > span {
8
+ width: 100%;
9
+ }
10
+ }
11
+ `,Tt=({uniqueKey:e,entityWithLocalizations:n,entryTitle:o,selectedPromotions:a,setSelectedPromotions:i,onCheckItemChange:c,contentTypeMainField:d,onRememberEntityGroup:l,canExecute:u})=>{const{formatMessage:g}=S.useIntl(),m=n.filter(y=>K(y.status,y.warning)),h=y=>{i(F=>{const N=m.map(k=>ne(k)),M=k=>n.some(R=>Y(k,ne(R)));return y?(l?.(n),[...F.filter(R=>!M(R)),...N]):F.filter(k=>!M(k))})},p=n?.some(y=>oe(y,a)),x=m.length>0&&m.every(y=>oe(y,a)),P=m.length===0,I=_e(u,n),D=mt(n),b=(()=>{switch(!0){case n?.some(y=>y?.status==="new"):return"new";case n?.some(y=>y?.status==="changed"):return"changed";default:return"up_to_date"}})(),w=p&&!x;return t.jsx(s.Accordion.Root,{style:{width:"100%"},size:"M",children:t.jsxs(s.Accordion.Item,{value:`${o}-${e}`,children:[t.jsx(s.Accordion.Header,{children:t.jsx(ft,{caretPosition:"right",children:t.jsx(s.Flex,{direction:"row",justifyContent:"space-between",alignItems:"center",style:{width:"100%"},grow:1,gap:4,children:t.jsx(Ae,{entryTitle:o,uniqueKey:e,missingUniqueKeyScope:D,checked:w?"indeterminate":x,onCheckedChange:h,checkboxDisabled:P||!u,checkboxTooltipLabel:I?g({id:r.getTranslation(I)}):void 0,status:b})})})}),t.jsx(s.Accordion.Content,{children:t.jsx(xt,{isAllCheckedInEntity:x,onCheckAllInEntity:h,entityWithLocalizations:n,selectedPromotions:a,onCheckItemChange:c,isIndeterminate:w,contentTypeMainField:d,canExecute:u})})]})})},Pt=({entities:e,contentTypeMainField:n,selectedPromotions:o,setSelectedPromotions:a,onRememberEntityGroup:i,canExecute:c})=>{const d=u=>g=>m=>{const h=ne(g);a(p=>m?p.some(x=>Y(x,h))?p:(i?.(u),[...p,h]):p.filter(x=>!Y(x,h)))},l=(u,g)=>{const m=ce(u,n),h=u?.uniqueKeyValue||"";return g.length>1?t.jsx(Tt,{uniqueKey:h,contentTypeMainField:n,entityWithLocalizations:g,entryTitle:m||"",selectedPromotions:o,setSelectedPromotions:a,onCheckItemChange:d(g),onRememberEntityGroup:i,canExecute:c}):t.jsx(yt,{entryTitle:m||"",uniqueKey:h,status:u?.status,warning:u?.warning,locale:u?.locale,isChecked:oe(u,o),onCheckItemChange:d(g)(u),canExecute:c})};return t.jsx("div",{children:e?.map((u,g)=>{const m=Te(u);return t.jsxs(j.Fragment,{children:[l(u,m),e?.length-1>g&&t.jsx(s.Divider,{})]},u?.documentId)})})},De=(e=!0)=>{const{get:n}=C.useFetchClient();return E.useQuery({queryKey:[re.PROMOTABLE_CONTENT_TYPES_QUERY_KEY],enabled:e,queryFn:async()=>{const{data:o}=await n(`/${r.URL_PREFIX}/promotion/promotable-content-types`);return o.contentTypes}})},jt=(e,n)=>{const{get:o}=C.useFetchClient();return E.useQuery({queryKey:[re.SETTINGS_QUERY_KEY,"related-content-types",e],queryFn:async()=>{const{data:a}=await o(`/${r.URL_PREFIX}/promotion/related-content-types`,{params:{contentTypeUid:e}});return a},enabled:!!e&&n})},St=()=>{const{post:e}=C.useFetchClient(),n=E.useQueryClient();return E.useMutation({mutationFn:async o=>{const{data:a}=await e(`/${r.URL_PREFIX}/promotion`,o);return a},onSuccess:()=>{ve(n)}})},Ct=(e,n)=>e.includes(n)?[n,...e.filter(o=>o!==n).sort()]:e.sort(),bt=e=>e.filter(n=>K(n.status,n.warning)).map(n=>n.locale??"default"),It=(e,n)=>e.length>0&&e.every(o=>n.includes(o)),Et=(e,n,o)=>{const a=new Map;for(const l of n??[])a.set(l.documentId,l);const i=Me(n),c=new Map;for(const l of e){const u=c.get(l.documentId)??[];u.push(l),c.set(l.documentId,u)}return[...new Set(e.map(l=>l.documentId))].map(l=>{const u=c.get(l)??[],g=a.get(l)??i.find(P=>P.documentId===l),m=g?.locale??"default",h=g??i.find(P=>u.some(I=>Y(I,{documentId:P.documentId,locale:P.locale??"default"}))),p=Ct(u.map(P=>P.locale),m),x=bt(st(l,n));return{documentId:l,title:h?ce(h,o)??l:l,locales:p,allLocalesSelected:It(x,p),uniqueKey:h?.uniqueKeyValue??null}})},ae=(e,n)=>n?.findLast(o=>o.uid===e)?.displayName??e,wt=e=>{const n=[e.summary,...e.dependencyResults.map(i=>i.summary)],o=n.reduce((i,c)=>i+c.failed,0),a=n.reduce((i,c)=>i+c.total,0);return o===0?"success":o>=a?"failure":"partial"},kt=["en","default"],Rt=e=>{for(const n of kt){const o=e.find(a=>a.locale===n);if(o?.uniqueKey!=null&&o.uniqueKey.length>0)return o.uniqueKey}return e.find(n=>n.uniqueKey!=null&&n.uniqueKey.length>0)?.uniqueKey??null},vt=(e,n,o)=>{if(e.uniqueKey!=null&&e.uniqueKey.length>0)return e.uniqueKey;const a=e.documentId??e.documentKey,i=Me(n).find(c=>c.documentId===a);if(i){const c=ce(i,o);if(c!=null&&String(c).length>0)return String(c)}return a},Ft=e=>{if(e.documentId!=null&&e.documentId.length>0)return e.documentId;const n=e.steps.find(a=>a.push.remoteDocumentId!=null&&a.push.remoteDocumentId.length>0)?.push.remoteDocumentId;if(n!=null&&n.length>0)return n;if(e.uniqueKey!=null&&e.uniqueKey.length>0)return e.uniqueKey;const o=e.groupKey.lastIndexOf("::");return o===-1?e.groupKey:e.groupKey.slice(0,o)},Mt={create:"created",update:"updated"},Be=e=>e.push.ok?e.push.skipped||e.action==="skip"?"skipped":Mt[e.action]:"failed",Lt=e=>{const n=e[0];return n?Be(n):"skipped"},_t=e=>{switch(e){case"failed":return"danger";case"skipped":return"neutral";case"updated":return"secondary";case"created":return"success";default:return"success"}},qt=e=>[...e].reverse().find(n=>n.push.ok&&n.push.writeStatus)?.push.writeStatus,X=e=>{const n=new Map;for(const o of e){const a=o.snapshotKey,i=n.get(a)??[];i.push(o),n.set(a,i)}return Array.from(n.entries()).map(([o,a])=>{const i=a.some(d=>!d.push.ok),c=a[a.length-1];return{groupKey:o,documentId:c.documentId,locale:c.locale,uniqueKey:c.uniqueKey,outcome:i?"failed":Lt(a),writeStatus:qt(a),steps:a,hasFailure:i}})},Ke=e=>{const n=X(e),o=new Map;for(const a of n){const i=Ft(a),c=o.get(i)??[];c.push(a),o.set(i,c)}return Array.from(o.entries()).map(([a,i])=>{const c=i.sort((d,l)=>d.locale.localeCompare(l.locale));return{documentKey:a,documentId:c[0]?.documentId,uniqueKey:Rt(c),localeEntries:c}})},At=(e,n)=>Ke(e).map(o=>({id:o.documentKey,title:vt(o,n?.comparedEntities,n?.contentTypeMainField),entries:o.localeEntries.flatMap(a=>a.steps)})),Ee=e=>{const n=X(e);return{entityCount:n.length,created:n.filter(o=>o.outcome==="created").length,updated:n.filter(o=>o.outcome==="updated").length,skipped:n.filter(o=>o.outcome==="skipped").length,failed:n.filter(o=>o.outcome==="failed").length,published:n.filter(o=>o.writeStatus==="published").length,drafts:n.filter(o=>o.writeStatus==="draft").length,locales:[...new Set(n.map(o=>o.locale))].sort()}},Dt=e=>{const n={total:0,created:0,updated:0,skipped:0,failed:0},o=X(e);for(const a of o){const i=a.steps[0];i&&(n.total+=1,n[Be(i)]+=1)}return n},Bt=e=>X(e).filter(n=>n.steps.some(o=>o.hasUnlinkedRelations)).length,Kt=(e,n)=>{const o=Ke(e.entries),a=Ee(e.entries),i=[...new Set(e.selections.map(m=>m.locale))].sort(),c=e.dependencyResults.map(m=>{const h=Ee(m.entries);return{contentTypeUid:m.contentTypeUid,displayName:ae(m.contentTypeUid,n),...h}}),d=a.entityCount+c.reduce((m,h)=>m+h.entityCount,0),l=a.failed+c.reduce((m,h)=>m+h.failed,0),u=a.published+c.reduce((m,h)=>m+h.published,0),g=a.drafts+c.reduce((m,h)=>m+h.drafts,0);return{outcome:wt(e),primaryDisplayName:ae(e.contentTypeUid,n),primaryEntityCount:o.length,dependencySummaries:c,totalEntityCount:d,totalFailed:l,totalPublished:u,totalDrafts:g,selectionLocales:i,dependencyContentTypeCount:e.dependencyResults.length,mediaSummary:e.mediaSummary}},Ne=({entries:e,showFailuresOnly:n=!1})=>{const{formatMessage:o}=S.useIntl(),a=j.useMemo(()=>{const i=X(e);return n?i.filter(c=>c.hasFailure):i},[e,n]);return a.length===0?t.jsx(s.Typography,{variant:"omega",textColor:"neutral600",children:o({id:r.getTranslation(n?"homePage.promotionResults.noFailures":"homePage.promotionResults.noEntries")})}):t.jsxs(s.Table,{colCount:4,rowCount:a.length,children:[t.jsx(s.Thead,{children:t.jsxs(s.Tr,{children:[t.jsx(s.Th,{children:t.jsx(s.Typography,{variant:"sigma",children:o({id:r.getTranslation("homePage.table.locale")})})}),t.jsx(s.Th,{children:t.jsx(s.Typography,{variant:"sigma",children:o({id:r.getTranslation("homePage.table.key")})})}),t.jsx(s.Th,{children:t.jsx(s.Typography,{variant:"sigma",children:o({id:r.getTranslation("homePage.promotionResults.table.outcome")})})}),t.jsx(s.Th,{children:t.jsx(s.Typography,{variant:"sigma",children:o({id:r.getTranslation("homePage.promotionResults.table.targetStatus")})})})]})}),t.jsx(s.Tbody,{children:a.map(i=>t.jsxs(s.Tr,{children:[t.jsx(s.Td,{children:t.jsx(de,{locale:i.locale})}),t.jsx(s.Td,{children:t.jsx(ue,{uniqueKey:i.uniqueKey,maxCharacters:35})}),t.jsx(s.Td,{children:t.jsx(s.Badge,{variant:_t(i.outcome),children:o({id:r.getTranslation(`homePage.promotionResults.outcome.${i.outcome}`)})})}),t.jsx(s.Td,{children:i.writeStatus?t.jsx(s.Badge,{variant:i.writeStatus==="published"?"success":"neutral",children:o({id:r.getTranslation(`homePage.promotionResults.writeStatus.${i.writeStatus}`)})}):t.jsx(s.Typography,{variant:"pi",textColor:"neutral500",children:o({id:r.getTranslation(i.hasFailure?"homePage.promotionResults.writeStatus.notWritten":"homePage.promotionResults.writeStatus.none")})})})]},i.groupKey))})]})},Nt=({summary:e,unlinkedRelationCount:n=0})=>{const{formatMessage:o}=S.useIntl(),a=[{key:"created",label:o({id:r.getTranslation("homePage.promotionResults.summary.created")}),value:e.created,variant:"success"},{key:"updated",label:o({id:r.getTranslation("homePage.promotionResults.summary.updated")}),value:e.updated,variant:"secondary"},...e.skipped>0?[{key:"skipped",label:o({id:r.getTranslation("homePage.promotionResults.summary.skipped")}),value:e.skipped,variant:"neutral"}]:[],...e.failed>0?[{key:"failed",label:o({id:r.getTranslation("homePage.promotionResults.summary.failed")}),value:e.failed,variant:"danger"}]:[],...n>0?[{key:"unlinkedRelations",label:o({id:r.getTranslation("homePage.promotionResults.summary.unlinkedRelations")}),value:n,variant:"warning"}]:[]];return t.jsx(s.Flex,{gap:2,wrap:"wrap",children:a.map(i=>t.jsxs(s.Badge,{variant:i.variant,children:[i.label,": ",i.value]},i.key))})},Ut=fe.default(s.Accordion.Trigger)`
12
+ width: 100%;
13
+ font-weight: ${({theme:e})=>e.fontWeights.regular};
14
+
15
+ & > span:first-child {
16
+ width: 100%;
17
+ display: flex;
18
+ justify-content: space-between;
19
+ font-weight: inherit;
20
+ & > span {
21
+ width: 100%;
22
+ font-weight: inherit;
23
+ }
24
+ }
25
+ `,we=({items:e})=>t.jsx(s.Accordion.Root,{style:{width:"100%"},size:"S",children:e.map(n=>t.jsxs(s.Accordion.Item,{value:n.id,children:[t.jsx(s.Accordion.Header,{children:t.jsx(Ut,{caretPosition:"right",children:t.jsxs(s.Flex,{justifyContent:"space-between",alignItems:"center",width:"100%",gap:2,children:[t.jsx(T.TruncatedTypography,{maxCharacters:40,text:n.title,fontWeight:"regular"}),t.jsx(s.Box,{style:{flexShrink:0},children:t.jsx(Nt,{summary:Dt(n.entries),unlinkedRelationCount:Bt(n.entries)})})]})})}),t.jsx(s.Accordion.Content,{children:t.jsx(Ne,{entries:n.entries})})]},n.id))}),Ot=({overview:e})=>{const{formatMessage:n}=S.useIntl(),o=e.dependencySummaries.map(a=>a.displayName);return t.jsxs(s.Flex,{direction:"column",alignItems:"stretch",gap:2,children:[t.jsx(s.Typography,{variant:"omega",children:n({id:r.getTranslation("homePage.promotionResults.header.summary")},{primaryCount:e.primaryEntityCount,dependencyCount:e.dependencyContentTypeCount,entityCount:e.totalEntityCount,failedCount:e.totalFailed})}),e.totalPublished+e.totalDrafts>0&&t.jsx(s.Typography,{variant:"pi",textColor:"neutral600",children:n({id:r.getTranslation("homePage.promotionResults.header.writeStatus")},{published:e.totalPublished,drafts:e.totalDrafts})}),o.length>0&&t.jsx(s.Typography,{variant:"pi",textColor:"neutral600",children:n({id:r.getTranslation("homePage.promotionResults.header.dependencies")},{contentTypes:o.join(", ")})}),e.mediaSummary&&t.jsx(s.Typography,{variant:"pi",textColor:"neutral600",children:n({id:r.getTranslation("homePage.promotionResults.media.summary")},{uploaded:e.mediaSummary.uploaded,replaced:e.mediaSummary.replaced,failed:e.mediaSummary.failed})})]})},Qt=({result:e,contentTypes:n,comparedEntities:o,contentTypeMainField:a})=>{const{formatMessage:i}=S.useIntl(),c=Kt(e,n),d=c.outcome,l=[...e.entries,...e.dependencyResults.flatMap(P=>P.entries)],u=ae(e.contentTypeUid,n),g=c.totalFailed>0,m=e.dependencyResults.length>0,h=At(e.entries,{comparedEntities:o,contentTypeMainField:a}),p=e.dependencyResults.map(P=>({id:P.contentTypeUid,title:ae(P.contentTypeUid,n),entries:P.entries})),x=()=>{switch(d){case"success":return t.jsx(T.Alert,{variant:"success",title:i({id:r.getTranslation("homePage.promotionResults.success.title")}),description:i({id:r.getTranslation("homePage.promotionResults.success.description")},{primaryCount:c.primaryEntityCount})});case"partial":return t.jsx(T.Alert,{variant:"warning",title:i({id:r.getTranslation("homePage.promotionResults.partialFailure.title")}),description:i({id:r.getTranslation("homePage.promotionResults.partialFailure.description")})});case"failure":return t.jsx(T.Alert,{variant:"danger",title:i({id:r.getTranslation("homePage.promotionResults.failure.title")}),description:i({id:r.getTranslation("homePage.promotionResults.failure.description")})})}};return t.jsxs(s.Flex,{direction:"column",alignItems:"stretch",gap:4,children:[x(),c.totalDrafts>0&&t.jsx(T.Alert,{variant:"default",title:i({id:r.getTranslation("homePage.promotionResults.drafts.title")}),description:i({id:r.getTranslation("homePage.promotionResults.drafts.description")},{count:c.totalDrafts})}),e.hasUnlinkedRelations&&t.jsx(T.Alert,{variant:"warning",title:i({id:r.getTranslation("homePage.promotionResults.unlinkedRelations.title")}),description:i({id:r.getTranslation("homePage.promotionResults.unlinkedRelations.description")})}),t.jsx(Ot,{overview:c}),g&&t.jsxs(s.Flex,{direction:"column",alignItems:"stretch",gap:2,children:[t.jsx(s.Typography,{variant:"delta",children:i({id:r.getTranslation("homePage.promotionResults.failures.title")})}),t.jsx(Ne,{entries:l,showFailuresOnly:!0})]}),t.jsxs(s.Flex,{direction:"column",alignItems:"stretch",gap:2,children:[t.jsxs(s.Typography,{variant:"delta",children:[u,":"]}),t.jsx(we,{items:h})]}),m&&t.jsxs(s.Flex,{direction:"column",alignItems:"stretch",gap:2,children:[t.jsx(s.Typography,{variant:"delta",children:i({id:r.getTranslation("homePage.promotionResults.dependencies.title")})}),t.jsx(we,{items:p})]})]})},Ht=({previews:e,mediaDocumentIds:n,onToggleMediaDocument:o,publishDocumentIds:a,isPublishLocked:i,onTogglePublishDocument:c})=>{const{formatMessage:d}=S.useIntl();return e.length===0?null:t.jsxs(s.Table,{colCount:5,rowCount:e.length,children:[t.jsx(s.Thead,{children:t.jsxs(s.Tr,{children:[t.jsxs(s.Th,{children:[t.jsx(s.Typography,{variant:"sigma",children:d({id:r.getTranslation("homePage.modal.confirmPromotion.publish")})}),t.jsx(s.Tooltip,{label:d({id:r.getTranslation(i?"homePage.modal.confirmPromotion.publishLockedTooltip":"homePage.modal.confirmPromotion.publishTooltip")}),children:t.jsx(A.Information,{style:{marginLeft:"4px"}})})]}),t.jsxs(s.Th,{children:[t.jsx(s.Typography,{variant:"sigma",children:d({id:r.getTranslation("homePage.modal.confirmPromotion.includeMedia")})}),t.jsx(s.Tooltip,{label:d({id:r.getTranslation("homePage.modal.confirmPromotion.tooltip")}),children:t.jsx(A.Information,{style:{marginLeft:"4px"}})})]}),t.jsx(s.Th,{children:t.jsx(s.Typography,{variant:"sigma",children:d({id:r.getTranslation("homePage.table.entryTitle")})})}),t.jsx(s.Th,{children:t.jsx(s.Typography,{variant:"sigma",children:d({id:r.getTranslation("homePage.table.locale")})})}),t.jsx(s.Th,{children:t.jsx(s.Typography,{variant:"sigma",children:d({id:r.getTranslation("homePage.table.key")})})})]})}),t.jsx(s.Tbody,{children:e.map(l=>t.jsxs(s.Tr,{children:[t.jsx(s.Td,{children:t.jsx(s.Checkbox,{checked:a.has(l.documentId),disabled:i,onCheckedChange:u=>c(l.documentId,u===!0),"aria-label":d({id:r.getTranslation("homePage.modal.confirmPromotion.publishForDocument")},{title:l.title})})}),t.jsx(s.Td,{children:t.jsx(s.Checkbox,{checked:n.has(l.documentId),onCheckedChange:u=>o(l.documentId,u===!0),"aria-label":d({id:r.getTranslation("homePage.modal.confirmPromotion.includeMediaForDocument")},{title:l.title})})}),t.jsx(s.Td,{children:t.jsx(T.TruncatedTypography,{maxCharacters:50,text:l.title})}),t.jsx(s.Td,{children:l.allLocalesSelected?t.jsx(s.Typography,{variant:"pi",children:d({id:r.getTranslation("homePage.modal.confirmPromotion.allLocalesSelected")})}):t.jsx(s.Flex,{gap:2,wrap:"wrap",children:l.locales.map(u=>t.jsx(de,{locale:u},`${l.documentId}-${u}`))})}),t.jsx(s.Td,{children:t.jsx(ue,{uniqueKey:l.uniqueKey,maxCharacters:35})})]},l.documentId))})]})},$t={locked:{title:"homePage.modal.confirmPromotion.publishLockedScopeHint.title",description:"homePage.modal.confirmPromotion.publishLockedScopeHint.description"},some:{title:"homePage.modal.confirmPromotion.publishSomeScopeHint.title",description:"homePage.modal.confirmPromotion.publishSomeScopeHint.description"},none:{title:"homePage.modal.confirmPromotion.publishNoneScopeHint.title",description:"homePage.modal.confirmPromotion.publishNoneScopeHint.description"}},Gt=({open:e,onClose:n,selectedPromotions:o,contentTypeUid:a,contentTypeMainField:i,comparedEntities:c,onPromoteComplete:d})=>{const{formatMessage:l}=S.useIntl(),{data:u}=De(),{data:g}=jt(a,e),m=g?.contentTypes,h=j.useMemo(()=>[...u??[],...m??[]],[u,m]),[p,x]=j.useState(null),[P,I]=j.useState(()=>new Set),[D,L]=j.useState(()=>new Set),b=j.useMemo(()=>rt(o),[o]),w=it(u?.find(f=>f.uid===a)),y=ct(m).map(f=>f.displayName),F=w?new Set(b):D,N=Ce(b,P),M=Ce(b,F),k=P.size>0,R=b.some(f=>!P.has(f)),W=$t[lt(w,b,F)],{mutate:me,isPending:J,error:Z,reset:ge}=St(),U=()=>{x(null),I(new Set),L(new Set),ge()};j.useEffect(()=>{I(f=>Ie(f,b)),L(f=>Ie(f,b))},[b]);const _=m?.map(f=>f.displayName)??[],z=Et(o,c,i),ee=()=>{U(),n()},he=f=>{I(f?new Set(b):new Set)},O=(f,$)=>{I(G=>be(G,f,$))},pe=f=>{L(f?new Set(b):new Set)},Q=(f,$)=>{L(G=>be(G,f,$))},H=()=>{me({selections:o,contentTypeUid:a,documentOptions:dt(b,{mediaDocumentIds:P,publishDocumentIds:F})},{onSuccess:f=>{x(f),d?.(f)}})},q=p!=null;return t.jsx(ie,{open:e,onClose:ee,onSubmit:H,title:l({id:r.getTranslation(q?"homePage.modal.promotionResults.title":"homePage.modal.confirmPromotion.title")}),confirmButtonText:l({id:r.getTranslation("homePage.modal.confirmPromotion.confirmButtonText")}),isConfirmButtonDisabled:J||!a||o.length===0,isConfirmButtonLoading:J,showConfirmButton:!q,fillMaxHeight:!0,maxWidth:"120rem",children:q?t.jsx(Qt,{result:p,contentTypes:h,comparedEntities:c,contentTypeMainField:i}):t.jsxs(s.Flex,{direction:"column",gap:4,alignItems:"stretch",children:[t.jsx(s.Typography,{variant:"omega",children:l({id:r.getTranslation("homePage.modal.confirmPromotion.description")},{count:o.length})}),t.jsx(s.Checkbox,{checked:M,disabled:w,onCheckedChange:f=>pe(f===!0),children:l({id:r.getTranslation("homePage.modal.confirmPromotion.publishAll")})}),t.jsx(s.Checkbox,{checked:N,onCheckedChange:f=>he(f===!0),children:l({id:r.getTranslation("homePage.modal.confirmPromotion.includeMediaAll")})}),t.jsx(Ht,{previews:z,mediaDocumentIds:P,onToggleMediaDocument:O,publishDocumentIds:F,isPublishLocked:w,onTogglePublishDocument:Q}),t.jsx(T.Alert,{variant:"default",title:l({id:r.getTranslation(W.title)}),description:l({id:r.getTranslation(W.description)})}),!w&&y.length>0&&t.jsx(T.Alert,{variant:"default",title:l({id:r.getTranslation("homePage.modal.confirmPromotion.alwaysPublishedRelated.title")}),description:l({id:r.getTranslation("homePage.modal.confirmPromotion.alwaysPublishedRelated.description")},{contentTypes:y.join(", ")})}),t.jsx(T.Alert,{variant:"default",title:l({id:r.getTranslation("homePage.promotionResults.scope.title")}),description:l({id:r.getTranslation("homePage.modal.confirmPromotion.localeScopeHint")})}),R&&t.jsx(T.Alert,{variant:"default",title:l({id:r.getTranslation("homePage.modal.confirmPromotion.richTextMediaHint.title")}),description:l({id:r.getTranslation("homePage.modal.confirmPromotion.richTextMediaHint.description")})}),k&&t.jsx(T.Alert,{variant:"default",title:l({id:r.getTranslation("homePage.modal.confirmPromotion.mediaScopeHint.title")}),description:l({id:r.getTranslation("homePage.modal.confirmPromotion.mediaScopeHint.description")})}),_.length>0&&t.jsx(T.Alert,{variant:"warning",title:l({id:r.getTranslation("homePage.modal.confirmPromotion.relatedWarning.title")}),description:l({id:r.getTranslation("homePage.modal.confirmPromotion.relatedWarning.description")},{contentTypes:_.join(", ")})}),Z&&t.jsx(s.Typography,{variant:"omega",textColor:"danger500",children:T.formatApiError(Z,l)})]})})},Vt=2500,Yt=5e3,Xt=e=>e==="running"?Vt:e==="queued"?Yt:!1,Ue=(e,n=!0)=>{const{get:o}=C.useFetchClient(),a=E.useQueryClient(),i=j.useRef(void 0),c=E.useQuery({queryKey:V.list(e),queryFn:async()=>{const{data:d}=await o(`/${r.URL_PREFIX}/snapshot/sync/${e}/status`);return d},enabled:!!e&&n,refetchInterval:d=>Xt(d.state.data?.status),refetchOnWindowFocus:!0});return j.useEffect(()=>{if(!e)return;const d=i.current,l=c.data?.status;(d==="running"&&l!=="running"||d==="queued"&&l==="running")&&le(a,e),i.current=l},[c.data?.status,e,a]),c},Wt=({syncStatus:e,isSyncInProgressFromComparison:n})=>{const o=e?.status;switch(!0){case(o==="running"||n):return"in_progress";case o==="queued":return"queued";case o==="cancelled":return"cancelled";case o==="failed":return"failed";default:return"none"}},Jt=fe.default(s.ProgressBar)`
26
+ background-color: ${({theme:e})=>e.colors.neutral600};
27
+ & > div {
28
+ background-color: ${({theme:e})=>e.colors.neutral150};
29
+ }
30
+ `,ye=({lastProcessedPage:e,totalPages:n})=>{const{formatMessage:o}=S.useIntl(),a=(i,c)=>Math.round(Number(i)/Number(c)*100);return t.jsxs(s.Flex,{direction:"row",gap:2,alignItems:"center",children:[t.jsx(s.Typography,{variant:"omega",children:o({id:r.getTranslation("homePage.alert.syncInProgress.progress")},{currentPage:e,totalPages:n})}),t.jsx(Jt,{value:a(e,n)})]})},Zt=({view:e,syncStatus:n,onRefresh:o,onCancel:a,onResume:i,canExecute:c})=>{const{formatMessage:d}=S.useIntl();if(e==="none")return null;const l=T.formatTranslationKey(n?.error,d),g=(()=>{switch(e){case"queued":return{title:d({id:r.getTranslation("homePage.alert.syncQueued.title")}),description:t.jsxs(s.Flex,{direction:"column",gap:2,alignItems:"flex-start",children:[t.jsx(s.Typography,{variant:"omega",children:d({id:r.getTranslation("homePage.alert.syncQueued.description")})}),n?.queuePosition!=null?t.jsx(s.Typography,{variant:"omega",textColor:"neutral600",children:d({id:r.getTranslation("homePage.alert.syncQueued.position")},{position:n.queuePosition})}):null,n?.queuedAt?t.jsx(s.Typography,{variant:"omega",textColor:"neutral600",children:d({id:r.getTranslation("homePage.alert.syncQueued.queuedAt")},{queuedAt:new Date(n.queuedAt).toLocaleString()})}):null]}),action:t.jsx(s.Button,{onClick:o,variant:"secondary",children:d({id:r.getTranslation("homePage.alert.syncQueued.linkText")})}),variant:"default"};case"in_progress":return{title:d({id:r.getTranslation("homePage.alert.syncInProgress.title")}),description:t.jsxs(s.Flex,{direction:"column",gap:2,alignItems:"flex-start",children:[t.jsx(s.Typography,{variant:"omega",children:d({id:r.getTranslation("homePage.alert.syncInProgress.description")})}),t.jsx(ye,{lastProcessedPage:n?.lastProcessedPage??0,totalPages:n?.totalPages??1})]}),action:t.jsxs(s.Flex,{direction:"row",gap:2,alignItems:"center",children:[t.jsx(s.Button,{onClick:o,variant:"secondary",children:d({id:r.getTranslation("homePage.alert.syncInProgress.linkText")})}),c?t.jsx(s.Button,{variant:"danger-light",onClick:a,children:d({id:r.getTranslation("common.button.cancel")})}):null]}),variant:"default"};case"cancelled":return{title:d({id:r.getTranslation("homePage.alert.resumeSync.title")}),description:t.jsxs(s.Flex,{direction:"column",gap:2,alignItems:"flex-start",children:[t.jsx(s.Typography,{variant:"omega",children:d({id:r.getTranslation("homePage.alert.resumeSync.description")})}),t.jsx(ye,{lastProcessedPage:n?.lastProcessedPage??0,totalPages:n?.totalPages??1})]}),action:c?t.jsx(s.Button,{onClick:i,variant:"secondary",children:d({id:r.getTranslation("homePage.alert.resumeSync.linkText")})}):void 0,variant:"warning"};case"failed":return{title:d({id:r.getTranslation("homePage.alert.syncFailed.title")}),description:t.jsxs(s.Flex,{direction:"column",gap:2,alignItems:"flex-start",children:[t.jsx(s.Typography,{variant:"omega",children:d({id:r.getTranslation("homePage.alert.syncFailed.description")})}),l?t.jsx(s.Typography,{variant:"omega",textColor:"danger500",children:l}):null,t.jsx(ye,{lastProcessedPage:n?.lastProcessedPage??0,totalPages:n?.totalPages??1})]}),action:c?t.jsx(s.Button,{onClick:i,variant:"secondary",children:d({id:r.getTranslation("homePage.alert.syncFailed.linkText")})}):void 0,variant:"danger"};default:return e}})();return t.jsx(T.Alert,{title:g?.title,description:g?.description,action:g?.action,variant:g?.variant})},zt=()=>{const{post:e}=C.useFetchClient(),n=E.useQueryClient();return E.useMutation({mutationFn:async()=>await e(`/${r.URL_PREFIX}/snapshot/sync/cancel`),onSuccess:()=>{le(n)}})},en=({open:e,onClose:n})=>{const{formatMessage:o}=S.useIntl(),{mutate:a,isPending:i,error:c,reset:d}=zt(),l=()=>{n(),d()};return t.jsx(ie,{open:e,onClose:l,onSubmit:()=>a(void 0,{onSuccess:l}),title:t.jsxs(s.Flex,{direction:"row",gap:2,alignItems:"center",children:[t.jsx(A.WarningCircle,{fill:"danger500",width:20,height:20}),o({id:r.getTranslation("homePage.modal.cancelSync.title")})]}),confirmButtonText:o({id:r.getTranslation("homePage.modal.cancelSync.confirmButtonText")}),isConfirmButtonLoading:i,children:t.jsxs(s.Flex,{direction:"column",gap:4,alignItems:"stretch",children:[t.jsx(s.Typography,{variant:"omega",children:o({id:r.getTranslation("homePage.modal.cancelSync.description")})}),c&&t.jsx(s.Typography,{variant:"omega",textColor:"danger500",children:T.formatApiError(c,o)})]})})},tn=()=>{const{post:e}=C.useFetchClient(),n=E.useQueryClient();return E.useMutation({mutationFn:async o=>await e(`/${r.URL_PREFIX}/snapshot/sync/${o}/resume`),onSuccess:()=>{le(n)}})},nn=({open:e,onClose:n,jobDocumentId:o})=>{const{formatMessage:a}=S.useIntl(),{mutate:i,isPending:c,error:d,reset:l}=tn(),u=()=>{n(),l()};return t.jsx(ie,{open:e,onClose:u,onSubmit:()=>i(o,{onSuccess:u}),title:a({id:r.getTranslation("homePage.modal.resumeSync.title")}),confirmButtonText:a({id:r.getTranslation("homePage.modal.resumeSync.confirmButtonText")}),isConfirmButtonDisabled:!o,isConfirmButtonLoading:c,children:t.jsxs(s.Flex,{direction:"column",gap:4,alignItems:"stretch",children:[t.jsx(s.Typography,{variant:"omega",children:a({id:r.getTranslation("homePage.modal.resumeSync.description")})}),d&&t.jsx(s.Typography,{variant:"omega",textColor:"danger500",children:T.formatApiError(d,a)})]})})},on=({contentTypeUid:e,isSyncInProgressFromComparison:n,canExecute:o,enabled:a=!0})=>{const[i,c]=j.useState(!1),[d,l]=j.useState(!1),{data:u,refetch:g}=Ue(e,a),m=Wt({syncStatus:u,isSyncInProgressFromComparison:n}),h=u?.jobDocumentId??"";return t.jsxs(t.Fragment,{children:[t.jsx(Zt,{view:m,syncStatus:u,onRefresh:()=>g(),onCancel:()=>c(!0),onResume:()=>l(!0),canExecute:o}),o?t.jsxs(t.Fragment,{children:[t.jsx(en,{open:i,onClose:()=>c(!1)}),t.jsx(nn,{open:d,onClose:()=>l(!1),jobDocumentId:h})]}):null]})},sn=e=>{const{get:n}=C.useFetchClient();return E.useQuery({queryKey:["compare-schemas"],queryFn:async()=>{const{data:o}=await n(`/${r.URL_PREFIX}/compare-schemas`);return o},enabled:e})},an=(e,n)=>{const o=new Set((e??[]).map(i=>i.documentId)),a=[...n.entries()].filter(([i])=>!o.has(i)).map(([,i])=>at(i)).filter(i=>i!=null);return[...e??[],...a]},rn=(e,n)=>{const o=new Set(n.map(i=>i.documentId)),a=new Map;for(const[i,c]of e)o.has(i)&&a.set(i,c);return a},ln=(e,n)=>{const o=n[0]?.documentId;if(!o)return e;const a=new Map(e);return a.set(o,n),a},cn=e=>{const[n,o]=j.useState([]),[a,i]=j.useState(()=>new Map),c=j.useCallback(()=>{o([]),i(new Map)},[]);j.useEffect(()=>{i(u=>rn(u,n))},[n]);const d=j.useCallback(u=>{i(g=>ln(g,u))},[]),l=j.useMemo(()=>an(e,a),[e,a]);return{selectedPromotions:n,setSelectedPromotions:o,clear:c,rememberEntityGroup:d,entitiesForPreview:l}},dn=()=>{const{formatMessage:e}=S.useIntl(),{isLoading:n,allowedActions:{canExecute:o=!1,canRead:a=!1}}=C.useRBAC([...r.PERMISSIONS.promotionExecute,...r.PERMISSIONS.settingsRead]),[{query:i},c]=C.useQueryParams(),d=j.useRef(!1),l=te.default.object({page:te.default.coerce.number().optional().default(1),pageSize:te.default.coerce.number().optional().default(10),uid:te.default.string().optional()}).parse(i),[u,g]=j.useState(!1),{data:m,isLoading:h}=Xe(),p=m?.active===!0,x=!h&&m?.active===!1,{data:P}=Ue(l.uid??"",p),{data:I,isSuccess:D,isLoading:L}=De(p),b=D&&(I?.length??0)>0,w=I?.map(v=>({key:v.uid,value:v.uid,label:v.displayName}))??[],{data:y,isLoading:F,error:N}=Ze({uid:l.uid,page:l.page,pageSize:l.pageSize,enabled:p}),{selectedPromotions:M,setSelectedPromotions:k,clear:R,rememberEntityGroup:W,entitiesForPreview:me}=cn(y?.results),J=v=>{d.current=!1,c({...i,page:1,pageSize:10,uid:v}),R()},Z=()=>{d.current=!0,c({...i,page:1,pageSize:10,uid:void 0}),R()},ge=()=>{g(!1),R()},{data:U,isLoading:_,error:z}=sn(p&&b),ee=y?.mainField,he=y?.maxDepthReached,O=y?.errors,pe=O?.type==="unconfigured_relations"?O:void 0,Q=O?.type==="sync_in_progress",H=Q||P?.status==="running",q=!x&&!_&&(!!z||!!U&&!U?.isMatch),f=!o||h||x||_||q||Q||P?.status==="running"||P?.status==="queued",$=!!l.uid&&F,G=()=>{switch(!0){case(L||$):return t.jsx(s.Loader,{});case(D&&!b):return t.jsx(T.Alert,{title:e({id:r.getTranslation("homePage.alert.configurationNeeded.title")}),description:e({id:r.getTranslation(a?"homePage.alert.configurationNeeded.description":"homePage.alert.configurationNeeded.readOnlyDescription")}),action:a?t.jsx(s.Link,{tag:B.Link,to:"/settings/xecp/configuration",children:e({id:r.getTranslation("homePage.alert.configurationNeeded.linkText")})}):void 0,variant:"danger"});case H:return t.jsx(s.EmptyStateLayout,{content:e({id:r.getTranslation("homePage.alert.syncInProgress.contentUnavailable")})});case(y?.results&&y?.results?.length>0):return t.jsxs(t.Fragment,{children:[he&&t.jsx(T.Alert,{title:e({id:r.getTranslation("homePage.alert.maxDepthExceeded.title")}),variant:"warning",description:e({id:r.getTranslation("homePage.alert.maxDepthExceeded.description")})}),t.jsx(Pt,{entities:y?.results,contentTypeMainField:ee,selectedPromotions:M,setSelectedPromotions:k,onRememberEntityGroup:W,canExecute:o&&!x})]});case!!N:return t.jsx(s.EmptyStateLayout,{icon:t.jsx(A.WarningCircle,{width:24,height:24}),content:e({id:r.getTranslation("homePage.errorLoadingEntities")})});case(y?.results&&y?.results?.length===0):return t.jsx(ot,{contentTypeUid:l.uid??"",hasExistingSnapshot:y?.snapshot?.exists??!1,unconfiguredRelationsError:pe,isGetSnapshotDisabled:f,canExecute:o&&!x,canReadSettings:a});default:return t.jsx(s.EmptyStateLayout,{content:e({id:r.getTranslation("homePage.youNeedToSelectAContentTypeToSeeTheEntities")})})}},Pe=y?.snapshot?.exists??!1,Oe=!H&&Pe&&y?.pagination&&y?.pagination?.pageCount>0,Qe=!o||h||x||_||!b||q||!l.uid||M.length===0||H,He=L||h||_||x||q||!b,$e=()=>{switch(!0){case h:return t.jsxs(s.Flex,{gap:2,alignItems:"center",children:[t.jsx(s.Loader,{small:!0}),t.jsx(s.Typography,{variant:"omega",children:e({id:r.getTranslation("homePage.verifyingLicense")})})]});case x:return t.jsx(tt,{canReadSettings:a});case _:return t.jsxs(s.Flex,{gap:2,alignItems:"center",children:[t.jsx(s.Loader,{small:!0}),t.jsx(s.Typography,{variant:"omega",children:e({id:r.getTranslation("homePage.verifyingSchemas")})})]});case q:return t.jsx(nt,{compareSchemasData:U,errorCompareSchemas:z?.message});default:return null}},je=d.current||!!l.uid||!b;return j.useEffect(()=>{if(je)return;const v=I?.[0]?.uid;v&&c({...i,uid:v,page:1,pageSize:10})},[je,I,i,c]),n?t.jsx(C.Page.Loading,{}):t.jsxs(t.Fragment,{children:[t.jsx(C.Page.Title,{children:e({id:r.getTranslation("homePage.title")})}),t.jsxs(C.Page.Main,{children:[t.jsx(C.Layouts.Header,{title:e({id:r.getTranslation("homePage.title")}),primaryAction:o?t.jsx(s.Button,{disabled:Qe,onClick:()=>g(!0),children:e({id:r.getTranslation("homePage.promoteContent")})}):null}),t.jsx(C.Layouts.Content,{children:t.jsxs(s.Flex,{direction:"column",alignItems:"stretch",gap:4,children:[$e(),t.jsx(s.Flex,{children:t.jsx(We,{name:"contentType",placeholder:e({id:r.getTranslation("homePage.selectContentType")}),onClear:Z,onChange:J,options:w,value:l.uid,disabled:He})}),l?.uid&&!x?t.jsxs(t.Fragment,{children:[t.jsx(on,{contentTypeUid:l.uid,isSyncInProgressFromComparison:Q,canExecute:o&&!x,enabled:p}),t.jsx(et,{contentTypeUid:l.uid,selectedPromotionsLength:M.length,syncedAt:y?.snapshot?.syncedAt??null,isGetSnapshotDisabled:f,hasSnapshot:Pe,clearSelectedPromotions:R,canExecute:o&&!x,privateFields:I?.find(v=>v.uid===l.uid)?.privateFields})]}):null,x?null:G(),Oe&&!x?t.jsxs(C.Pagination.Root,{total:y?.pagination?.total||0,pageCount:y?.pagination?.pageCount||0,children:[t.jsx(C.Pagination.PageSize,{}),t.jsx(C.Pagination.Links,{})]}):null]})})]}),o&&!x&&u?t.jsx(Gt,{open:u,onClose:ge,selectedPromotions:M,contentTypeUid:l.uid??"",contentTypeMainField:ee,comparedEntities:me}):null]})},un=()=>t.jsx(C.Page.Protect,{permissions:[...r.PERMISSIONS.promotionRead],children:t.jsx(dn,{})}),mn=()=>t.jsx(re.QueryProvider,{children:t.jsxs(B.Routes,{children:[t.jsx(B.Route,{index:!0,element:t.jsx(un,{})}),t.jsx(B.Route,{path:"*",element:t.jsx(C.Page.Error,{})})]})});exports.default=mn;