@qkix/strapi-plugin-rewind 0.3.0 → 0.4.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/README.md CHANGED
@@ -98,6 +98,12 @@ relations, and a snapshot of the schema at the time - the last of which is what
98
98
  lets a restore tell "this field was empty" apart from "this field did not exist
99
99
  yet".
100
100
 
101
+ A relation is stored as what it pointed at _and_ what that was called, using the
102
+ field the Content Manager titles the entry by. Storing the name is what makes a
103
+ history readable once the target is gone: the id of a deleted author resolves to
104
+ nothing, and "Ada Lovelace no longer exists and will be left out" is the sentence
105
+ an editor needs.
106
+
101
107
  Publishing records **one** version, not two, even though the Content Manager
102
108
  saves the draft and publishes it as two separate operations.
103
109
 
@@ -142,7 +148,12 @@ Scalars are shown as a plain before and after. Prose - including rich text
142
148
  stored as JSON - is compared word by word, with the unchanged stretches
143
149
  collapsed, so a one-word edit in a long article reads as one word rather than
144
150
  as the whole article with something green in it somewhere. Relations are
145
- reported as linked and unlinked.
151
+ reported as linked and unlinked, by name where the version has one.
152
+
153
+ <img src="https://raw.githubusercontent.com/qkix/strapi-plugins/main/packages/strapi-plugin-rewind/docs/relations.png" alt="The What changed dialog showing the featured relation: plus Plugin showcase in green, minus Autumn release notes in red" width="760" />
154
+
155
+ The name comes from the version, not from the target, so it still reads this way
156
+ once the target has been deleted.
146
157
 
147
158
  Where a field's stored value changed but its readable text did not - a mark
148
159
  applied, blocks reordered - it says so, rather than showing an empty diff.
@@ -225,9 +236,13 @@ Worth knowing before you install it, not after:
225
236
  - **Only the Document Service is visible.** Writes made through
226
237
  `strapi.db.query()` or the legacy entity service bypass the middleware
227
238
  entirely and cannot be captured at any setting.
228
- - **Deleted relation targets lose their names.** A version stores which document
229
- a relation pointed at, not what it was called, so a link to something since
230
- deleted shows as missing rather than as "the article it used to be".
239
+ - **A relation's name is a snapshot too.** A version records what the target was
240
+ called when it was taken, so a link survives the target being deleted. It does
241
+ not follow a later rename: a version from March says what the author was called
242
+ in March, which is the point.
243
+ - **Versions taken before names were recorded have none**, and fall back to
244
+ counting - "2 linked items" - because a name cannot be recovered after the
245
+ fact.
231
246
  - **Media is referenced, never copied.** Delete the file and the version knows
232
247
  the file is gone; it cannot bring it back.
