You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nextcloud-server/dist/files_trashbin-init.mjs

12 lines
6.6 KiB

import{C as c,V as _,b as v,c as x,a as V}from"./index-Dm6qdjjT.chunk.mjs";import{a as o,b as H,j as A,g as C,h as N,k as E,f as h}from"./index-kP1pdrFW.chunk.mjs";import{c as u,i as S}from"./index-ChXuPuJU.chunk.mjs";import{a as b,d as $,g as I}from"./index-DYY4wUHN.chunk.mjs";import{P as D}from"./externalStorageUtils-CQ1qe2np.chunk.mjs";import{g as y,b as f,t as r}from"./translation-DoG5ZELJ-Cnt4vXgN.chunk.mjs";import{g as L,a as M,b as T,r as k,d as F}from"./dav-BpUHXhz5.chunk.mjs";import{f as B}from"./NcModal-DiDvgcU8-AyGpO2Wl.chunk.mjs";import{f as U}from"./Web-CGrAivgv.chunk.mjs";import{N as P}from"./NcUserBubble-BXR7vT0V-BLCA5Wd-.chunk.mjs";import{l as O}from"./public-C1mLBHT3.chunk.mjs";import"./util-C9Hc1fff.chunk.mjs";import"./mdi-CVr4TDRq.chunk.mjs";import"./createElementId-DhjFt1I9-DwrDuyxe.chunk.mjs";import"./logger-D3RVzcfQ-k6GV3wRV.chunk.mjs";import"./Check-B8g3wLRC.chunk.mjs";import"./TrashCanOutline-CSbixKR2.chunk.mjs";import"./index-Co0EgQYL.chunk.mjs";import"./NcAvatar-1KxMUN7V-CiZW3sVm.chunk.mjs";import"./ArrowRight-Bo5pSHoF.chunk.mjs";import"./colors-Cv9F-jWS-BOqQ6yCH.chunk.mjs";import"./NcUserStatusIcon-BF5OEQFU-CflDfVCi.chunk.mjs";import"./PencilOutline-m7gX2JJw.chunk.mjs";import"./NcActionLink-BFiaYt9A-C66mrFQH.chunk.mjs";import"./NcDateTime.vue_vue_type_script_setup_true_lang-BJuPH7S7-B9ePistO.chunk.mjs";import"./NcActionText-CQ9qwJ0p-CzEyGOHa.chunk.mjs";const R='<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>',j='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-trash-can-outline" viewBox="0 0 24 24"><path d="M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M7,6H17V19H7V6M9,8V17H11V8H9M13,8V17H15V8H13Z" /></svg>',w=`/trashbin/${o()?.uid}/trash`,q=L(),z=`<?xml version="1.0"?>
<d:propfind ${M()}>
<d:prop>
<nc:trashbin-deletion-time />
<nc:trashbin-original-location />
<nc:trashbin-title />
<nc:trashbin-deleted-by-id />
<nc:trashbin-deleted-by-display-name />
${T()}
</d:prop>
</d:propfind>`;function K(i){const e=k(i,w);return e.attributes.previewUrl=H("/apps/files_trashbin/preview?fileId={fileid}&x=32&y=32",{fileid:e.fileid}),e}async function Y(i="/"){const e=(await q.getDirectoryContents(`${w}${i}`,{details:!0,data:z,includeSelf:!0})).data.map(K),[t]=e.splice(e.findIndex(n=>n.path===i),1);return{folder:t,contents:e}}const Z=new c({id:"files_trashbin--original-location",title:r("files_trashbin","Original location"),render(i){const e=l(i),t=document.createElement("span");return t.title=e,t.textContent=e,t},sort(i,e){const t=l(i),n=l(e);return t.localeCompare(n,[y(),f()],{numeric:!0,usage:"sort"})}}),G=new c({id:"files_trashbin--deleted-by",title:r("files_trashbin","Deleted by"),render(i){const{userId:e,displayName:t,label:n}=d(i);if(n){const a=document.createElement("span");return a.textContent=n,a}const s=document.createElement("div");return U(P,{size:32,user:e??void 0,displayName:t??e}).mount(s),s},sort(i,e){const t=d(i),n=t.label??t.displayName??t.userId,s=d(e),a=s.label??s.displayName??s.userId;return n.localeCompare(a,[y(),f()],{numeric:!0,usage:"sort"})}}),J=new c({id:"files_trashbin--deleted",title:r("files_trashbin","Deleted"),render(i){const e=i.attributes?.["trashbin-deletion-time"]||(i?.mtime?.getTime()??0)/1e3,t=document.createElement("span");if(e){const n=Intl.DateTimeFormat([f()],{dateStyle:"long",timeStyle:"short"}),s=new Date(e*1e3);return t.title=n.format(s),t.textContent=B(s,{ignoreSeconds:r("files","few seconds ago")}),t}return t.textContent=r("files_trashbin","A long time ago"),t},sort(i,e){const t=i.attributes?.["trashbin-deletion-time"]||(i?.mtime?.getTime()??0)/1e3;return(e.attributes?.["trashbin-deletion-time"]||(e?.mtime?.getTime()??0)/1e3)-t}});function l(i){const e=m(i.attributes?.["trashbin-original-location"]);if(!e)return r("files_trashbin","Unknown");const t=A(e);return t==="/"||t==="."?r("files_trashbin","All files"):t.replace(/^\//,"")}function d(i){const e=m(i.attributes?.["trashbin-deleted-by-id"]),t=m(i.attributes?.["trashbin-deleted-by-display-name"]);let n;const s=o()?.uid;return e===s&&(n=r("files_trashbin","You")),!e&&!t&&(n=r("files_trashbin","Unknown")),{userId:e,displayName:t,label:n}}function m(i){return i?String(i):null}const p="trashbin",Q=new _({id:p,name:r("files_trashbin","Deleted files"),caption:r("files_trashbin","List of files that have been deleted."),emptyTitle:r("files_trashbin","No deleted files"),emptyCaption:r("files_trashbin","Files and folders you have deleted will show up here"),icon:j,order:50,sticky:!0,defaultSortKey:"deleted",columns:[Z,G,J],getContents:Y}),g=C().setApp("files_trashbin").detectUser().build(),W={id:"restore",displayName(){return r("files_trashbin","Restore")},iconSvgInline:()=>R,enabled({nodes:i,view:e}){return e.id!==p?!1:i.length>0&&i.map(t=>t.permissions).every(t=>!!(t&D.READ))},async exec({nodes:i}){const e=i[0];try{const t=N(E(`dav/trashbin/${o().uid}/restore/${e.basename}`));return await u.request({method:"MOVE",url:e.encodedSource,headers:{destination:t}}),h("files:node:deleted",e),!0}catch(t){return S(t)&&t.response?.status===507&&b(r("files_trashbin","Not enough free space to restore the file/folder")),g.error("Failed to restore node",{error:t,node:e}),!1}},async execBatch({nodes:i,view:e,folder:t,contents:n}){return Promise.all(i.map(s=>this.exec({nodes:[s],view:e,folder:t,contents:n})))},order:1,inline:()=>!0};async function X(){try{return await u.delete(`${F}/trashbin/${o().uid}/trash`),$(r("files_trashbin","All files have been permanently deleted")),!0}catch(i){return b(r("files_trashbin","Failed to empty deleted files")),g.error("Failed to empty deleted files",{error:i}),!1}}const ee={id:"empty-trash",displayName:()=>r("files_trashbin","Empty deleted files"),order:0,enabled({view:i,folder:e,contents:t}){return i.id!==p||!O("files_trashbin","config").allow_delete?!1:t.length>0&&e.path==="/"},async exec({contents:i}){return await new Promise(e=>{I(r("files_trashbin","Confirm permanent deletion")).setSeverity("warning").setText(r("files_trashbin","Are you sure you want to permanently delete all files and folders in the trash? This cannot be undone.")).setButtons([{label:r("files_trashbin","Cancel"),variant:"secondary",callback:()=>e(!1)},{label:r("files_trashbin","Empty deleted files"),variant:"error",callback:()=>e(!0)}]).build().show().then(()=>{e(!1)})})===!0&&await X()&&i.forEach(e=>h("files:node:deleted",e)),null}},te=v();te.register(Q),x(ee),V(W);
//# sourceMappingURL=files_trashbin-init.mjs.map