mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
12 lines
6.4 KiB
JavaScript
12 lines
6.4 KiB
JavaScript
import{C as c,V as _,g as v,a as x,b as V}from"./index-CZqtY2I6.chunk.mjs";import{a as o,g as H,e as p}from"./index-6_gsQFyp.chunk.mjs";import{c as u,i as A}from"./index-ClUK5nWL.chunk.mjs";import{a as b,d as C,g as N}from"./index-C1xmmKTZ-B_lLl9Ld.chunk.mjs";import{P as E}from"./public-BJJBqhxW.chunk.mjs";import{d as S,e as $,l as I}from"./index-Ma7sfat2.chunk.mjs";import{t as n,g as y,a as f}from"./translation-DoG5ZELJ-2ffMJaM4.chunk.mjs";import{g as D,i as L}from"./createElementId-DhjFt1I9-CRJVCjcq.chunk.mjs";import{g as M,a as T,b as k,r as F,d as B}from"./dav-DxC6BCcd.chunk.mjs";import{f as U}from"./index-DeDXQtUD.chunk.mjs";import{h as P}from"./runtime-dom.esm-bundler-nUg13ekW.chunk.mjs";import{N as O}from"./NcUserBubble-vOAXLHB5-hYokuz_z.chunk.mjs";import"./index-sH3U_332.chunk.mjs";import"./NcNoteCard-Cok_4Fld-BLQT242e.chunk.mjs";import"./logger-D3RVzcfQ-B4GxPQ5t.chunk.mjs";import"./index-Gli2NTV8.chunk.mjs";import"./mdi-DK5BPbEO.chunk.mjs";import"./NcAvatar-C9d7Wrc8-DSaQpb7G.chunk.mjs";import"./colors-BHGKZFDI-_xZPp21x.chunk.mjs";import"./NcUserStatusIcon-XiwrgeCm-BGKwPmPa.chunk.mjs";import"./PencilOutline-Da_gxdzI.chunk.mjs";import"./NcDateTime.vue_vue_type_script_setup_true_lang-BhB8yA4U-DyY3Wrls.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>',q='<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>',g=`/trashbin/${o()?.uid}/trash`,z=M(),K=`<?xml version="1.0"?>
|
|
<d:propfind ${T()}>
|
|
<d:prop>
|
|
<nc:trashbin-deletion-time />
|
|
<nc:trashbin-original-location />
|
|
<nc:trashbin-title />
|
|
<nc:trashbin-deleted-by-id />
|
|
<nc:trashbin-deleted-by-display-name />
|
|
${k()}
|
|
</d:prop>
|
|
</d:propfind>`;function Y(i){const e=F(i,g);return e.attributes.previewUrl=D("/apps/files_trashbin/preview?fileId={fileid}&x=32&y=32",{fileid:e.fileid}),e}async function Z(i="/"){const e=(await z.getDirectoryContents(`${g}${i}`,{details:!0,data:K,includeSelf:!0})).data.map(Y),[t]=e.splice(e.findIndex(r=>r.path===i),1);return{folder:t,contents:e}}const j=new c({id:"files_trashbin--original-location",title:n("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),r=l(e);return t.localeCompare(r,[y(),f()],{numeric:!0,usage:"sort"})}}),G=new c({id:"files_trashbin--deleted-by",title:n("files_trashbin","Deleted by"),render(i){const{userId:e,displayName:t,label:r}=d(i);if(r){const a=document.createElement("span");return a.textContent=r,a}const s=document.createElement("div");return P(O,{size:32,user:e??void 0,displayName:t??e}).mount(s),s},sort(i,e){const t=d(i),r=t.label??t.displayName??t.userId,s=d(e),a=s.label??s.displayName??s.userId;return r.localeCompare(a,[y(),f()],{numeric:!0,usage:"sort"})}}),J=new c({id:"files_trashbin--deleted",title:n("files_trashbin","Deleted"),render(i){const e=i.attributes?.["trashbin-deletion-time"]||(i?.mtime?.getTime()??0)/1e3,t=document.createElement("span");if(e){const r=Intl.DateTimeFormat([f()],{dateStyle:"long",timeStyle:"short"}),s=new Date(e*1e3);return t.title=r.format(s),t.textContent=U(s,{ignoreSeconds:n("files","few seconds ago")}),t}return t.textContent=n("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 n("files_trashbin","Unknown");const t=S(e);return t==="/"||t==="."?n("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 r;const s=o()?.uid;return e===s&&(r=n("files_trashbin","You")),!e&&!t&&(r=n("files_trashbin","Unknown")),{userId:e,displayName:t,label:r}}function m(i){return i?String(i):null}const h="trashbin",Q=new _({id:h,name:n("files_trashbin","Deleted files"),caption:n("files_trashbin","List of files that have been deleted."),emptyTitle:n("files_trashbin","No deleted files"),emptyCaption:n("files_trashbin","Files and folders you have deleted will show up here"),icon:q,order:50,sticky:!0,defaultSortKey:"deleted",columns:[j,G,J],getContents:Z}),w=H().setApp("files_trashbin").detectUser().build(),W={id:"restore",displayName(){return n("files_trashbin","Restore")},iconSvgInline:()=>R,enabled({nodes:i,view:e}){return e.id!==h?!1:i.length>0&&i.map(t=>t.permissions).every(t=>!!(t&E.READ))},async exec({nodes:i}){const e=i[0];try{const t=L($(`dav/trashbin/${o().uid}/restore/${e.basename}`));return await u.request({method:"MOVE",url:e.encodedSource,headers:{destination:t}}),p("files:node:deleted",e),!0}catch(t){return A(t)&&t.response?.status===507&&b(n("files_trashbin","Not enough free space to restore the file/folder")),w.error("Failed to restore node",{error:t,node:e}),!1}},async execBatch({nodes:i,view:e,folder:t,contents:r}){return Promise.all(i.map(s=>this.exec({nodes:[s],view:e,folder:t,contents:r})))},order:1,inline:()=>!0};async function X(){try{return await u.delete(`${B}/trashbin/${o().uid}/trash`),C(n("files_trashbin","All files have been permanently deleted")),!0}catch(i){return b(n("files_trashbin","Failed to empty deleted files")),w.error("Failed to empty deleted files",{error:i}),!1}}const ee={id:"empty-trash",displayName:()=>n("files_trashbin","Empty deleted files"),order:0,enabled({view:i,folder:e,contents:t}){return i.id!==h||!I("files_trashbin","config").allow_delete?!1:t.length>0&&e.path==="/"},async exec({contents:i}){return await new Promise(e=>{N(n("files_trashbin","Confirm permanent deletion")).setSeverity("warning").setText(n("files_trashbin","Are you sure you want to permanently delete all files and folders in the trash? This cannot be undone.")).setButtons([{label:n("files_trashbin","Cancel"),variant:"secondary",callback:()=>e(!1)},{label:n("files_trashbin","Empty deleted files"),variant:"error",callback:()=>e(!0)}]).build().show().then(()=>{e(!1)})})===!0&&await X()&&i.forEach(e=>p("files:node:deleted",e)),null}},te=v();te.register(Q),x(ee),V(W);
|
|
//# sourceMappingURL=files_trashbin-init.mjs.map
|