nextcloud-server/dist/files_trashbin-init.js

2 lines
9.8 KiB
JavaScript

(()=>{"use strict";var e,t,n,r={88864:(e,t,n)=>{var r=n(35810),i=n(61884),a=n(85168),s=n(61338),l=n(53334),o=n(71225),d=n(63814),c=n(19051),u=n(51651),f=n(85471),p=n(77764);const b=new r.VP({id:"files_trashbin--original-location",title:(0,l.Tl)("files_trashbin","Original location"),render(e){const t=y(e),n=document.createElement("span");return n.title=t,n.textContent=t,n},sort(e,t){const n=y(e),r=y(t);return n.localeCompare(r,[(0,l.Z0)(),(0,l.lO)()],{numeric:!0,usage:"sort"})}}),h=new r.VP({id:"files_trashbin--deleted-by",title:(0,l.Tl)("files_trashbin","Deleted by"),render(e){const{userId:t,displayName:n,label:r}=g(e);if(r){const e=document.createElement("span");return e.textContent=r,e}return new(f.Ay.extend(p.A))({propsData:{size:32,user:t??void 0,displayName:n??t}}).$mount().$el},sort(e,t){const n=g(e),r=n.label??n.displayName??n.userId,i=g(t),a=i.label??i.displayName??i.userId;return r.localeCompare(a,[(0,l.Z0)(),(0,l.lO)()],{numeric:!0,usage:"sort"})}}),m=new r.VP({id:"files_trashbin--deleted",title:(0,l.Tl)("files_trashbin","Deleted"),render(e){const t=e.attributes?.["trashbin-deletion-time"]||(e?.mtime?.getTime()??0)/1e3,n=document.createElement("span");return t?(n.title=u.A.unix(t).format("LLL"),n.textContent=u.A.unix(t).fromNow(),n):(n.textContent=(0,l.Tl)("files_trashbin","A long time ago"),n)},sort(e,t){const n=e.attributes?.["trashbin-deletion-time"]||(e?.mtime?.getTime()??0)/1e3;return(t.attributes?.["trashbin-deletion-time"]||(t?.mtime?.getTime()??0)/1e3)-n}});function y(e){const t=v(e.attributes?.["trashbin-original-location"]);if(!t)return(0,l.Tl)("files_trashbin","Unknown");const n=(0,o.pD)(t);return n===t?(0,l.Tl)("files_trashbin","All files"):n.replace(/^\//,"")}function g(e){const t=v(e.attributes?.["trashbin-deleted-by-id"]),n=v(e.attributes?.["trashbin-deleted-by-display-name"]);let r;const a=(0,i.HW)()?.uid;return t===a&&(r=(0,l.Tl)("files_trashbin","You")),t||n||(r=(0,l.Tl)("files_trashbin","Unknown")),{userId:t,displayName:n,label:r}}function v(e){return e?String(e):null}const w=`/trashbin/${(0,i.HW)()?.uid}/trash`,A=(0,r.H4)(),_=`<?xml version="1.0"?>\n<d:propfind ${(0,r.CP)()}>\n\t<d:prop>\n\t\t<nc:trashbin-deletion-time />\n\t\t<nc:trashbin-original-location />\n\t\t<nc:trashbin-title />\n\t\t<nc:trashbin-deleted-by-id />\n\t\t<nc:trashbin-deleted-by-display-name />\n\t\t${(0,r.VX)()}\n\t</d:prop>\n</d:propfind>`,x=e=>{const t=(0,r.Al)(e,w);return t.attributes.previewUrl=(0,d.Jv)("/apps/files_trashbin/preview?fileId={fileid}&x=32&y=32",{fileid:t.fileid}),t};var C=n(45174);const T="trashbin",S=new r.Ss({id:T,name:(0,l.t)("files_trashbin","Deleted files"),caption:(0,l.t)("files_trashbin","List of files that have been deleted."),emptyTitle:(0,l.t)("files_trashbin","No deleted files"),emptyCaption:(0,l.t)("files_trashbin","Files and folders you have deleted will show up here"),icon:C,order:50,sticky:!0,defaultSortKey:"deleted",columns:[b,h,m],getContents:async(e="/")=>{const t=(await A.getDirectoryContents(`${w}${e}`,{details:!0,data:_,includeSelf:!0})).data.map(x),[n]=t.splice(t.findIndex((t=>t.path===e)),1);return{folder:n,contents:t}}});var P=n(35947);const E=(0,P.YK)().setApp("files").detectUser().build(),N=new r.hY({id:"restore",displayName:()=>(0,l.t)("files_trashbin","Restore"),iconSvgInline:()=>'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-history" viewBox="0 0 24 24"><path d="M13.5,8H12V13L16.28,15.54L17,14.33L13.5,12.25V8M13,3A9,9 0 0,0 4,12H1L4.96,16.03L9,12H6A7,7 0 0,1 13,5A7,7 0 0,1 20,12A7,7 0 0,1 13,19C11.07,19 9.32,18.21 8.06,16.94L6.64,18.36C8.27,20 10.5,21 13,21A9,9 0 0,0 22,12A9,9 0 0,0 13,3" /></svg>',enabled:(e,t)=>t.id===T&&e.length>0&&e.map((e=>e.permissions)).every((e=>Boolean(e&r.aX.READ))),async exec(e){try{const t=(0,d.dC)((0,o.O0)(`dav/trashbin/${(0,i.HW)().uid}/restore/${e.basename}`));return await c.Ay.request({method:"MOVE",url:e.encodedSource,headers:{destination:t}}),(0,s.Ic)("files:node:deleted",e),!0}catch(t){return 507===t.response?.status&&(0,a.Qg)((0,l.t)("files_trashbin","Not enough free space to restore the file/folder")),E.error("Failed to restore node",{error:t,node:e}),!1}},async execBatch(e,t,n){return Promise.all(e.map((e=>this.exec(e,t,n))))},order:1,inline:()=>!0});var O=n(32981),k=n(77815);const I=(0,P.YK)().setApp("files_trashbin").detectUser().build(),L=new r.VI({id:"empty-trash",displayName:()=>(0,l.t)("files_trashbin","Empty deleted files"),order:0,enabled:(e,t,n)=>e.id===T&&(!!(0,O.C)("files_trashbin","config").allow_delete&&t.length>0&&"/"===n.path),async exec(e,t){const n=new Promise((e=>{(0,a.As)((0,l.t)("files_trashbin","Confirm permanent deletion")).setSeverity(a.aR.Warning).setText((0,l.t)("files_trashbin","Are you sure you want to permanently delete all files and folders in the trash? This cannot be undone.")).setButtons([{label:(0,l.t)("files_trashbin","Cancel"),type:"secondary",callback:()=>e(!1)},{label:(0,l.t)("files_trashbin","Empty deleted files"),type:"error",callback:()=>e(!0)}]).build().show().then((()=>{e(!1)}))}));return!0===await n?(await async function(){try{return await c.Ay.delete(`${k.Xn}/trashbin/${(0,i.HW)().uid}/trash`),(0,a.Te)((0,l.t)("files_trashbin","All files have been permanently deleted")),!0}catch(e){return(0,a.Qg)((0,l.t)("files_trashbin","Failed to empty deleted files")),I.error("Failed to empty deleted files",{error:e}),!1}}()&&t.forEach((e=>(0,s.Ic)("files:node:deleted",e))),null):((0,a.cf)((0,l.t)("files_trashbin","Deletion cancelled")),null)}});var $=n(85072),j=n.n($),D=n(97825),H=n.n(D),V=n(77659),B=n.n(V),F=n(55056),U=n.n(F),X=n(10540),M=n.n(X),R=n(41113),G=n.n(R),W=n(98290),Y={};Y.styleTagTransform=G(),Y.setAttributes=U(),Y.insert=B().bind(null,"head"),Y.domAPI=H(),Y.insertStyleElement=M(),j()(W.A,Y),W.A&&W.A.locals&&W.A.locals,(0,r.bh)().register(S),(0,r.yC)(L),(0,r.Gg)(N)},98290:(e,t,n)=>{n.d(t,{A:()=>l});var r=n(71354),i=n.n(r),a=n(76314),s=n.n(a)()(i());s.push([e.id,"/*!\n * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */.files-list__row-trashbin-original-location{width:150px !important}","",{version:3,sources:["webpack://./apps/files_trashbin/src/trashbin.scss"],names:[],mappings:"AAAA;;;EAAA,CAIA,4CACE,sBAAA",sourcesContent:["/*!\n * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n.files-list__row-trashbin-original-location {\n width: 150px !important;\n}\n"],sourceRoot:""}]);const l=s}},i={};function a(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={id:e,loaded:!1,exports:{}};return r[e].call(n.exports,n,n.exports,a),n.loaded=!0,n.exports}a.m=r,e=[],a.O=(t,n,r,i)=>{if(!n){var s=1/0;for(c=0;c<e.length;c++){n=e[c][0],r=e[c][1],i=e[c][2];for(var l=!0,o=0;o<n.length;o++)(!1&i||s>=i)&&Object.keys(a.O).every((e=>a.O[e](n[o])))?n.splice(o--,1):(l=!1,i<s&&(s=i));if(l){e.splice(c--,1);var d=r();void 0!==d&&(t=d)}}return t}i=i||0;for(var c=e.length;c>0&&e[c-1][2]>i;c--)e[c]=e[c-1];e[c]=[n,r,i]},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,n)=>(a.f[n](e,t),t)),[])),a.u=e=>e+"-"+e+".js?v="+{3278:"8b4fe0854296793e7bfb",4612:"aebb24cec040bc57223b",5664:"4b28558df62ae5fee1e5",7471:"6423b9b898ffefeb7d1d"}[e],a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},n="nextcloud:",a.l=(e,r,i,s)=>{if(t[e])t[e].push(r);else{var l,o;if(void 0!==i)for(var d=document.getElementsByTagName("script"),c=0;c<d.length;c++){var u=d[c];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==n+i){l=u;break}}l||(o=!0,(l=document.createElement("script")).charset="utf-8",l.timeout=120,a.nc&&l.setAttribute("nonce",a.nc),l.setAttribute("data-webpack",n+i),l.src=e),t[e]=[r];var f=(n,r)=>{l.onerror=l.onload=null,clearTimeout(p);var i=t[e];if(delete t[e],l.parentNode&&l.parentNode.removeChild(l),i&&i.forEach((e=>e(r))),n)return n(r)},p=setTimeout(f.bind(null,void 0,{type:"timeout",target:l}),12e4);l.onerror=f.bind(null,l.onerror),l.onload=f.bind(null,l.onload),o&&document.head.appendChild(l)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),a.j=2573,(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var r=n.length-1;r>-1&&(!e||!/^http(s?):/.test(e));)e=n[r--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{a.b=document.baseURI||self.location.href;var e={2573:0};a.f.j=(t,n)=>{var r=a.o(e,t)?e[t]:void 0;if(0!==r)if(r)n.push(r[2]);else{var i=new Promise(((n,i)=>r=e[t]=[n,i]));n.push(r[2]=i);var s=a.p+a.u(t),l=new Error;a.l(s,(n=>{if(a.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var i=n&&("load"===n.type?"missing":n.type),s=n&&n.target&&n.target.src;l.message="Loading chunk "+t+" failed.\n("+i+": "+s+")",l.name="ChunkLoadError",l.type=i,l.request=s,r[1](l)}}),"chunk-"+t,t)}},a.O.j=t=>0===e[t];var t=(t,n)=>{var r,i,s=n[0],l=n[1],o=n[2],d=0;if(s.some((t=>0!==e[t]))){for(r in l)a.o(l,r)&&(a.m[r]=l[r]);if(o)var c=o(a)}for(t&&t(n);d<s.length;d++)i=s[d],a.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return a.O(c)},n=self.webpackChunknextcloud=self.webpackChunknextcloud||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})(),a.nc=void 0;var s=a.O(void 0,[4208],(()=>a(88864)));s=a.O(s)})();
//# sourceMappingURL=files_trashbin-init.js.map?v=126b7f6d267fb51e87d9