233
248
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),Q=require("react"),X=require("@strapi/admin/strapi-admin"),t=require("@strapi/design-system"),Y=require("@strapi/icons");function ee(n){if(n&&n.__esModule)return n;const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const s in n)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(i,s,a.get?a:{enumerable:!0,get:()=>n[s]})}}return i.default=n,Object.freeze(i)}const c=ee(Q),te=(n,i,s)=>{const a=n[i];return a?typeof a=="function"?a():Promise.resolve(a):new Promise((f,x)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(x.bind(null,new Error("Unknown variable dynamic import: "+i+(i.split("/").length!==s?". Note that variables only represent file names one level deep.":""))))})},$=new Map,ne=(n,i)=>{$.set(n,i)},L=n=>$.get(n),re=({spans:n})=>e.jsx(t.Typography,{variant:"omega",tag:"p",children:n.map((i,s)=>i.op==="equal"?e.jsx(t.Typography,{variant:"omega",textColor:"neutral600",children:i.value},s):e.jsx(t.Typography,{variant:"omega",textColor:i.op==="added"?"success600":"danger600",style:i.op==="removed"?{textDecoration:"line-through"}:{fontWeight:600},children:i.value},s))}),M=n=>n==null||n===""?"(empty)":typeof n=="object"?JSON.stringify(n):String(n),ie=({change:n})=>{const i=(n.customField?L(n.customField):void 0)??L(n.type);return i?e.jsx(i,{change:n}):n.spans?e.jsx(re,{spans:n.spans}):n.linked||n.unlinked?e.jsxs(t.Flex,{direction:"column",alignItems:"flex-start",gap:1,children:[n.linked?.length?e.jsxs(t.Typography,{variant:"pi",textColor:"success600",children:["+ ",n.linked.length," linked"]}):null,n.unlinked?.length?e.jsxs(t.Typography,{variant:"pi",textColor:"danger600",children:["− ",n.unlinked.length," unlinked"]}):null]}):n.before!==void 0||n.after!==void 0?e.jsxs(t.Flex,{gap:2,alignItems:"center",wrap:"wrap",children:[e.jsx(t.Typography,{variant:"omega",textColor:"danger600",style:{textDecoration:"line-through"},children:M(n.before)}),e.jsx(t.Typography,{variant:"omega",textColor:"neutral500",children:"→"}),e.jsx(t.Typography,{variant:"omega",textColor:"success600",children:M(n.after)})]}):e.jsx(t.Typography,{variant:"pi",textColor:"neutral600",children:"Formatting or structure changed; the text is the same."})},T="previous",se=({diff:n,loading:i,onClose:s,subject:a,options:f,againstId:x,onChangeAgainst:u,hasUnloadedVersions:y})=>e.jsx(t.Modal.Root,{open:!0,onOpenChange:s,children:e.jsxs(t.Modal.Content,{children:[e.jsx(t.Modal.Header,{children:e.jsx(t.Modal.Title,{children:"What changed"})}),e.jsxs(t.Modal.Body,{children:[e.jsxs(t.Flex,{direction:"column",alignItems:"stretch",gap:2,paddingBottom:4,children:[e.jsxs(t.Typography,{variant:"pi",textColor:"neutral600",children:["Comparing ",e.jsx("b",{children:a})," with"]}),e.jsxs(t.SingleSelect,{"aria-label":"Compare with",size:"S",value:x===null?T:String(x),onChange:l=>u(String(l)===T?null:Number(l)),children:[e.jsx(t.SingleSelectOption,{value:T,children:"The version saved just before it"}),f.map(l=>e.jsx(t.SingleSelectOption,{value:String(l.id),children:l.name},l.id))]}),y?e.jsxs(t.Typography,{variant:"pi",textColor:"neutral600",children:["Only versions loaded in the panel are listed. Use ",e.jsx("b",{children:"Show older versions"})," there to reach further back."]}):null]}),i?e.jsx(t.Flex,{justifyContent:"center",padding:4,children:e.jsx(t.Loader,{small:!0,children:"Comparing"})}):n?e.jsxs(t.Flex,{direction:"column",alignItems:"stretch",gap:4,children:[n.from?null:e.jsx(t.Typography,{variant:"pi",textColor:"neutral600",children:"This is the earliest version of the document, so everything in it is new."}),n.identical?e.jsx(t.Typography,{textColor:"neutral600",children:"Nothing changed between these two versions."}):n.changes.map(l=>e.jsxs(t.Box,{children:[e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:l.field}),e.jsx(t.Box,{paddingTop:1,children:e.jsx(ie,{change:l})})]},l.field))]}):e.jsx(t.Typography,{textColor:"danger600",children:"Could not compare these versions."})]}),e.jsx(t.Modal.Footer,{children:e.jsx(t.Button,{variant:"tertiary",onClick:s,children:"Close"})})]})}),h="rewind",A={create:"Created",update:"Edited",clone:"Cloned",publish:"Published",unpublish:"Unpublished",discardDraft:"Draft discarded",restore:"Replaced by restore"},O=new Set(["publish","unpublish","discardDraft","restore"]),oe=10,_=n=>`${A[n.origin]??n.origin} · ${N(n.createdAt)}`,N=n=>{const i=new Date(n),s=Math.round((Date.now()-i.getTime())/6e4);return s<1?"just now":s<60?`${s} min ago`:s<60*24?`${Math.round(s/60)} h ago`:i.toLocaleString()},ae=({model:n,documentId:i,updatedAt:s})=>{const{get:a,post:f,put:x}=X.useFetchClient(),[u,y]=c.useState([]),[l,q]=c.useState(0),[E,U]=c.useState(1),[S,k]=c.useState(!0),[v,j]=c.useState(null),[o,C]=c.useState(null),[D,F]=c.useState(!1),[m,R]=c.useState(null),[W,P]=c.useState(null),[z,w]=c.useState(null),[H,I]=c.useState(!1),b=c.useCallback(async r=>{k(!0),j(null);try{const{data:d}=await a(`/${h}/versions`,{params:{contentType:n,documentId:i,page:r,pageSize:oe}});y(p=>r===1?d.data:[...p,...d.data]),q(d.meta.total),U(r)}catch{j("Could not load the history for this document.")}finally{k(!1)}},[a,n,i]);c.useEffect(()=>{b(1)},[b,s]);const B=async(r,d)=>{I(!0),w(null);try{const{data:p}=await a(`/${h}/versions/${r.id}/diff`,d===null?void 0:{params:{against:d}});w(p.data)}catch{w(null)}finally{I(!1)}},G=r=>{R(r),P(null),B(r,null)},V=r=>{m&&(P(r),B(m,r))},K=async r=>{const d=!r.pinned;y(p=>p.map(g=>g.id===r.id?{...g,pinned:d}:g));try{await x(`/${h}/versions/${r.id}/pin`,{pinned:d})}catch{y(p=>p.map(g=>g.id===r.id?{...g,pinned:!d}:g)),j(d?"Could not pin that version.":"Could not unpin that version.")}},J=async r=>{try{const{data:d}=await a(`/${h}/versions/${r.id}/preview`);C({version:r,preview:d.data})}catch{j("Could not work out what restoring this version would change.")}},Z=async()=>{if(o){F(!0);try{await f(`/${h}/versions/${o.version.id}/restore`,{}),window.location.reload()}catch{j("The restore failed. Nothing was changed."),F(!1),C(null)}}};return S&&u.length===0?e.jsx(t.Flex,{justifyContent:"center",padding:4,children:e.jsx(t.Loader,{small:!0,children:"Loading history"})}):v&&u.length===0?e.jsx(t.Typography,{variant:"pi",textColor:"danger600",children:v}):u.length===0?e.jsx(t.Typography,{variant:"pi",textColor:"neutral600",children:"No versions yet. The next time this document is saved, a version will appear here."}):e.jsxs(t.Flex,{direction:"column",alignItems:"stretch",gap:2,width:"100%",children:[u.map(r=>e.jsxs(t.Box,{paddingBottom:2,children:[e.jsxs(t.Flex,{justifyContent:"space-between",alignItems:"center",gap:2,children:[e.jsxs(t.Flex,{direction:"column",alignItems:"flex-start",gap:1,grow:1,minWidth:0,children:[e.jsxs(t.Flex,{gap:2,alignItems:"center",children:[e.jsx(t.Badge,{backgroundColor:O.has(r.origin)?"primary100":"neutral150",textColor:O.has(r.origin)?"primary600":"neutral600",children:A[r.origin]??r.origin}),r.locale?e.jsx(t.Typography,{variant:"pi",textColor:"neutral500",children:r.locale}):null]}),r.label?e.jsx(t.Box,{width:"100%",children:e.jsx(t.Typography,{variant:"omega",textColor:"neutral800",ellipsis:!0,children:r.label})}):null,e.jsxs(t.Typography,{variant:"pi",textColor:"neutral600",children:[N(r.createdAt),r.user?` · ${r.user.name}`:""]}),r.pinned?e.jsx(t.Typography,{variant:"pi",textColor:"primary600",fontWeight:"bold",children:"Pinned"}):null,e.jsx(t.TextButton,{onClick:()=>G(r),children:"What changed"})]}),e.jsxs(t.Flex,{shrink:0,gap:1,alignItems:"center",children:[e.jsx(t.IconButton,{size:"S",variant:"ghost",label:r.pinned?"Unpin this version, so tidying up can remove it":"Pin this version, so tidying up never removes it",onClick:()=>K(r),children:e.jsx(Y.Pin,{fill:r.pinned?"primary600":"neutral500"})}),e.jsx(t.Button,{size:"S",variant:"tertiary",onClick:()=>J(r),children:"Restore"})]})]}),e.jsx(t.Box,{paddingTop:2,children:e.jsx(t.Divider,{})})]},r.id)),u.length<l?e.jsx(t.Button,{size:"S",variant:"tertiary",loading:S,onClick:()=>b(E+1),children:"Show older versions"}):null,v?e.jsx(t.Typography,{variant:"pi",textColor:"danger600",children:v}):null,m?e.jsx(se,{diff:z,loading:H,subject:_(m),options:u.filter(r=>r.id!==m.id).map(r=>({id:r.id,name:_(r)})),againstId:W,onChangeAgainst:V,hasUnloadedVersions:u.length<l,onClose:()=>R(null)}):null,e.jsx(t.Dialog.Root,{open:o!==null,onOpenChange:()=>C(null),children:e.jsxs(t.Dialog.Content,{children:[e.jsx(t.Dialog.Header,{children:"Restore this version?"}),e.jsx(t.Dialog.Body,{children:e.jsxs(t.Flex,{direction:"column",alignItems:"flex-start",gap:2,children:[e.jsx(t.Typography,{children:"The current draft is saved as a version first, so this can be undone. The published version is not touched."}),o?.preview.crossLocaleFields.length?e.jsxs(t.Typography,{textColor:"danger600",children:[o.preview.crossLocaleFields.join(", ")," ",o.preview.crossLocaleFields.length===1?"is":"are"," not translated per locale, so restoring"," ",o.preview.crossLocaleFields.length===1?"it":"them"," changes"," ",o.preview.affectedLocales.length," locales at once:"," ",o.preview.affectedLocales.join(", "),"."]}):null,o?.preview.fieldsKeptAsIs.length?e.jsxs(t.Typography,{variant:"pi",textColor:"neutral600",children:["Added since this version and left untouched:"," ",o.preview.fieldsKeptAsIs.join(", "),"."]}):null,o?.preview.fieldsDropped.length?e.jsxs(t.Typography,{variant:"pi",textColor:"neutral600",children:["No longer in the model and skipped: ",o.preview.fieldsDropped.join(", "),"."]}):null,o?.preview.brokenRelations.length||o?.preview.missingMedia.length?e.jsxs(t.Typography,{variant:"pi",textColor:"warning600",children:[(o.preview.brokenRelations.length??0)+(o.preview.missingMedia.length??0)," ","linked item(s) no longer exist and will be left out."]}):null]})}),e.jsxs(t.Dialog.Footer,{children:[e.jsx(t.Dialog.Cancel,{children:e.jsx(t.Button,{variant:"tertiary",disabled:D,children:"Cancel"})}),e.jsx(t.Button,{onClick:Z,loading:D,children:"Restore"})]})]})})]})},le=({model:n,documentId:i,document:s})=>i?{title:"History",content:e.jsx(ae,{model:n,documentId:i,updatedAt:s?.updatedAt})}:null,de={register(n){n.registerPlugin({id:h,name:h,isReady:!0})},bootstrap(n){n.getPlugin("content-manager").apis.addEditViewSidePanel([le])},async registerTrads({locales:n}){return Promise.all(n.map(async i=>{try{const{default:s}=await te(Object.assign({"./translations/en.json":()=>Promise.resolve().then(()=>require("../_chunks/en-BHfx2OWt.js"))}),`./translations/${i}.json`,3);return{data:s,locale:i}}catch{return{data:{},locale:i}}}))}};exports.PLUGIN_ID=h;exports.default=de;exports.registerDiffRenderer=ne;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),X=require("react"),Y=require("@strapi/admin/strapi-admin"),n=require("@strapi/design-system"),ee=require("@strapi/icons");function te(t){if(t&&t.__esModule)return t;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(r,s,o.get?o:{enumerable:!0,get:()=>t[s]})}}return r.default=t,Object.freeze(r)}const c=te(X),ne=(t,r,s)=>{const o=t[r];return o?typeof o=="function"?o():Promise.resolve(o):new Promise((p,g)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(g.bind(null,new Error("Unknown variable dynamic import: "+r+(r.split("/").length!==s?". Note that variables only represent file names one level deep.":""))))})},A=new Map,re=(t,r)=>{A.set(t,r)},I=t=>A.get(t),ie=({spans:t})=>e.jsx(n.Typography,{variant:"omega",tag:"p",children:t.map((r,s)=>r.op==="equal"?e.jsx(n.Typography,{variant:"omega",textColor:"neutral600",children:r.value},s):e.jsx(n.Typography,{variant:"omega",textColor:r.op==="added"?"success600":"danger600",style:r.op==="removed"?{textDecoration:"line-through"}:{fontWeight:600},children:r.value},s))}),L=t=>{const r=t.map(o=>o.label).filter(Boolean);if(r.length===0)return`${t.length} item${t.length===1?"":"s"}`;const s=t.length-r.length;return s?`${r.join(", ")} and ${s} more`:r.join(", ")},M=t=>t==null||t===""?"(empty)":typeof t=="object"?JSON.stringify(t):String(t),se=({change:t})=>{const r=(t.customField?I(t.customField):void 0)??I(t.type);return r?e.jsx(r,{change:t}):t.spans?e.jsx(ie,{spans:t.spans}):t.linked||t.unlinked?e.jsxs(n.Flex,{direction:"column",alignItems:"flex-start",gap:1,children:[t.linked?.length?e.jsxs(n.Typography,{variant:"pi",textColor:"success600",children:["+ ",L(t.linked)]}):null,t.unlinked?.length?e.jsxs(n.Typography,{variant:"pi",textColor:"danger600",children:["− ",L(t.unlinked)]}):null]}):t.before!==void 0||t.after!==void 0?e.jsxs(n.Flex,{gap:2,alignItems:"center",wrap:"wrap",children:[e.jsx(n.Typography,{variant:"omega",textColor:"danger600",style:{textDecoration:"line-through"},children:M(t.before)}),e.jsx(n.Typography,{variant:"omega",textColor:"neutral500",children:"→"}),e.jsx(n.Typography,{variant:"omega",textColor:"success600",children:M(t.after)})]}):e.jsx(n.Typography,{variant:"pi",textColor:"neutral600",children:"Formatting or structure changed; the text is the same."})},T="previous",oe=({diff:t,loading:r,onClose:s,subject:o,options:p,againstId:g,onChangeAgainst:u,hasUnloadedVersions:m})=>e.jsx(n.Modal.Root,{open:!0,onOpenChange:s,children:e.jsxs(n.Modal.Content,{children:[e.jsx(n.Modal.Header,{children:e.jsx(n.Modal.Title,{children:"What changed"})}),e.jsxs(n.Modal.Body,{children:[e.jsxs(n.Flex,{direction:"column",alignItems:"stretch",gap:2,paddingBottom:4,children:[e.jsxs(n.Typography,{variant:"pi",textColor:"neutral600",children:["Comparing ",e.jsx("b",{children:o})," with"]}),e.jsxs(n.SingleSelect,{"aria-label":"Compare with",size:"S",value:g===null?T:String(g),onChange:l=>u(String(l)===T?null:Number(l)),children:[e.jsx(n.SingleSelectOption,{value:T,children:"The version saved just before it"}),p.map(l=>e.jsx(n.SingleSelectOption,{value:String(l.id),children:l.name},l.id))]}),m?e.jsxs(n.Typography,{variant:"pi",textColor:"neutral600",children:["Only versions loaded in the panel are listed. Use ",e.jsx("b",{children:"Show older versions"})," there to reach further back."]}):null]}),r?e.jsx(n.Flex,{justifyContent:"center",padding:4,children:e.jsx(n.Loader,{small:!0,children:"Comparing"})}):t?e.jsxs(n.Flex,{direction:"column",alignItems:"stretch",gap:4,children:[t.from?null:e.jsx(n.Typography,{variant:"pi",textColor:"neutral600",children:"This is the earliest version of the document, so everything in it is new."}),t.identical?e.jsx(n.Typography,{textColor:"neutral600",children:"Nothing changed between these two versions."}):t.changes.map(l=>e.jsxs(n.Box,{children:[e.jsx(n.Typography,{variant:"sigma",textColor:"neutral600",children:l.field}),e.jsx(n.Box,{paddingTop:1,children:e.jsx(se,{change:l})})]},l.field))]}):e.jsx(n.Typography,{textColor:"danger600",children:"Could not compare these versions."})]}),e.jsx(n.Modal.Footer,{children:e.jsx(n.Button,{variant:"tertiary",onClick:s,children:"Close"})})]})}),h="rewind",ae=t=>{const r=[...t.brokenRelations,...t.missingMedia],s=r.map(u=>u.label).filter(Boolean),o=`${r.length} linked item${r.length===1?"":"s"}`;if(s.length===0)return`${o} no longer exist and will be left out.`;const p=r.length-s.length;return`${p?`${s.join(", ")} and ${p} more`:s.join(", ")} no longer exist${r.length===1?"s":""} and will be left out.`},N={create:"Created",update:"Edited",clone:"Cloned",publish:"Published",unpublish:"Unpublished",discardDraft:"Draft discarded",restore:"Replaced by restore"},O=new Set(["publish","unpublish","discardDraft","restore"]),le=10,_=t=>`${N[t.origin]??t.origin} · ${q(t.createdAt)}`,q=t=>{const r=new Date(t),s=Math.round((Date.now()-r.getTime())/6e4);return s<1?"just now":s<60?`${s} min ago`:s<60*24?`${Math.round(s/60)} h ago`:r.toLocaleString()},de=({model:t,documentId:r,updatedAt:s})=>{const{get:o,post:p,put:g}=Y.useFetchClient(),[u,m]=c.useState([]),[l,E]=c.useState(0),[U,W]=c.useState(1),[S,k]=c.useState(!0),[v,j]=c.useState(null),[a,C]=c.useState(null),[$,D]=c.useState(!1),[f,F]=c.useState(null),[z,R]=c.useState(null),[H,w]=c.useState(null),[G,P]=c.useState(!1),b=c.useCallback(async i=>{k(!0),j(null);try{const{data:d}=await o(`/${h}/versions`,{params:{contentType:t,documentId:r,page:i,pageSize:le}});m(x=>i===1?d.data:[...x,...d.data]),E(d.meta.total),W(i)}catch{j("Could not load the history for this document.")}finally{k(!1)}},[o,t,r]);c.useEffect(()=>{b(1)},[b,s]);const B=async(i,d)=>{P(!0),w(null);try{const{data:x}=await o(`/${h}/versions/${i.id}/diff`,d===null?void 0:{params:{against:d}});w(x.data)}catch{w(null)}finally{P(!1)}},V=i=>{F(i),R(null),B(i,null)},K=i=>{f&&(R(i),B(f,i))},J=async i=>{const d=!i.pinned;m(x=>x.map(y=>y.id===i.id?{...y,pinned:d}:y));try{await g(`/${h}/versions/${i.id}/pin`,{pinned:d})}catch{m(x=>x.map(y=>y.id===i.id?{...y,pinned:!d}:y)),j(d?"Could not pin that version.":"Could not unpin that version.")}},Z=async i=>{try{const{data:d}=await o(`/${h}/versions/${i.id}/preview`);C({version:i,preview:d.data})}catch{j("Could not work out what restoring this version would change.")}},Q=async()=>{if(a){D(!0);try{await p(`/${h}/versions/${a.version.id}/restore`,{}),window.location.reload()}catch{j("The restore failed. Nothing was changed."),D(!1),C(null)}}};return S&&u.length===0?e.jsx(n.Flex,{justifyContent:"center",padding:4,children:e.jsx(n.Loader,{small:!0,children:"Loading history"})}):v&&u.length===0?e.jsx(n.Typography,{variant:"pi",textColor:"danger600",children:v}):u.length===0?e.jsx(n.Typography,{variant:"pi",textColor:"neutral600",children:"No versions yet. The next time this document is saved, a version will appear here."}):e.jsxs(n.Flex,{direction:"column",alignItems:"stretch",gap:2,width:"100%",children:[u.map(i=>e.jsxs(n.Box,{paddingBottom:2,children:[e.jsxs(n.Flex,{justifyContent:"space-between",alignItems:"center",gap:2,children:[e.jsxs(n.Flex,{direction:"column",alignItems:"flex-start",gap:1,grow:1,minWidth:0,children:[e.jsxs(n.Flex,{gap:2,alignItems:"center",children:[e.jsx(n.Badge,{backgroundColor:O.has(i.origin)?"primary100":"neutral150",textColor:O.has(i.origin)?"primary600":"neutral600",children:N[i.origin]??i.origin}),i.locale?e.jsx(n.Typography,{variant:"pi",textColor:"neutral500",children:i.locale}):null]}),i.label?e.jsx(n.Box,{width:"100%",children:e.jsx(n.Typography,{variant:"omega",textColor:"neutral800",ellipsis:!0,children:i.label})}):null,e.jsxs(n.Typography,{variant:"pi",textColor:"neutral600",children:[q(i.createdAt),i.user?` · ${i.user.name}`:""]}),i.pinned?e.jsx(n.Typography,{variant:"pi",textColor:"primary600",fontWeight:"bold",children:"Pinned"}):null,e.jsx(n.TextButton,{onClick:()=>V(i),children:"What changed"})]}),e.jsxs(n.Flex,{shrink:0,gap:1,alignItems:"center",children:[e.jsx(n.IconButton,{size:"S",variant:"ghost",label:i.pinned?"Unpin this version, so tidying up can remove it":"Pin this version, so tidying up never removes it",onClick:()=>J(i),children:e.jsx(ee.Pin,{fill:i.pinned?"primary600":"neutral500"})}),e.jsx(n.Button,{size:"S",variant:"tertiary",onClick:()=>Z(i),children:"Restore"})]})]}),e.jsx(n.Box,{paddingTop:2,children:e.jsx(n.Divider,{})})]},i.id)),u.length<l?e.jsx(n.Button,{size:"S",variant:"tertiary",loading:S,onClick:()=>b(U+1),children:"Show older versions"}):null,v?e.jsx(n.Typography,{variant:"pi",textColor:"danger600",children:v}):null,f?e.jsx(oe,{diff:H,loading:G,subject:_(f),options:u.filter(i=>i.id!==f.id).map(i=>({id:i.id,name:_(i)})),againstId:z,onChangeAgainst:K,hasUnloadedVersions:u.length<l,onClose:()=>F(null)}):null,e.jsx(n.Dialog.Root,{open:a!==null,onOpenChange:()=>C(null),children:e.jsxs(n.Dialog.Content,{children:[e.jsx(n.Dialog.Header,{children:"Restore this version?"}),e.jsx(n.Dialog.Body,{children:e.jsxs(n.Flex,{direction:"column",alignItems:"flex-start",gap:2,children:[e.jsx(n.Typography,{children:"The current draft is saved as a version first, so this can be undone. The published version is not touched."}),a?.preview.crossLocaleFields.length?e.jsxs(n.Typography,{textColor:"danger600",children:[a.preview.crossLocaleFields.join(", ")," ",a.preview.crossLocaleFields.length===1?"is":"are"," not translated per locale, so restoring"," ",a.preview.crossLocaleFields.length===1?"it":"them"," changes"," ",a.preview.affectedLocales.length," locales at once:"," ",a.preview.affectedLocales.join(", "),"."]}):null,a?.preview.fieldsKeptAsIs.length?e.jsxs(n.Typography,{variant:"pi",textColor:"neutral600",children:["Added since this version and left untouched:"," ",a.preview.fieldsKeptAsIs.join(", "),"."]}):null,a?.preview.fieldsDropped.length?e.jsxs(n.Typography,{variant:"pi",textColor:"neutral600",children:["No longer in the model and skipped: ",a.preview.fieldsDropped.join(", "),"."]}):null,a?.preview.brokenRelations.length||a?.preview.missingMedia.length?e.jsx(n.Typography,{variant:"pi",textColor:"warning600",children:ae(a.preview)}):null]})}),e.jsxs(n.Dialog.Footer,{children:[e.jsx(n.Dialog.Cancel,{children:e.jsx(n.Button,{variant:"tertiary",disabled:$,children:"Cancel"})}),e.jsx(n.Button,{onClick:Q,loading:$,children:"Restore"})]})]})})]})},ce=({model:t,documentId:r,document:s})=>r?{title:"History",content:e.jsx(de,{model:t,documentId:r,updatedAt:s?.updatedAt})}:null,ue={register(t){t.registerPlugin({id:h,name:h,isReady:!0})},bootstrap(t){t.getPlugin("content-manager").apis.addEditViewSidePanel([ce])},async registerTrads({locales:t}){return Promise.all(t.map(async r=>{try{const{default:s}=await ne(Object.assign({"./translations/en.json":()=>Promise.resolve().then(()=>require("../_chunks/en-BHfx2OWt.js"))}),`./translations/${r}.json`,3);return{data:s,locale:r}}catch{return{data:{},locale:r}}}))}};exports.PLUGIN_ID=h;exports.default=ue;exports.registerDiffRenderer=re;
@@ -1,104 +1,112 @@
1
- import { jsx as t, jsxs as l } from "react/jsx-runtime";
2
- import * as c from "react";
3
- import { useFetchClient as le } from "@strapi/admin/strapi-admin";
4
- import { Modal as v, Flex as u, Typography as r, SingleSelect as ae, SingleSelectOption as M, Loader as z, Box as k, Button as S, Badge as oe, TextButton as se, IconButton as de, Divider as ce, Dialog as y } from "@strapi/design-system";
5
- import { Pin as ue } from "@strapi/icons";
6
- const he = (e, i, a) => {
7
- const h = e[i];
8
- return h ? typeof h == "function" ? h() : Promise.resolve(h) : new Promise((R, C) => {
1
+ import { jsx as t, jsxs as o } from "react/jsx-runtime";
2
+ import * as u from "react";
3
+ import { useFetchClient as oe } from "@strapi/admin/strapi-admin";
4
+ import { Modal as y, Flex as h, Typography as l, SingleSelect as ae, SingleSelectOption as M, Loader as G, Box as k, Button as $, Badge as se, TextButton as de, IconButton as ce, Divider as ue, Dialog as w } from "@strapi/design-system";
5
+ import { Pin as he } from "@strapi/icons";
6
+ const ge = (e, i, r) => {
7
+ const s = e[i];
8
+ return s ? typeof s == "function" ? s() : Promise.resolve(s) : new Promise((p, m) => {
9
9
  (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
10
- C.bind(
10
+ m.bind(
11
11
  null,
12
12
  new Error(
13
- "Unknown variable dynamic import: " + i + (i.split("/").length !== a ? ". Note that variables only represent file names one level deep." : "")
13
+ "Unknown variable dynamic import: " + i + (i.split("/").length !== r ? ". Note that variables only represent file names one level deep." : "")
14
14
  )
15
15
  )
16
16
  );
17
17
  });
18
- }, G = /* @__PURE__ */ new Map(), Se = (e, i) => {
19
- G.set(e, i);
20
- }, U = (e) => G.get(e), pe = ({ spans: e }) => /* @__PURE__ */ t(r, { variant: "omega", tag: "p", children: e.map((i, a) => i.op === "equal" ? /* @__PURE__ */ t(r, { variant: "omega", textColor: "neutral600", children: i.value }, a) : /* @__PURE__ */ t(
21
- r,
18
+ }, V = /* @__PURE__ */ new Map(), ke = (e, i) => {
19
+ V.set(e, i);
20
+ }, U = (e) => V.get(e), pe = ({ spans: e }) => /* @__PURE__ */ t(l, { variant: "omega", tag: "p", children: e.map((i, r) => i.op === "equal" ? /* @__PURE__ */ t(l, { variant: "omega", textColor: "neutral600", children: i.value }, r) : /* @__PURE__ */ t(
21
+ l,
22
22
  {
23
23
  variant: "omega",
24
24
  textColor: i.op === "added" ? "success600" : "danger600",
25
25
  style: i.op === "removed" ? { textDecoration: "line-through" } : { fontWeight: 600 },
26
26
  children: i.value
27
27
  },
28
- a
29
- )) }), W = (e) => e == null || e === "" ? "(empty)" : typeof e == "object" ? JSON.stringify(e) : String(e), ge = ({ change: e }) => {
28
+ r
29
+ )) }), W = (e) => {
30
+ const i = e.map((s) => s.label).filter(Boolean);
31
+ if (i.length === 0) return `${e.length} item${e.length === 1 ? "" : "s"}`;
32
+ const r = e.length - i.length;
33
+ return r ? `${i.join(", ")} and ${r} more` : i.join(", ");
34
+ }, _ = (e) => e == null || e === "" ? "(empty)" : typeof e == "object" ? JSON.stringify(e) : String(e), me = ({ change: e }) => {
30
35
  const i = (e.customField ? U(e.customField) : void 0) ?? U(e.type);
31
- return i ? /* @__PURE__ */ t(i, { change: e }) : e.spans ? /* @__PURE__ */ t(pe, { spans: e.spans }) : e.linked || e.unlinked ? /* @__PURE__ */ l(u, { direction: "column", alignItems: "flex-start", gap: 1, children: [
32
- e.linked?.length ? /* @__PURE__ */ l(r, { variant: "pi", textColor: "success600", children: [
36
+ return i ? /* @__PURE__ */ t(i, { change: e }) : e.spans ? /* @__PURE__ */ t(pe, { spans: e.spans }) : e.linked || e.unlinked ? /* @__PURE__ */ o(h, { direction: "column", alignItems: "flex-start", gap: 1, children: [
37
+ e.linked?.length ? /* @__PURE__ */ o(l, { variant: "pi", textColor: "success600", children: [
33
38
  "+ ",
34
- e.linked.length,
35
- " linked"
39
+ W(e.linked)
36
40
  ] }) : null,
37
- e.unlinked?.length ? /* @__PURE__ */ l(r, { variant: "pi", textColor: "danger600", children: [
41
+ e.unlinked?.length ? /* @__PURE__ */ o(l, { variant: "pi", textColor: "danger600", children: [
38
42
  "− ",
39
- e.unlinked.length,
40
- " unlinked"
43
+ W(e.unlinked)
41
44
  ] }) : null
42
- ] }) : e.before !== void 0 || e.after !== void 0 ? /* @__PURE__ */ l(u, { gap: 2, alignItems: "center", wrap: "wrap", children: [
45
+ ] }) : e.before !== void 0 || e.after !== void 0 ? /* @__PURE__ */ o(h, { gap: 2, alignItems: "center", wrap: "wrap", children: [
43
46
  /* @__PURE__ */ t(
44
- r,
47
+ l,
45
48
  {
46
49
  variant: "omega",
47
50
  textColor: "danger600",
48
51
  style: { textDecoration: "line-through" },
49
- children: W(e.before)
52
+ children: _(e.before)
50
53
  }
51
54
  ),
52
- /* @__PURE__ */ t(r, { variant: "omega", textColor: "neutral500", children: "→" }),
53
- /* @__PURE__ */ t(r, { variant: "omega", textColor: "success600", children: W(e.after) })
54
- ] }) : /* @__PURE__ */ t(r, { variant: "pi", textColor: "neutral600", children: "Formatting or structure changed; the text is the same." });
55
- }, P = "previous", me = ({
55
+ /* @__PURE__ */ t(l, { variant: "omega", textColor: "neutral500", children: "→" }),
56
+ /* @__PURE__ */ t(l, { variant: "omega", textColor: "success600", children: _(e.after) })
57
+ ] }) : /* @__PURE__ */ t(l, { variant: "pi", textColor: "neutral600", children: "Formatting or structure changed; the text is the same." });
58
+ }, D = "previous", fe = ({
56
59
  diff: e,
57
60
  loading: i,
58
- onClose: a,
59
- subject: h,
60
- options: R,
61
- againstId: C,
62
- onChangeAgainst: p,
63
- hasUnloadedVersions: w
64
- }) => /* @__PURE__ */ t(v.Root, { open: !0, onOpenChange: a, children: /* @__PURE__ */ l(v.Content, { children: [
65
- /* @__PURE__ */ t(v.Header, { children: /* @__PURE__ */ t(v.Title, { children: "What changed" }) }),
66
- /* @__PURE__ */ l(v.Body, { children: [
67
- /* @__PURE__ */ l(u, { direction: "column", alignItems: "stretch", gap: 2, paddingBottom: 4, children: [
68
- /* @__PURE__ */ l(r, { variant: "pi", textColor: "neutral600", children: [
61
+ onClose: r,
62
+ subject: s,
63
+ options: p,
64
+ againstId: m,
65
+ onChangeAgainst: g,
66
+ hasUnloadedVersions: b
67
+ }) => /* @__PURE__ */ t(y.Root, { open: !0, onOpenChange: r, children: /* @__PURE__ */ o(y.Content, { children: [
68
+ /* @__PURE__ */ t(y.Header, { children: /* @__PURE__ */ t(y.Title, { children: "What changed" }) }),
69
+ /* @__PURE__ */ o(y.Body, { children: [
70
+ /* @__PURE__ */ o(h, { direction: "column", alignItems: "stretch", gap: 2, paddingBottom: 4, children: [
71
+ /* @__PURE__ */ o(l, { variant: "pi", textColor: "neutral600", children: [
69
72
  "Comparing ",
70
- /* @__PURE__ */ t("b", { children: h }),
73
+ /* @__PURE__ */ t("b", { children: s }),
71
74
  " with"
72
75
  ] }),
73
- /* @__PURE__ */ l(
76
+ /* @__PURE__ */ o(
74
77
  ae,
75
78
  {
76
79
  "aria-label": "Compare with",
77
80
  size: "S",
78
- value: C === null ? P : String(C),
79
- onChange: (s) => p(String(s) === P ? null : Number(s)),
81
+ value: m === null ? D : String(m),
82
+ onChange: (d) => g(String(d) === D ? null : Number(d)),
80
83
  children: [
81
- /* @__PURE__ */ t(M, { value: P, children: "The version saved just before it" }),
82
- R.map((s) => /* @__PURE__ */ t(M, { value: String(s.id), children: s.name }, s.id))
84
+ /* @__PURE__ */ t(M, { value: D, children: "The version saved just before it" }),
85
+ p.map((d) => /* @__PURE__ */ t(M, { value: String(d.id), children: d.name }, d.id))
83
86
  ]
84
87
  }
85
88
  ),
86
- w ? /* @__PURE__ */ l(r, { variant: "pi", textColor: "neutral600", children: [
89
+ b ? /* @__PURE__ */ o(l, { variant: "pi", textColor: "neutral600", children: [
87
90
  "Only versions loaded in the panel are listed. Use ",
88
91
  /* @__PURE__ */ t("b", { children: "Show older versions" }),
89
92
  " there to reach further back."
90
93
  ] }) : null
91
94
  ] }),
92
- i ? /* @__PURE__ */ t(u, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ t(z, { small: !0, children: "Comparing" }) }) : e ? /* @__PURE__ */ l(u, { direction: "column", alignItems: "stretch", gap: 4, children: [
93
- e.from ? null : /* @__PURE__ */ t(r, { variant: "pi", textColor: "neutral600", children: "This is the earliest version of the document, so everything in it is new." }),
94
- e.identical ? /* @__PURE__ */ t(r, { textColor: "neutral600", children: "Nothing changed between these two versions." }) : e.changes.map((s) => /* @__PURE__ */ l(k, { children: [
95
- /* @__PURE__ */ t(r, { variant: "sigma", textColor: "neutral600", children: s.field }),
96
- /* @__PURE__ */ t(k, { paddingTop: 1, children: /* @__PURE__ */ t(ge, { change: s }) })
97
- ] }, s.field))
98
- ] }) : /* @__PURE__ */ t(r, { textColor: "danger600", children: "Could not compare these versions." })
95
+ i ? /* @__PURE__ */ t(h, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ t(G, { small: !0, children: "Comparing" }) }) : e ? /* @__PURE__ */ o(h, { direction: "column", alignItems: "stretch", gap: 4, children: [
96
+ e.from ? null : /* @__PURE__ */ t(l, { variant: "pi", textColor: "neutral600", children: "This is the earliest version of the document, so everything in it is new." }),
97
+ e.identical ? /* @__PURE__ */ t(l, { textColor: "neutral600", children: "Nothing changed between these two versions." }) : e.changes.map((d) => /* @__PURE__ */ o(k, { children: [
98
+ /* @__PURE__ */ t(l, { variant: "sigma", textColor: "neutral600", children: d.field }),
99
+ /* @__PURE__ */ t(k, { paddingTop: 1, children: /* @__PURE__ */ t(me, { change: d }) })
100
+ ] }, d.field))
101
+ ] }) : /* @__PURE__ */ t(l, { textColor: "danger600", children: "Could not compare these versions." })
99
102
  ] }),
100
- /* @__PURE__ */ t(v.Footer, { children: /* @__PURE__ */ t(S, { variant: "tertiary", onClick: a, children: "Close" }) })
101
- ] }) }), f = "rewind", V = {
103
+ /* @__PURE__ */ t(y.Footer, { children: /* @__PURE__ */ t($, { variant: "tertiary", onClick: r, children: "Close" }) })
104
+ ] }) }), v = "rewind", Ce = (e) => {
105
+ const i = [...e.brokenRelations, ...e.missingMedia], r = i.map((g) => g.label).filter(Boolean), s = `${i.length} linked item${i.length === 1 ? "" : "s"}`;
106
+ if (r.length === 0) return `${s} no longer exist and will be left out.`;
107
+ const p = i.length - r.length;
108
+ return `${p ? `${r.join(", ")} and ${p} more` : r.join(", ")} no longer exist${i.length === 1 ? "s" : ""} and will be left out.`;
109
+ }, q = {
102
110
  create: "Created",
103
111
  update: "Edited",
104
112
  clone: "Cloned",
@@ -106,10 +114,10 @@ const he = (e, i, a) => {
106
114
  unpublish: "Unpublished",
107
115
  discardDraft: "Draft discarded",
108
116
  restore: "Replaced by restore"
109
- }, _ = /* @__PURE__ */ new Set(["publish", "unpublish", "discardDraft", "restore"]), fe = 10, H = (e) => `${V[e.origin] ?? e.origin} · ${q(e.createdAt)}`, q = (e) => {
110
- const i = new Date(e), a = Math.round((Date.now() - i.getTime()) / 6e4);
111
- return a < 1 ? "just now" : a < 60 ? `${a} min ago` : a < 60 * 24 ? `${Math.round(a / 60)} h ago` : i.toLocaleString();
112
- }, Ce = ({
117
+ }, H = /* @__PURE__ */ new Set(["publish", "unpublish", "discardDraft", "restore"]), ve = 10, z = (e) => `${q[e.origin] ?? e.origin} · ${K(e.createdAt)}`, K = (e) => {
118
+ const i = new Date(e), r = Math.round((Date.now() - i.getTime()) / 6e4);
119
+ return r < 1 ? "just now" : r < 60 ? `${r} min ago` : r < 60 * 24 ? `${Math.round(r / 60)} h ago` : i.toLocaleString();
120
+ }, ye = ({
113
121
  model: e,
114
122
  documentId: i,
115
123
  /**
@@ -118,194 +126,190 @@ const he = (e, i, a) => {
118
126
  * fetches once on mount and then quietly goes stale, so the version you just
119
127
  * created by saving does not show up until the page is reloaded.
120
128
  */
121
- updatedAt: a
129
+ updatedAt: r
122
130
  }) => {
123
- const { get: h, post: R, put: C } = le(), [p, w] = c.useState([]), [s, K] = c.useState(0), [J, Z] = c.useState(1), [L, $] = c.useState(!0), [I, x] = c.useState(null), [o, T] = c.useState(null), [A, F] = c.useState(!1), [b, N] = c.useState(null), [Q, B] = c.useState(null), [X, D] = c.useState(null), [Y, O] = c.useState(!1), j = c.useCallback(
131
+ const { get: s, post: p, put: m } = oe(), [g, b] = u.useState([]), [d, J] = u.useState(0), [Z, Q] = u.useState(1), [P, L] = u.useState(!0), [R, x] = u.useState(null), [a, j] = u.useState(null), [A, F] = u.useState(!1), [S, B] = u.useState(null), [X, N] = u.useState(null), [Y, T] = u.useState(null), [ee, O] = u.useState(!1), I = u.useCallback(
124
132
  async (n) => {
125
- $(!0), x(null);
133
+ L(!0), x(null);
126
134
  try {
127
- const { data: d } = await h(`/${f}/versions`, {
135
+ const { data: c } = await s(`/${v}/versions`, {
128
136
  params: {
129
137
  contentType: e,
130
138
  documentId: i,
131
139
  page: n,
132
- pageSize: fe
140
+ pageSize: ve
133
141
  }
134
142
  });
135
- w((g) => n === 1 ? d.data : [...g, ...d.data]), K(d.meta.total), Z(n);
143
+ b((f) => n === 1 ? c.data : [...f, ...c.data]), J(c.meta.total), Q(n);
136
144
  } catch {
137
145
  x("Could not load the history for this document.");
138
146
  } finally {
139
- $(!1);
147
+ L(!1);
140
148
  }
141
149
  },
142
- [h, e, i]
150
+ [s, e, i]
143
151
  );
144
- c.useEffect(() => {
145
- j(1);
146
- }, [j, a]);
147
- const E = async (n, d) => {
148
- O(!0), D(null);
152
+ u.useEffect(() => {
153
+ I(1);
154
+ }, [I, r]);
155
+ const E = async (n, c) => {
156
+ O(!0), T(null);
149
157
  try {
150
- const { data: g } = await h(
151
- `/${f}/versions/${n.id}/diff`,
152
- d === null ? void 0 : { params: { against: d } }
158
+ const { data: f } = await s(
159
+ `/${v}/versions/${n.id}/diff`,
160
+ c === null ? void 0 : { params: { against: c } }
153
161
  );
154
- D(g.data);
162
+ T(f.data);
155
163
  } catch {
156
- D(null);
164
+ T(null);
157
165
  } finally {
158
166
  O(!1);
159
167
  }
160
- }, ee = (n) => {
161
- N(n), B(null), E(n, null);
162
168
  }, te = (n) => {
163
- b && (B(n), E(b, n));
164
- }, ne = async (n) => {
165
- const d = !n.pinned;
166
- w((g) => g.map((m) => m.id === n.id ? { ...m, pinned: d } : m));
169
+ B(n), N(null), E(n, null);
170
+ }, ne = (n) => {
171
+ S && (N(n), E(S, n));
172
+ }, ie = async (n) => {
173
+ const c = !n.pinned;
174
+ b((f) => f.map((C) => C.id === n.id ? { ...C, pinned: c } : C));
167
175
  try {
168
- await C(`/${f}/versions/${n.id}/pin`, { pinned: d });
176
+ await m(`/${v}/versions/${n.id}/pin`, { pinned: c });
169
177
  } catch {
170
- w(
171
- (g) => g.map((m) => m.id === n.id ? { ...m, pinned: !d } : m)
172
- ), x(d ? "Could not pin that version." : "Could not unpin that version.");
178
+ b(
179
+ (f) => f.map((C) => C.id === n.id ? { ...C, pinned: !c } : C)
180
+ ), x(c ? "Could not pin that version." : "Could not unpin that version.");
173
181
  }
174
- }, ie = async (n) => {
182
+ }, re = async (n) => {
175
183
  try {
176
- const { data: d } = await h(
177
- `/${f}/versions/${n.id}/preview`
184
+ const { data: c } = await s(
185
+ `/${v}/versions/${n.id}/preview`
178
186
  );
179
- T({ version: n, preview: d.data });
187
+ j({ version: n, preview: c.data });
180
188
  } catch {
181
189
  x("Could not work out what restoring this version would change.");
182
190
  }
183
- }, re = async () => {
184
- if (o) {
191
+ }, le = async () => {
192
+ if (a) {
185
193
  F(!0);
186
194
  try {
187
- await R(`/${f}/versions/${o.version.id}/restore`, {}), window.location.reload();
195
+ await p(`/${v}/versions/${a.version.id}/restore`, {}), window.location.reload();
188
196
  } catch {
189
- x("The restore failed. Nothing was changed."), F(!1), T(null);
197
+ x("The restore failed. Nothing was changed."), F(!1), j(null);
190
198
  }
191
199
  }
192
200
  };
193
- return L && p.length === 0 ? /* @__PURE__ */ t(u, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ t(z, { small: !0, children: "Loading history" }) }) : I && p.length === 0 ? /* @__PURE__ */ t(r, { variant: "pi", textColor: "danger600", children: I }) : p.length === 0 ? /* @__PURE__ */ t(r, { variant: "pi", textColor: "neutral600", children: "No versions yet. The next time this document is saved, a version will appear here." }) : /* @__PURE__ */ l(u, { direction: "column", alignItems: "stretch", gap: 2, width: "100%", children: [
194
- p.map((n) => /* @__PURE__ */ l(k, { paddingBottom: 2, children: [
195
- /* @__PURE__ */ l(u, { justifyContent: "space-between", alignItems: "center", gap: 2, children: [
196
- /* @__PURE__ */ l(u, { direction: "column", alignItems: "flex-start", gap: 1, grow: 1, minWidth: 0, children: [
197
- /* @__PURE__ */ l(u, { gap: 2, alignItems: "center", children: [
201
+ return P && g.length === 0 ? /* @__PURE__ */ t(h, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ t(G, { small: !0, children: "Loading history" }) }) : R && g.length === 0 ? /* @__PURE__ */ t(l, { variant: "pi", textColor: "danger600", children: R }) : g.length === 0 ? /* @__PURE__ */ t(l, { variant: "pi", textColor: "neutral600", children: "No versions yet. The next time this document is saved, a version will appear here." }) : /* @__PURE__ */ o(h, { direction: "column", alignItems: "stretch", gap: 2, width: "100%", children: [
202
+ g.map((n) => /* @__PURE__ */ o(k, { paddingBottom: 2, children: [
203
+ /* @__PURE__ */ o(h, { justifyContent: "space-between", alignItems: "center", gap: 2, children: [
204
+ /* @__PURE__ */ o(h, { direction: "column", alignItems: "flex-start", gap: 1, grow: 1, minWidth: 0, children: [
205
+ /* @__PURE__ */ o(h, { gap: 2, alignItems: "center", children: [
198
206
  /* @__PURE__ */ t(
199
- oe,
207
+ se,
200
208
  {
201
- backgroundColor: _.has(n.origin) ? "primary100" : "neutral150",
202
- textColor: _.has(n.origin) ? "primary600" : "neutral600",
203
- children: V[n.origin] ?? n.origin
209
+ backgroundColor: H.has(n.origin) ? "primary100" : "neutral150",
210
+ textColor: H.has(n.origin) ? "primary600" : "neutral600",
211
+ children: q[n.origin] ?? n.origin
204
212
  }
205
213
  ),
206
- n.locale ? /* @__PURE__ */ t(r, { variant: "pi", textColor: "neutral500", children: n.locale }) : null
214
+ n.locale ? /* @__PURE__ */ t(l, { variant: "pi", textColor: "neutral500", children: n.locale }) : null
207
215
  ] }),
208
- n.label ? /* @__PURE__ */ t(k, { width: "100%", children: /* @__PURE__ */ t(r, { variant: "omega", textColor: "neutral800", ellipsis: !0, children: n.label }) }) : null,
209
- /* @__PURE__ */ l(r, { variant: "pi", textColor: "neutral600", children: [
210
- q(n.createdAt),
216
+ n.label ? /* @__PURE__ */ t(k, { width: "100%", children: /* @__PURE__ */ t(l, { variant: "omega", textColor: "neutral800", ellipsis: !0, children: n.label }) }) : null,
217
+ /* @__PURE__ */ o(l, { variant: "pi", textColor: "neutral600", children: [
218
+ K(n.createdAt),
211
219
  n.user ? ` · ${n.user.name}` : ""
212
220
  ] }),
213
- n.pinned ? /* @__PURE__ */ t(r, { variant: "pi", textColor: "primary600", fontWeight: "bold", children: "Pinned" }) : null,
214
- /* @__PURE__ */ t(se, { onClick: () => ee(n), children: "What changed" })
221
+ n.pinned ? /* @__PURE__ */ t(l, { variant: "pi", textColor: "primary600", fontWeight: "bold", children: "Pinned" }) : null,
222
+ /* @__PURE__ */ t(de, { onClick: () => te(n), children: "What changed" })
215
223
  ] }),
216
- /* @__PURE__ */ l(u, { shrink: 0, gap: 1, alignItems: "center", children: [
224
+ /* @__PURE__ */ o(h, { shrink: 0, gap: 1, alignItems: "center", children: [
217
225
  /* @__PURE__ */ t(
218
- de,
226
+ ce,
219
227
  {
220
228
  size: "S",
221
229
  variant: "ghost",
222
230
  label: n.pinned ? "Unpin this version, so tidying up can remove it" : "Pin this version, so tidying up never removes it",
223
- onClick: () => ne(n),
224
- children: /* @__PURE__ */ t(ue, { fill: n.pinned ? "primary600" : "neutral500" })
231
+ onClick: () => ie(n),
232
+ children: /* @__PURE__ */ t(he, { fill: n.pinned ? "primary600" : "neutral500" })
225
233
  }
226
234
  ),
227
- /* @__PURE__ */ t(S, { size: "S", variant: "tertiary", onClick: () => ie(n), children: "Restore" })
235
+ /* @__PURE__ */ t($, { size: "S", variant: "tertiary", onClick: () => re(n), children: "Restore" })
228
236
  ] })
229
237
  ] }),
230
- /* @__PURE__ */ t(k, { paddingTop: 2, children: /* @__PURE__ */ t(ce, {}) })
238
+ /* @__PURE__ */ t(k, { paddingTop: 2, children: /* @__PURE__ */ t(ue, {}) })
231
239
  ] }, n.id)),
232
- p.length < s ? /* @__PURE__ */ t(S, { size: "S", variant: "tertiary", loading: L, onClick: () => j(J + 1), children: "Show older versions" }) : null,
233
- I ? /* @__PURE__ */ t(r, { variant: "pi", textColor: "danger600", children: I }) : null,
234
- b ? /* @__PURE__ */ t(
235
- me,
240
+ g.length < d ? /* @__PURE__ */ t($, { size: "S", variant: "tertiary", loading: P, onClick: () => I(Z + 1), children: "Show older versions" }) : null,
241
+ R ? /* @__PURE__ */ t(l, { variant: "pi", textColor: "danger600", children: R }) : null,
242
+ S ? /* @__PURE__ */ t(
243
+ fe,
236
244
  {
237
- diff: X,
238
- loading: Y,
239
- subject: H(b),
240
- options: p.filter((n) => n.id !== b.id).map((n) => ({ id: n.id, name: H(n) })),
241
- againstId: Q,
242
- onChangeAgainst: te,
243
- hasUnloadedVersions: p.length < s,
244
- onClose: () => N(null)
245
+ diff: Y,
246
+ loading: ee,
247
+ subject: z(S),
248
+ options: g.filter((n) => n.id !== S.id).map((n) => ({ id: n.id, name: z(n) })),
249
+ againstId: X,
250
+ onChangeAgainst: ne,
251
+ hasUnloadedVersions: g.length < d,
252
+ onClose: () => B(null)
245
253
  }
246
254
  ) : null,
247
- /* @__PURE__ */ t(y.Root, { open: o !== null, onOpenChange: () => T(null), children: /* @__PURE__ */ l(y.Content, { children: [
248
- /* @__PURE__ */ t(y.Header, { children: "Restore this version?" }),
249
- /* @__PURE__ */ t(y.Body, { children: /* @__PURE__ */ l(u, { direction: "column", alignItems: "flex-start", gap: 2, children: [
250
- /* @__PURE__ */ t(r, { children: "The current draft is saved as a version first, so this can be undone. The published version is not touched." }),
251
- o?.preview.crossLocaleFields.length ? /* @__PURE__ */ l(r, { textColor: "danger600", children: [
252
- o.preview.crossLocaleFields.join(", "),
255
+ /* @__PURE__ */ t(w.Root, { open: a !== null, onOpenChange: () => j(null), children: /* @__PURE__ */ o(w.Content, { children: [
256
+ /* @__PURE__ */ t(w.Header, { children: "Restore this version?" }),
257
+ /* @__PURE__ */ t(w.Body, { children: /* @__PURE__ */ o(h, { direction: "column", alignItems: "flex-start", gap: 2, children: [
258
+ /* @__PURE__ */ t(l, { children: "The current draft is saved as a version first, so this can be undone. The published version is not touched." }),
259
+ a?.preview.crossLocaleFields.length ? /* @__PURE__ */ o(l, { textColor: "danger600", children: [
260
+ a.preview.crossLocaleFields.join(", "),
253
261
  " ",
254
- o.preview.crossLocaleFields.length === 1 ? "is" : "are",
262
+ a.preview.crossLocaleFields.length === 1 ? "is" : "are",
255
263
  " not translated per locale, so restoring",
256
264
  " ",
257
- o.preview.crossLocaleFields.length === 1 ? "it" : "them",
265
+ a.preview.crossLocaleFields.length === 1 ? "it" : "them",
258
266
  " changes",
259
267
  " ",
260
- o.preview.affectedLocales.length,
268
+ a.preview.affectedLocales.length,
261
269
  " locales at once:",
262
270
  " ",
263
- o.preview.affectedLocales.join(", "),
271
+ a.preview.affectedLocales.join(", "),
264
272
  "."
265
273
  ] }) : null,
266
- o?.preview.fieldsKeptAsIs.length ? /* @__PURE__ */ l(r, { variant: "pi", textColor: "neutral600", children: [
274
+ a?.preview.fieldsKeptAsIs.length ? /* @__PURE__ */ o(l, { variant: "pi", textColor: "neutral600", children: [
267
275
  "Added since this version and left untouched:",
268
276
  " ",
269
- o.preview.fieldsKeptAsIs.join(", "),
277
+ a.preview.fieldsKeptAsIs.join(", "),
270
278
  "."
271
279
  ] }) : null,
272
- o?.preview.fieldsDropped.length ? /* @__PURE__ */ l(r, { variant: "pi", textColor: "neutral600", children: [
280
+ a?.preview.fieldsDropped.length ? /* @__PURE__ */ o(l, { variant: "pi", textColor: "neutral600", children: [
273
281
  "No longer in the model and skipped: ",
274
- o.preview.fieldsDropped.join(", "),
282
+ a.preview.fieldsDropped.join(", "),
275
283
  "."
276
284
  ] }) : null,
277
- o?.preview.brokenRelations.length || o?.preview.missingMedia.length ? /* @__PURE__ */ l(r, { variant: "pi", textColor: "warning600", children: [
278
- (o.preview.brokenRelations.length ?? 0) + (o.preview.missingMedia.length ?? 0),
279
- " ",
280
- "linked item(s) no longer exist and will be left out."
281
- ] }) : null
285
+ a?.preview.brokenRelations.length || a?.preview.missingMedia.length ? /* @__PURE__ */ t(l, { variant: "pi", textColor: "warning600", children: Ce(a.preview) }) : null
282
286
  ] }) }),
283
- /* @__PURE__ */ l(y.Footer, { children: [
284
- /* @__PURE__ */ t(y.Cancel, { children: /* @__PURE__ */ t(S, { variant: "tertiary", disabled: A, children: "Cancel" }) }),
285
- /* @__PURE__ */ t(S, { onClick: re, loading: A, children: "Restore" })
287
+ /* @__PURE__ */ o(w.Footer, { children: [
288
+ /* @__PURE__ */ t(w.Cancel, { children: /* @__PURE__ */ t($, { variant: "tertiary", disabled: A, children: "Cancel" }) }),
289
+ /* @__PURE__ */ t($, { onClick: le, loading: A, children: "Restore" })
286
290
  ] })
287
291
  ] }) })
288
292
  ] });
289
- }, ve = ({
293
+ }, we = ({
290
294
  model: e,
291
295
  documentId: i,
292
- document: a
296
+ document: r
293
297
  }) => i ? {
294
298
  title: "History",
295
- content: /* @__PURE__ */ t(Ce, { model: e, documentId: i, updatedAt: a?.updatedAt })
296
- } : null, ke = {
299
+ content: /* @__PURE__ */ t(ye, { model: e, documentId: i, updatedAt: r?.updatedAt })
300
+ } : null, Re = {
297
301
  register(e) {
298
- e.registerPlugin({ id: f, name: f, isReady: !0 });
302
+ e.registerPlugin({ id: v, name: v, isReady: !0 });
299
303
  },
300
304
  bootstrap(e) {
301
- e.getPlugin("content-manager").apis.addEditViewSidePanel([ve]);
305
+ e.getPlugin("content-manager").apis.addEditViewSidePanel([we]);
302
306
  },
303
307
  async registerTrads({ locales: e }) {
304
308
  return Promise.all(
305
309
  e.map(async (i) => {
306
310
  try {
307
- const { default: a } = await he(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("../_chunks/en-DCctmu-a.mjs") }), `./translations/${i}.json`, 3);
308
- return { data: a, locale: i };
311
+ const { default: r } = await ge(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("../_chunks/en-DCctmu-a.mjs") }), `./translations/${i}.json`, 3);
312
+ return { data: r, locale: i };
309
313
  } catch {
310
314
  return { data: {}, locale: i };
311
315
  }
@@ -314,7 +318,7 @@ const he = (e, i, a) => {
314
318
  }
315
319
  };
316
320
  export {
317
- f as PLUGIN_ID,
318
- ke as default,
319
- Se as registerDiffRenderer
321
+ v as PLUGIN_ID,
322
+ Re as default,
323
+ ke as registerDiffRenderer
320
324
  };