nextcloud-server/dist/files_versions-files_versio...

2 lines
31 KiB
JavaScript

(()=>{var e,i,n,s={15340:()=>{},25227:(e,i,n)=>{"use strict";var s=n(53334),o=n(80284),r=n(85471),a=n(21777),l=n(85168),c=n(61338),d=n(53429),u=n(43627),v=n.n(u),f=n(88289),p=n(35810),h=n(81222),m=n(51651),A=n(71225),b=n(63814),_=n(59656),g=n(57505),C=n(39999),w=n(41944),y=n(4604),V=n(1522);const x={name:"BackupRestoreIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var k=n(14486);const L=(0,k.A)(x,function(){var e=this,t=e._self._c;return t("span",e._b({staticClass:"material-design-icon backup-restore-icon",attrs:{"aria-hidden":e.title?null:"true","aria-label":e.title,role:"img"},on:{click:function(t){return e.$emit("click",t)}}},"span",e.$attrs,!1),[t("svg",{staticClass:"material-design-icon__svg",attrs:{fill:e.fillColor,width:e.size,height:e.size,viewBox:"0 0 24 24"}},[t("path",{attrs:{d:"M12,3A9,9 0 0,0 3,12H0L4,16L8,12H5A7,7 0 0,1 12,5A7,7 0 0,1 19,12A7,7 0 0,1 12,19C10.5,19 9.09,18.5 7.94,17.7L6.5,19.14C8.04,20.3 9.94,21 12,21A9,9 0 0,0 21,12A9,9 0 0,0 12,3M14,12A2,2 0 0,0 12,10A2,2 0 0,0 10,12A2,2 0 0,0 12,14A2,2 0 0,0 14,12Z"}},[e.title?t("title",[e._v(e._s(e.title))]):e._e()])])])},[],!1,null,null,null).exports,S={name:"FileCompareIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},I=(0,k.A)(S,function(){var e=this,t=e._self._c;return t("span",e._b({staticClass:"material-design-icon file-compare-icon",attrs:{"aria-hidden":e.title?null:"true","aria-label":e.title,role:"img"},on:{click:function(t){return e.$emit("click",t)}}},"span",e.$attrs,!1),[t("svg",{staticClass:"material-design-icon__svg",attrs:{fill:e.fillColor,width:e.size,height:e.size,viewBox:"0 0 24 24"}},[t("path",{attrs:{d:"M10,18H6V16H10V18M10,14H6V12H10V14M10,1V2H6C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H10V23H12V1H10M20,8V20C20,21.11 19.11,22 18,22H14V20H18V11H14V9H18.5L14,4.5V2L20,8M16,14H14V12H16V14M16,18H14V16H16V18Z"}},[e.title?t("title",[e._v(e._s(e.title))]):e._e()])])])},[],!1,null,null,null).exports,H={name:"ImageOffOutlineIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},E=(0,k.A)(H,function(){var e=this,t=e._self._c;return t("span",e._b({staticClass:"material-design-icon image-off-outline-icon",attrs:{"aria-hidden":e.title?null:"true","aria-label":e.title,role:"img"},on:{click:function(t){return e.$emit("click",t)}}},"span",e.$attrs,!1),[t("svg",{staticClass:"material-design-icon__svg",attrs:{fill:e.fillColor,width:e.size,height:e.size,viewBox:"0 0 24 24"}},[t("path",{attrs:{d:"M22 20.7L3.3 2L2 3.3L3 4.3V19C3 20.1 3.9 21 5 21H19.7L20.7 22L22 20.7M5 19V6.3L12.6 13.9L11.1 15.8L9 13.1L6 17H15.7L17.7 19H5M8.8 5L6.8 3H19C20.1 3 21 3.9 21 5V17.2L19 15.2V5H8.8"}},[e.title?t("title",[e._v(e._s(e.title))]):e._e()])])])},[],!1,null,null,null).exports;var D=n(16502),T=n(37793),B=n(89025);const $=(e,t)=>0!==(e&t),N=(0,r.pM)({name:"VersionEntry",components:{NcActionLink:C.A,NcActionButton:g.A,NcAvatar:w.A,NcDateTime:y.A,NcListItem:V.A,BackupRestore:L,Download:B.A,FileCompare:I,Pencil:D.A,Delete:T.A,ImageOffOutline:E},directives:{tooltip:_.A},props:{version:{type:Object,required:!0},fileInfo:{type:Object,required:!0},isCurrent:{type:Boolean,default:!1},isFirstVersion:{type:Boolean,default:!1},loadPreview:{type:Boolean,default:!1},canView:{type:Boolean,default:!1},canCompare:{type:Boolean,default:!1}},emits:["click","compare","restore","delete","label-update-request"],data:()=>({previewLoaded:!1,previewErrored:!1,capabilities:(0,h.C)("core","capabilities",{files:{version_labeling:!1,version_deletion:!1}})}),computed:{humanReadableSize(){return(0,p.v7)(this.version.size)},versionLabel(){const e=this.version.label??"";return this.isCurrent?""===e?(0,s.t)("files_versions","Current version"):`${e} (${(0,s.t)("files_versions","Current version")})`:this.isFirstVersion&&""===e?(0,s.t)("files_versions","Initial version"):e},versionAuthor(){return this.version.author&&this.version.authorName?this.version.author===(0,a.HW)()?.uid?(0,s.t)("files_versions","You"):this.version.authorName??this.version.author:""},versionHumanExplicitDate(){return(0,m.A)(this.version.mtime).format("LLLL")},downloadURL(){return this.isCurrent?(0,b.aU)()+(0,A.HS)("/remote.php/webdav",this.fileInfo.path,this.fileInfo.name):(0,b.aU)()+this.version.url},enableLabeling(){return!0===this.capabilities.files.version_labeling},enableDeletion(){return!0===this.capabilities.files.version_deletion},hasDeletePermissions(){return $(this.fileInfo.permissions,p.aX.DELETE)},hasUpdatePermissions(){return $(this.fileInfo.permissions,p.aX.UPDATE)},isDownloadable(){if(0===(this.fileInfo.permissions&p.aX.READ))return!1;if("shared"===this.fileInfo.mountType){const e=this.fileInfo.shareAttributes.find(e=>"permissions"===e.scope&&"download"===e.key)||{};if(!1===e?.value)return!1}return!0}},methods:{labelUpdate(){this.$emit("label-update-request")},restoreVersion(){this.$emit("restore",this.version)},async deleteVersion(){await this.$nextTick(),await this.$nextTick(),this.$emit("delete",this.version)},click(){this.canView?this.$emit("click",{version:this.version}):window.location.href=this.downloadURL},compareVersion(){if(!this.canView)throw new Error("Cannot compare version of this file");this.$emit("compare",{version:this.version})},t:s.t}});var O=n(85072),z=n.n(O),P=n(97825),M=n.n(P),R=n(77659),F=n.n(R),U=n(55056),j=n.n(U),q=n(10540),W=n.n(q),K=n(41113),G=n.n(K),Y=n(67256),X={};X.styleTagTransform=G(),X.setAttributes=j(),X.insert=F().bind(null,"head"),X.domAPI=M(),X.insertStyleElement=W(),z()(Y.A,X),Y.A&&Y.A.locals&&Y.A.locals;const J=(0,k.A)(N,function(){var e=this,t=e._self._c;return e._self._setupProxy,t("NcListItem",{staticClass:"version",attrs:{"force-display-actions":!0,"actions-aria-label":e.t("files_versions","Actions for version from {versionHumanExplicitDate}",{versionHumanExplicitDate:e.versionHumanExplicitDate}),"data-files-versions-version":e.version.fileVersion},on:{click:e.click},scopedSlots:e._u([{key:"icon",fn:function(){return[e.loadPreview||e.previewLoaded?e.version.previewUrl&&!e.previewErrored?t("img",{staticClass:"version__image",attrs:{src:e.version.previewUrl,alt:"",decoding:"async",fetchpriority:"low",loading:"lazy"},on:{load:function(t){e.previewLoaded=!0},error:function(t){e.previewErrored=!0}}}):t("div",{staticClass:"version__image"},[t("ImageOffOutline",{attrs:{size:20}})],1):t("div",{staticClass:"version__image"})]},proxy:!0},{key:"name",fn:function(){return[t("div",{staticClass:"version__info"},[e.versionLabel?t("div",{staticClass:"version__info__label",attrs:{"data-cy-files-version-label":"",title:e.versionLabel}},[e._v("\n\t\t\t\t"+e._s(e.versionLabel)+"\n\t\t\t")]):e._e(),e._v(" "),e.versionAuthor?t("div",{staticClass:"version__info",attrs:{"data-cy-files-version-author-name":""}},[e.versionLabel?t("span",[e._v("•")]):e._e(),e._v(" "),t("NcAvatar",{staticClass:"avatar",attrs:{user:e.version.author,size:20,"disable-menu":"","disable-tooltip":"","hide-status":""}}),e._v(" "),t("div",{staticClass:"version__info__author_name",attrs:{title:e.versionAuthor}},[e._v("\n\t\t\t\t\t"+e._s(e.versionAuthor)+"\n\t\t\t\t")])],1):e._e()])]},proxy:!0},{key:"subname",fn:function(){return[t("div",{staticClass:"version__info version__info__subline"},[t("NcDateTime",{staticClass:"version__info__date",attrs:{"relative-time":"short",timestamp:e.version.mtime}}),e._v(" "),t("span",[e._v("•")]),e._v(" "),t("span",[e._v(e._s(e.humanReadableSize))])],1)]},proxy:!0},{key:"actions",fn:function(){return[e.enableLabeling&&e.hasUpdatePermissions?t("NcActionButton",{attrs:{"data-cy-files-versions-version-action":"label","close-after-click":!0},on:{click:e.labelUpdate},scopedSlots:e._u([{key:"icon",fn:function(){return[t("Pencil",{attrs:{size:22}})]},proxy:!0}],null,!1,3072546167)},[e._v("\n\t\t\t"+e._s(""===e.version.label?e.t("files_versions","Name this version"):e.t("files_versions","Edit version name"))+"\n\t\t")]):e._e(),e._v(" "),!e.isCurrent&&e.canView&&e.canCompare?t("NcActionButton",{attrs:{"data-cy-files-versions-version-action":"compare","close-after-click":!0},on:{click:e.compareVersion},scopedSlots:e._u([{key:"icon",fn:function(){return[t("FileCompare",{attrs:{size:22}})]},proxy:!0}],null,!1,1958207595)},[e._v("\n\t\t\t"+e._s(e.t("files_versions","Compare to current version"))+"\n\t\t")]):e._e(),e._v(" "),!e.isCurrent&&e.hasUpdatePermissions?t("NcActionButton",{attrs:{"data-cy-files-versions-version-action":"restore","close-after-click":!0},on:{click:e.restoreVersion},scopedSlots:e._u([{key:"icon",fn:function(){return[t("BackupRestore",{attrs:{size:22}})]},proxy:!0}],null,!1,2239038444)},[e._v("\n\t\t\t"+e._s(e.t("files_versions","Restore version"))+"\n\t\t")]):e._e(),e._v(" "),e.isDownloadable?t("NcActionLink",{attrs:{"data-cy-files-versions-version-action":"download",href:e.downloadURL,"close-after-click":!0,download:e.downloadURL},scopedSlots:e._u([{key:"icon",fn:function(){return[t("Download",{attrs:{size:22}})]},proxy:!0}],null,!1,927269758)},[e._v("\n\t\t\t"+e._s(e.t("files_versions","Download version"))+"\n\t\t")]):e._e(),e._v(" "),!e.isCurrent&&e.enableDeletion&&e.hasDeletePermissions?t("NcActionButton",{attrs:{"data-cy-files-versions-version-action":"delete","close-after-click":!0},on:{click:e.deleteVersion},scopedSlots:e._u([{key:"icon",fn:function(){return[t("Delete",{attrs:{size:22}})]},proxy:!0}],null,!1,2429175571)},[e._v("\n\t\t\t"+e._s(e.t("files_versions","Delete version"))+"\n\t\t")]):e._e()]},proxy:!0}])})},[],!1,null,"641d7786",null).exports;var Q=n(65659),Z=n(94219),ee=n(82182);const te=(0,r.pM)({name:"VersionLabelDialog",components:{NcDialog:Z.A,NcTextField:ee.A},props:{open:{type:Boolean,default:!1},versionLabel:{type:String,default:""}},data:()=>({editedVersionLabel:""}),computed:{dialogButtons(){const e=[];return""===this.versionLabel.trim()?e.push({label:(0,s.t)("files_versions","Cancel")}):e.push({label:(0,s.t)("files_versions","Remove version name"),type:"reset",variant:"error",callback:()=>{this.setVersionLabel("")}}),[...e,{label:(0,s.t)("files_versions","Save version name"),icon:Q,type:"submit",variant:"primary"}]}},watch:{versionLabel:{immediate:!0,handler(e){this.editedVersionLabel=e??""}},open:{immediate:!0,handler(e){e&&this.$nextTick(()=>this.$refs.labelInput.focus()),this.editedVersionLabel=this.versionLabel}}},methods:{setVersionLabel(e){this.$emit("label-update",e)},t:s.t}});var ie=n(28035),ne={};ne.styleTagTransform=G(),ne.setAttributes=j(),ne.insert=F().bind(null,"head"),ne.domAPI=M(),ne.insertStyleElement=W(),z()(ie.A,ne),ie.A&&ie.A.locals&&ie.A.locals;const se=(0,k.A)(te,function(){var e=this,t=e._self._c;return e._self._setupProxy,t("NcDialog",{attrs:{buttons:e.dialogButtons,"content-classes":"version-label-modal","is-form":"",open:e.open,size:"normal",name:e.t("files_versions","Name this version")},on:{"update:open":function(t){return e.$emit("update:open",t)},submit:function(t){return e.setVersionLabel(e.editedVersionLabel)}}},[t("NcTextField",{ref:"labelInput",staticClass:"version-label-modal__input",attrs:{label:e.t("files_versions","Version name"),placeholder:e.t("files_versions","Version name"),value:e.editedVersionLabel},on:{"update:value":function(t){e.editedVersionLabel=t}}}),e._v(" "),t("p",{staticClass:"version-label-modal__info"},[e._v("\n\t\t"+e._s(e.t("files_versions","Named versions are persisted, and excluded from automatic cleanups when your storage quota is full."))+"\n\t")])],1)},[],!1,null,"71b93844",null).exports,oe=(0,n(35947).YK)().setApp("files_version").detectUser().build(),re=(0,r.pM)({name:"VirtualScrolling",props:{sections:{type:Array,required:!0},containerElement:{type:HTMLElement,default:null},useWindow:{type:Boolean,default:!1},headerHeight:{type:Number,default:75},renderDistance:{type:Number,default:.5},bottomBufferRatio:{type:Number,default:2},scrollToKey:{type:String,default:""}},data:()=>({scrollPosition:0,containerHeight:0,rowsContainerHeight:0,resizeObserver:null}),computed:{visibleSections(){oe.debug("[VirtualScrolling] Computing visible section",{sections:this.sections});const e=this.containerHeight,t=this.scrollPosition,i=t+e;let n=0,s=0;const o=this.sections.map(o=>(s+=this.headerHeight,{...o,rows:o.rows.reduce((o,r)=>{n=s,s+=r.height;let a=0;return s<t?a=(t-s)/e:n>i&&(a=(n-i)/e),a>this.renderDistance?o:[...o,{...r,distance:a}]},[])})).filter(e=>e.rows.length>0),r=o.flatMap(({rows:e})=>e).flatMap(({items:e})=>e),a=this._rowIdToKeyMap;r.forEach(e=>e.key=a[e.id]);const l=r.map(({key:e})=>e).filter(e=>void 0!==e),c=Object.values(a).filter(e=>!l.includes(e));return r.filter(({key:e})=>void 0===e).forEach(e=>e.key=c.pop()??Math.random().toString(36).substr(2)),this._rowIdToKeyMap=r.reduce((e,{id:t,key:i})=>({...e,[`${t}`]:i}),{}),o},totalHeight(){return this.sections.map(e=>this.headerHeight+e.height).reduce((e,t)=>e+t,0)+0},paddingTop(){if(0===this.visibleSections.length)return 0;let e=0;for(const t of this.sections)if(t.key===this.visibleSections[0].rows[0].sectionKey){for(const i of t.rows){if(i.key===this.visibleSections[0].rows[0].key)return e;e+=i.height}e+=this.headerHeight}else e+=this.headerHeight+t.height;return e},rowsContainerStyle(){return{height:`${this.totalHeight}px`,paddingTop:`${this.paddingTop}px`}},isNearBottom(){const e=this.containerHeight*this.bottomBufferRatio;return this.scrollPosition+this.containerHeight>=this.totalHeight-e},container(){return oe.debug("[VirtualScrolling] Computing container"),null!==this.containerElement?this.containerElement:this.useWindow?window:this.$refs.container}},watch:{isNearBottom(e){oe.debug("[VirtualScrolling] isNearBottom changed",{value:e}),e&&this.$emit("need-content")},visibleSections(){this.isNearBottom&&this.$emit("need-content")},scrollToKey(e){let t=0;for(const i of this.sections){if(i.key===e)break;t+=this.headerHeight+i.height}oe.debug("[VirtualScrolling] Scrolling to",{currentRowTopDistanceFromTop:t}),this.container.scrollTo({top:t,behavior:"smooth"})}},beforeCreate(){this._rowIdToKeyMap={}},mounted(){this.resizeObserver=new ResizeObserver(e=>{for(const t of e){const e=t.contentRect;t.target===this.container&&(this.containerHeight=e.height),t.target.classList.contains("vs-rows-container")&&(this.rowsContainerHeight=e.height)}}),this.useWindow?(window.addEventListener("resize",this.updateContainerSize,{passive:!0}),this.containerHeight=window.innerHeight):this.resizeObserver.observe(this.container),this.resizeObserver.observe(this.$refs.rowsContainer),this.container.addEventListener("scroll",this.updateScrollPosition,{passive:!0})},beforeDestroy(){this.useWindow&&window.removeEventListener("resize",this.updateContainerSize),this.resizeObserver?.disconnect(),this.container.removeEventListener("scroll",this.updateScrollPosition)},methods:{updateScrollPosition(){this._onScrollHandle??=requestAnimationFrame(()=>{this._onScrollHandle=null,this.useWindow?this.scrollPosition=this.container.scrollY:this.scrollPosition=this.container.scrollTop})},updateContainerSize(){this.containerHeight=window.innerHeight}}});var ae=n(94548),le={};le.styleTagTransform=G(),le.setAttributes=j(),le.insert=F().bind(null,"head"),le.domAPI=M(),le.insertStyleElement=W(),z()(ae.A,le),ae.A&&ae.A.locals&&ae.A.locals;const ce=(0,k.A)(re,function(){var e=this,t=e._self._c;return e._self._setupProxy,e.useWindow||null!==e.containerElement?t("div",{ref:"rowsContainer",staticClass:"vs-rows-container",style:e.rowsContainerStyle},[e._t("default",null,{visibleSections:e.visibleSections}),e._v(" "),e._t("loader")],2):t("div",{ref:"container",staticClass:"vs-container"},[t("div",{ref:"rowsContainer",staticClass:"vs-rows-container",style:e.rowsContainerStyle},[e._t("default",null,{visibleSections:e.visibleSections}),e._v(" "),e._t("loader")],2)])},[],!1,null,"384488e5",null).exports;var de=n(19051),ue=n(45505);const ve=(0,b.dC)("dav"),fe=(0,ue.UU)(ve);function pe(e){fe.setHeaders({"X-Requested-With":"XMLHttpRequest",requesttoken:e??""})}(0,a.zo)(pe),pe((0,a.do)());const he=fe;const me={name:"VersionTab",components:{VersionEntry:J,VirtualScrolling:ce,VersionLabelDialog:se,NcLoadingIcon:f.A},setup:()=>({isMobile:(0,d.al)()}),data:()=>({fileInfo:null,isActive:!1,versions:[],loading:!1,showVersionLabelForm:!1,editedVersion:null}),computed:{sections(){return[{key:"versions",rows:this.orderedVersions.map(e=>({key:e.mtime,height:68,sectionKey:"versions",items:[e]})),height:68*this.orderedVersions.length}]},orderedVersions(){return[...this.versions].sort((e,t)=>e.mtime===this.fileInfo.mtime?-1:t.mtime===this.fileInfo.mtime?1:t.mtime-e.mtime)},initialVersionMtime(){return this.versions.map(e=>e.mtime).reduce((e,t)=>Math.min(e,t))},viewerFileInfo(){let e="";return 1&this.fileInfo.permissions&&(e+="R"),2&this.fileInfo.permissions&&(e+="W"),8&this.fileInfo.permissions&&(e+="D"),{...this.fileInfo,mime:this.fileInfo.mimetype,basename:this.fileInfo.name,filename:this.fileInfo.path+"/"+this.fileInfo.name,permissions:e,fileid:this.fileInfo.id}},canView(){return window.OCA.Viewer?.mimetypesCompare?.includes(this.fileInfo.mimetype)},canCompare(){return!this.isMobile}},mounted(){(0,c.B1)("files_versions:restore:restored",this.fetchVersions)},beforeUnmount(){(0,c.al)("files_versions:restore:restored",this.fetchVersions)},methods:{async update(e){this.fileInfo=e,this.resetState(),this.fetchVersions()},async setIsActive(e){this.isActive=e},async fetchVersions(){try{this.loading=!0,this.versions=await async function(e){const t=`/versions/${(0,a.HW)()?.uid}/versions/${e.id}`;try{const i=(await he.getDirectoryContents(t,{data:'<?xml version="1.0"?>\n<d:propfind xmlns:d="DAV:"\n\txmlns:oc="http://owncloud.org/ns"\n\txmlns:nc="http://nextcloud.org/ns"\n\txmlns:ocs="http://open-collaboration-services.org/ns">\n\t<d:prop>\n\t\t<d:getcontentlength />\n\t\t<d:getcontenttype />\n\t\t<d:getlastmodified />\n\t\t<d:getetag />\n\t\t<nc:version-label />\n\t\t<nc:version-author />\n\t\t<nc:has-preview />\n\t</d:prop>\n</d:propfind>',details:!0})).data.filter(({mime:e})=>""!==e).map(t=>function(e,t){const i=1e3*(0,m.A)(e.lastmod).unix();let n="";return n=i===t.mtime?(0,b.Jv)("/core/preview?fileId={fileId}&c={fileEtag}&x=250&y=250&forceIcon=0&a=0&forceIcon=1&mimeFallback=1",{fileId:t.id,fileEtag:t.etag}):(0,b.Jv)("/apps/files_versions/preview?file={file}&version={fileVersion}&mimeFallback=1",{file:(0,A.HS)(t.path,t.name),fileVersion:e.basename}),{fileId:t.id,label:e.props["version-label"]?String(e.props["version-label"]):"",author:e.props["version-author"]?String(e.props["version-author"]):null,authorName:null,filename:e.filename,basename:(0,m.A)(i).format("LLL"),mime:e.mime,etag:`${e.props.getetag}`,size:e.size,type:e.type,mtime:i,permissions:"R",previewUrl:n,url:(0,A.HS)("/remote.php/dav",e.filename),source:(0,b.dC)("dav")+(0,A.O0)(e.filename),fileVersion:e.basename}}(t,e)),n=new Set(i.map(e=>String(e.author))),s=await de.Ay.post((0,b.Jv)("/displaynames"),{users:[...n]});for(const e of i){const t=s.data.users[e.author??""];t&&(e.authorName=t)}return i}catch(e){throw oe.error("Could not fetch version",{exception:e}),e}}(this.fileInfo)}finally{this.loading=!1}},async handleRestore(e){const i=this.fileInfo;this.fileInfo={...this.fileInfo,size:e.size,mtime:e.mtime};const n={preventDefault:!1,fileInfo:this.fileInfo,version:e};if((0,c.Ic)("files_versions:restore:requested",n),!n.preventDefault)try{await async function(e){try{oe.debug("Restoring version",{url:e.url}),await he.moveFile(`/versions/${(0,a.HW)()?.uid}/versions/${e.fileId}/${e.fileVersion}`,`/versions/${(0,a.HW)()?.uid}/restore/target`)}catch(e){throw oe.error("Could not restore version",{exception:e}),e}}(e),e.label?(0,l.Te)(t("files_versions",`${e.label} restored`)):e.mtime===this.initialVersionMtime?(0,l.Te)(t("files_versions","Initial version restored")):(0,l.Te)(t("files_versions","Version restored")),(0,c.Ic)("files_versions:restore:restored",e)}catch{this.fileInfo=i,(0,l.Qg)(t("files_versions","Could not restore version")),(0,c.Ic)("files_versions:restore:failed",e)}},handleLabelUpdateRequest(e){this.showVersionLabelForm=!0,this.editedVersion=e},async handleLabelUpdate(e){const t=this.editedVersion.label;this.editedVersion.label=e,this.showVersionLabelForm=!1;try{await async function(e,t){return await he.customRequest(e.filename,{method:"PROPPATCH",data:`<?xml version="1.0"?>\n\t\t\t\t\t<d:propertyupdate xmlns:d="DAV:"\n\t\t\t\t\t\txmlns:oc="http://owncloud.org/ns"\n\t\t\t\t\t\txmlns:nc="http://nextcloud.org/ns"\n\t\t\t\t\t\txmlns:ocs="http://open-collaboration-services.org/ns">\n\t\t\t\t\t<d:set>\n\t\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t\t<nc:version-label>${t}</nc:version-label>\n\t\t\t\t\t\t</d:prop>\n\t\t\t\t\t</d:set>\n\t\t\t\t\t</d:propertyupdate>`})}(this.editedVersion,e),this.editedVersion=null}catch(e){this.editedVersion.label=t,(0,l.Qg)(this.t("files_versions","Could not set version label")),oe.error("Could not set version label",{exception:e})}},async handleDelete(e){const i=this.versions.indexOf(e);this.versions.splice(i,1);try{await async function(e){await he.deleteFile(e.filename)}(e)}catch{this.versions.push(e),(0,l.Qg)(t("files_versions","Could not delete version"))}},resetState(){this.$set(this,"versions",[])},openVersion({version:e}){if(e.mtime===this.fileInfo.mtime)return void OCA.Viewer.open({fileInfo:this.viewerFileInfo});const t=this.versions.map(e=>({...e,filename:e.mtime===this.fileInfo.mtime?v().join("files",(0,a.HW)()?.uid??"",this.fileInfo.path,this.fileInfo.name):e.filename,previewUrl:void 0}));OCA.Viewer.open({fileInfo:t.find(t=>t.source===e.source),enableSidebar:!1})},compareVersion({version:e}){const t=this.versions.map(e=>({...e,previewUrl:void 0}));OCA.Viewer.compare(this.viewerFileInfo,t.find(t=>t.source===e.source))}}};var Ae=n(66854),be={};be.styleTagTransform=G(),be.setAttributes=j(),be.insert=F().bind(null,"head"),be.domAPI=M(),be.insertStyleElement=W(),z()(Ae.A,be),Ae.A&&Ae.A.locals&&Ae.A.locals;const _e=(0,k.A)(me,function(){var e=this,t=e._self._c;return t("div",{staticClass:"versions-tab__container"},[t("VirtualScrolling",{attrs:{sections:e.sections,"header-height":0},scopedSlots:e._u([{key:"default",fn:function({visibleSections:i}){return[t("ul",{attrs:{"aria-label":e.t("files_versions","File versions"),"data-files-versions-versions-list":""}},[1===i.length?e._l(i[0].rows,function(i){return t("VersionEntry",{key:i.items[0].mtime,attrs:{"can-view":e.canView,"can-compare":e.canCompare,"load-preview":e.isActive,version:i.items[0],"file-info":e.fileInfo,"is-current":i.items[0].mtime===e.fileInfo.mtime,"is-first-version":i.items[0].mtime===e.initialVersionMtime},on:{click:e.openVersion,compare:e.compareVersion,restore:e.handleRestore,"label-update-request":function(t){return e.handleLabelUpdateRequest(i.items[0])},delete:e.handleDelete}})}):e._e()],2),e._v(" "),e.loading?t("NcLoadingIcon",{staticClass:"files-list-viewer__loader",attrs:{slot:"loader"},slot:"loader"}):e._e()]}}])}),e._v(" "),e.editedVersion?t("VersionLabelDialog",{attrs:{open:e.showVersionLabelForm,"version-label":e.editedVersion.label},on:{"update:open":function(t){e.showVersionLabelForm=t},"label-update":e.handleLabelUpdate}}):e._e()],1)},[],!1,null,null,null).exports;r.Ay.prototype.t=s.t,r.Ay.prototype.n=s.n,r.Ay.use(o.Ay);const ge=r.Ay.extend(_e);let Ce=null;window.addEventListener("DOMContentLoaded",function(){void 0!==OCA.Files?.Sidebar&&OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab({id:"version_vue",name:(0,s.t)("files_versions","Versions"),iconSvg:'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-backup-restore" viewBox="0 0 24 24"><path d="M12,3A9,9 0 0,0 3,12H0L4,16L8,12H5A7,7 0 0,1 12,5A7,7 0 0,1 19,12A7,7 0 0,1 12,19C10.5,19 9.09,18.5 7.94,17.7L6.5,19.14C8.04,20.3 9.94,21 12,21A9,9 0 0,0 21,12A9,9 0 0,0 12,3M14,12A2,2 0 0,0 12,10A2,2 0 0,0 10,12A2,2 0 0,0 12,14A2,2 0 0,0 14,12Z" /></svg>',async mount(e,t,i){Ce&&Ce.$destroy(),Ce=new ge({parent:i}),await Ce.update(t),Ce.$mount(e)},update(e){Ce.update(e)},setIsActive(e){Ce&&Ce.setIsActive(e)},destroy(){Ce.$destroy(),Ce=null},enabled:e=>!(e?.isDirectory()??1)}))})},28035:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var n=i(71354),s=i.n(n),o=i(76314),r=i.n(o)()(s());r.push([e.id,".version-label-modal__info[data-v-71b93844]{color:var(--color-text-maxcontrast);margin-block:calc(3*var(--default-grid-baseline))}.version-label-modal__input[data-v-71b93844]{margin-block-start:calc(2*var(--default-grid-baseline))}","",{version:3,sources:["webpack://./apps/files_versions/src/components/VersionLabelDialog.vue"],names:[],mappings:"AAEC,4CACC,mCAAA,CACA,iDAAA,CAGD,6CACC,uDAAA",sourcesContent:["\n.version-label-modal {\n\t&__info {\n\t\tcolor: var(--color-text-maxcontrast);\n\t\tmargin-block: calc(3 * var(--default-grid-baseline));\n\t}\n\n\t&__input {\n\t\tmargin-block-start: calc(2 * var(--default-grid-baseline));\n\t}\n}\n"],sourceRoot:""}]);const a=r},42634:()=>{},47790:()=>{},51069:()=>{},59169:()=>{},63779:()=>{},64688:()=>{},66089:()=>{},66854:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var n=i(71354),s=i.n(n),o=i(76314),r=i.n(o)()(s());r.push([e.id,".versions-tab__container{height:100%}","",{version:3,sources:["webpack://./apps/files_versions/src/views/VersionTab.vue"],names:[],mappings:"AACA,yBACC,WAAA",sourcesContent:["\n.versions-tab__container {\n\theight: 100%;\n}\n"],sourceRoot:""}]);const a=r},67256:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var n=i(71354),s=i.n(n),o=i(76314),r=i.n(o)()(s());r.push([e.id,".version[data-v-641d7786]{display:flex;flex-direction:row}.version__info[data-v-641d7786]{display:flex;flex-direction:row;align-items:center;gap:.5rem;color:var(--color-main-text);font-weight:500;overflow:hidden}.version__info__label[data-v-641d7786]{font-weight:700;overflow:hidden;text-overflow:ellipsis;min-width:110px}.version__info__author_name[data-v-641d7786]{overflow:hidden;text-overflow:ellipsis}.version__info__date[data-v-641d7786]{overflow:hidden;text-overflow:ellipsis}.version__info__subline[data-v-641d7786]{color:var(--color-text-maxcontrast)}.version__image[data-v-641d7786]{width:3rem;height:3rem;border:1px solid var(--color-border);border-radius:var(--border-radius-large);display:flex;justify-content:center;color:var(--color-main-text)}","",{version:3,sources:["webpack://./apps/files_versions/src/components/VersionEntry.vue"],names:[],mappings:"AACA,0BACC,YAAA,CACA,kBAAA,CAEA,gCACC,YAAA,CACA,kBAAA,CACA,kBAAA,CACA,SAAA,CACA,4BAAA,CACA,eAAA,CACA,eAAA,CAEA,uCACC,eAAA,CAEA,eAAA,CACA,sBAAA,CACA,eAAA,CAGD,6CACC,eAAA,CACA,sBAAA,CAGD,sCAEC,eAAA,CACA,sBAAA,CAGD,yCACC,mCAAA,CAIF,iCACC,UAAA,CACA,WAAA,CACA,oCAAA,CACA,wCAAA,CAGA,YAAA,CACA,sBAAA,CACA,4BAAA",sourcesContent:["\n.version {\n\tdisplay: flex;\n\tflex-direction: row;\n\n\t&__info {\n\t\tdisplay: flex;\n\t\tflex-direction: row;\n\t\talign-items: center;\n\t\tgap: 0.5rem;\n\t\tcolor: var(--color-main-text);\n\t\tfont-weight: 500;\n\t\toverflow: hidden;\n\n\t\t&__label {\n\t\t\tfont-weight: 700;\n\t\t\t// Fix overflow on narrow screens\n\t\t\toverflow: hidden;\n\t\t\ttext-overflow: ellipsis;\n\t\t\tmin-width: 110px;\n\t\t}\n\n\t\t&__author_name {\n\t\t\toverflow: hidden;\n\t\t\ttext-overflow: ellipsis;\n\t\t}\n\n\t\t&__date {\n\t\t\t// Fix overflow on narrow screens\n\t\t\toverflow: hidden;\n\t\t\ttext-overflow: ellipsis;\n\t\t}\n\n\t\t&__subline {\n\t\t\tcolor: var(--color-text-maxcontrast)\n\t\t}\n\t}\n\n\t&__image {\n\t\twidth: 3rem;\n\t\theight: 3rem;\n\t\tborder: 1px solid var(--color-border);\n\t\tborder-radius: var(--border-radius-large);\n\n\t\t// Useful to display no preview icon.\n\t\tdisplay: flex;\n\t\tjustify-content: center;\n\t\tcolor: var(--color-main-text);\n\t}\n}\n"],sourceRoot:""}]);const a=r},73776:()=>{},77199:()=>{},77965:()=>{},78982:()=>{},79368:()=>{},79838:()=>{},86833:()=>{},94548:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var n=i(71354),s=i.n(n),o=i(76314),r=i.n(o)()(s());r.push([e.id,".vs-container[data-v-384488e5]{overflow-y:scroll;height:100%}.vs-rows-container[data-v-384488e5]{box-sizing:border-box;will-change:scroll-position,padding;contain:layout paint style}","",{version:3,sources:["webpack://./apps/files_versions/src/components/VirtualScrolling.vue"],names:[],mappings:"AACA,+BACC,iBAAA,CACA,WAAA,CAGD,oCACC,qBAAA,CACA,mCAAA,CACA,0BAAA",sourcesContent:["\n.vs-container {\n\toverflow-y: scroll;\n\theight: 100%;\n}\n\n.vs-rows-container {\n\tbox-sizing: border-box;\n\twill-change: scroll-position, padding;\n\tcontain: layout paint style;\n}\n"],sourceRoot:""}]);const a=r}},o={};function r(e){var t=o[e];if(void 0!==t)return t.exports;var i=o[e]={id:e,loaded:!1,exports:{}};return s[e].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}r.m=s,e=[],r.O=(t,i,n,s)=>{if(!i){var o=1/0;for(d=0;d<e.length;d++){for(var[i,n,s]=e[d],a=!0,l=0;l<i.length;l++)(!1&s||o>=s)&&Object.keys(r.O).every(e=>r.O[e](i[l]))?i.splice(l--,1):(a=!1,s<o&&(o=s));if(a){e.splice(d--,1);var c=n();void 0!==c&&(t=c)}}return t}s=s||0;for(var d=e.length;d>0&&e[d-1][2]>s;d--)e[d]=e[d-1];e[d]=[i,n,s]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce((t,i)=>(r.f[i](e,t),t),[])),r.u=e=>e+"-"+e+".js?v="+{594:"706f8e77fcd637f25ccf",2391:"a1c7f293d21dd6ef8096",3166:"6ee0264908909e0260a1",4325:"cc118df199f1941c08e4",5862:"4ca96c4f928b038599cf",7347:"ec35b00310c1ae3cecd4",8339:"3f9cf3b616cfbc0082d4",9507:"0a08b35d8e91ee8529d0"}[e],r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i={},n="nextcloud:",r.l=(e,t,s,o)=>{if(i[e])i[e].push(t);else{var a,l;if(void 0!==s)for(var c=document.getElementsByTagName("script"),d=0;d<c.length;d++){var u=c[d];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==n+s){a=u;break}}a||(l=!0,(a=document.createElement("script")).charset="utf-8",r.nc&&a.setAttribute("nonce",r.nc),a.setAttribute("data-webpack",n+s),a.src=e),i[e]=[t];var v=(t,n)=>{a.onerror=a.onload=null,clearTimeout(f);var s=i[e];if(delete i[e],a.parentNode&&a.parentNode.removeChild(a),s&&s.forEach(e=>e(n)),t)return t(n)},f=setTimeout(v.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=v.bind(null,a.onerror),a.onload=v.bind(null,a.onload),l&&document.head.appendChild(a)}},r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),r.j=2250,(()=>{var e;r.g.importScripts&&(e=r.g.location+"");var t=r.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var i=t.getElementsByTagName("script");if(i.length)for(var n=i.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=i[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e})(),(()=>{r.b="undefined"!=typeof document&&document.baseURI||self.location.href;var e={2250:0};r.f.j=(t,i)=>{var n=r.o(e,t)?e[t]:void 0;if(0!==n)if(n)i.push(n[2]);else{var s=new Promise((i,s)=>n=e[t]=[i,s]);i.push(n[2]=s);var o=r.p+r.u(t),a=new Error;r.l(o,i=>{if(r.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var s=i&&("load"===i.type?"missing":i.type),o=i&&i.target&&i.target.src;a.message="Loading chunk "+t+" failed.\n("+s+": "+o+")",a.name="ChunkLoadError",a.type=s,a.request=o,n[1](a)}},"chunk-"+t,t)}},r.O.j=t=>0===e[t];var t=(t,i)=>{var n,s,[o,a,l]=i,c=0;if(o.some(t=>0!==e[t])){for(n in a)r.o(a,n)&&(r.m[n]=a[n]);if(l)var d=l(r)}for(t&&t(i);c<o.length;c++)s=o[c],r.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return r.O(d)},i=self.webpackChunknextcloud=self.webpackChunknextcloud||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})(),r.nc=void 0;var a=r.O(void 0,[4208],()=>r(25227));a=r.O(a)})();
//# sourceMappingURL=files_versions-files_versions.js.map?v=8ef874edb7784ae762cc