13 lines
10 KiB
JavaScript
13 lines
10 KiB
JavaScript
import{C as I,d as Y,V as G,b as W,e as X,P as Z,c as J,g as Q,f as ee,r as te}from"./index-wzXhnBCQ.chunk.mjs";import{h as U,A as ae,L as A,j as o,a0 as se,u as y,a1 as D,a2 as H,y as ne,a3 as re,T as ie,c as N,o as h,w,a4 as C,a5 as S,B as le,a as oe,k as ue,v as M,m as de,D as ce,t as fe,E as b,p as me,e as r,a6 as z,X as k,f as pe,G as he,d as R,Y as O,q as be,l as ve}from"./TrayArrowDown-sRwZP_WA.chunk.mjs";import{f as ge,g as ye,h as we,s as F,d as _e,i as xe}from"./Plus-DDsJI2iW.chunk.mjs";import{g as Ae,a as Ce,b as Ve,c as Ie,d as ke}from"./dav-CRTiYd1u.chunk.mjs";import{r as K,e as $e,i as E,f as He,h as Ne,n as Se,g as Ee}from"./TrashCanOutline-avc1vI9P.chunk.mjs";import"./ContentCopy-BEfKgtZW.chunk.mjs";import"./index-BGFNwqHi.chunk.mjs";function T(e){const t=A(K),a=A($e),s=o(()=>{const u=y(e.to);return t.resolve(u)}),n=o(()=>{const{matched:u}=s.value,{length:d}=u,p=u[d-1],c=a.matched;if(!p||!c.length)return-1;const i=c.findIndex(E.bind(null,p));if(i>-1)return i;const f=B(u[d-2]);return d>1&&B(p)===f&&c[c.length-1].path!==f?c.findIndex(E.bind(null,u[d-2])):i}),l=o(()=>n.value>-1&&De(a.params,s.value.params)),m=o(()=>n.value>-1&&n.value===a.matched.length-1&&He(a.params,s.value.params));function v(u={}){if(Ue(u)){const d=t[y(e.replace)?"replace":"push"](y(e.to)).catch(Se);return e.viewTransition&&typeof document<"u"&&"startViewTransition"in document&&document.startViewTransition(()=>d),d}return Promise.resolve()}return{route:s,href:o(()=>s.value.href),isActive:l,isExactActive:m,navigate:v}}function Te(e){return e.length===1?e[0]:e}const Be=U({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"},viewTransition:Boolean},useLink:T,setup(e,{slots:t}){const a=ae(T(e)),{options:s}=A(K),n=o(()=>({[L(e.activeClass,s.linkActiveClass,"router-link-active")]:a.isActive,[L(e.exactActiveClass,s.linkExactActiveClass,"router-link-exact-active")]:a.isExactActive}));return()=>{const l=t.default&&Te(t.default(a));return e.custom?l:se("a",{"aria-current":a.isExactActive?e.ariaCurrentValue:null,href:a.href,onClick:a.navigate,class:n.value},l)}}}),Le=Be;function Ue(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function De(e,t){for(const a in t){const s=t[a],n=e[a];if(typeof s=="string"){if(s!==n)return!1}else if(!Ne(n)||n.length!==s.length||s.some((l,m)=>l!==n[m]))return!1}return!0}function B(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const L=(e,t,a)=>e??t??a,Me={};function ze(e,t){return h(),M("div",null,[C(e.$slots,"trigger")])}const Re=D(Me,[["render",ze]]),Oe={class:"user-bubble__name"},Fe={key:0,class:"user-bubble__secondary"},Ke=U({__name:"NcUserBubble",props:H({avatarImage:{default:void 0},user:{default:void 0},displayName:{default:void 0},showUserStatus:{type:Boolean},url:{default:void 0},to:{default:void 0},primary:{type:Boolean},size:{default:20},margin:{default:2}},{open:{type:Boolean},openModifiers:{}}),emits:H(["click"],["update:open"]),setup(e,{emit:t}){const a=ne(e,"open"),s=e,n=t,l=o(()=>{if(!s.avatarImage)return!1;try{return!!new URL(s.avatarImage)}catch{return!1}}),m=o(()=>!!s.avatarImage),v=o(()=>({marginInlineStart:`${s.margin}px`})),u=o(()=>{if(!s.url||s.url.trim()==="")return!1;try{return!!new URL(s.url,s.url?.startsWith?.("/")?window.location.href:void 0)}catch{return re("[NcUserBubble] Invalid URL passed",{url:s.url}),!1}}),d=o(()=>u.value?s.url:void 0),p=o(()=>u.value?"a":s.to?Le:"div"),c=o(()=>({height:`${s.size}px`,lineHeight:`${s.size}px`,borderRadius:`${s.size/2}px`}));return ie([()=>s.displayName,()=>s.user],()=>{!s.displayName&&s.user}),(i,f)=>(h(),N(S(i.$slots.default?ye:Re),{shown:a.value,"onUpdate:shown":f[1]||(f[1]=g=>a.value=g),class:"user-bubble__wrapper",trigger:"hover focus"},{trigger:w(({attrs:g})=>[(h(),N(S(p.value),le({class:["user-bubble__content",{"user-bubble__content--primary":i.primary}],style:c.value,to:i.to,href:d.value},g,{onClick:f[0]||(f[0]=q=>n("click",q))}),{default:w(()=>[oe(ge,{url:m.value&&l.value?i.avatarImage:void 0,"icon-class":m.value&&!l.value?i.avatarImage:void 0,user:i.user,"display-name":i.displayName,size:i.size-i.margin*2,style:ce(v.value),"disable-tooltip":!0,"disable-menu":!0,"hide-status":!i.showUserStatus,class:"user-bubble__avatar"},null,8,["url","icon-class","user","display-name","size","style","hide-status"]),ue("span",Oe,fe(i.displayName||i.user),1),i.$slots.name?(h(),M("span",Fe,[C(i.$slots,"name",{},void 0,!0)])):de("",!0)]),_:2},1040,["class","style","to","href"]))]),default:w(()=>[C(i.$slots,"default",{},void 0,!0)]),_:3},40,["shown"]))}}),Pe=D(Ke,[["__scopeId","data-v-ad356e41"]]),je='<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>',qe='<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>',P=`/trashbin/${b()?.uid}/trash`,Ye=Ae(),Ge=`<?xml version="1.0"?>
|
|
<d:propfind ${Ce()}>
|
|
<d:prop>
|
|
<nc:trashbin-deletion-time />
|
|
<nc:trashbin-original-location />
|
|
<nc:trashbin-title />
|
|
<nc:trashbin-deleted-by-id />
|
|
<nc:trashbin-deleted-by-display-name />
|
|
${Ve()}
|
|
</d:prop>
|
|
</d:propfind>`;function We(e){const t=Ie(e,P);return t.attributes.previewUrl=me("/apps/files_trashbin/preview?fileId={fileid}&x=32&y=32",{fileid:t.fileid}),t}async function Xe(e="/"){const t=(await Ye.getDirectoryContents(`${P}${e}`,{details:!0,data:Ge,includeSelf:!0})).data.map(We),[a]=t.splice(t.findIndex(s=>s.path===e),1);return{folder:a,contents:t}}const Ze=new I({id:"files_trashbin--original-location",title:r("files_trashbin","Original location"),render(e){const t=_(e),a=document.createElement("span");return a.title=t,a.textContent=t,a},sort(e,t){const a=_(e),s=_(t);return a.localeCompare(s,[z(),k()],{numeric:!0,usage:"sort"})}}),Je=new I({id:"files_trashbin--deleted-by",title:r("files_trashbin","Deleted by"),render(e){const{userId:t,displayName:a,label:s}=x(e);if(s){const l=document.createElement("span");return l.textContent=s,l}const n=document.createElement("div");return pe(Pe,{size:32,user:t??void 0,displayName:a??t}).mount(n),n},sort(e,t){const a=x(e),s=a.label??a.displayName??a.userId,n=x(t),l=n.label??n.displayName??n.userId;return s.localeCompare(l,[z(),k()],{numeric:!0,usage:"sort"})}}),Qe=new I({id:"files_trashbin--deleted",title:r("files_trashbin","Deleted"),render(e){const t=e.attributes?.["trashbin-deletion-time"]||(e?.mtime?.getTime()??0)/1e3,a=document.createElement("span");if(t){const s=Intl.DateTimeFormat([k()],{dateStyle:"long",timeStyle:"short"}),n=new Date(t*1e3);return a.title=s.format(n),a.textContent=we(n,{ignoreSeconds:r("files","few seconds ago")}),a}return a.textContent=r("files_trashbin","A long time ago"),a},sort(e,t){const a=e.attributes?.["trashbin-deletion-time"]||(e?.mtime?.getTime()??0)/1e3;return(t.attributes?.["trashbin-deletion-time"]||(t?.mtime?.getTime()??0)/1e3)-a}});function _(e){const t=V(e.attributes?.["trashbin-original-location"]);if(!t)return r("files_trashbin","Unknown");const a=Y(t);return a===t?r("files_trashbin","All files"):a.replace(/^\//,"")}function x(e){const t=V(e.attributes?.["trashbin-deleted-by-id"]),a=V(e.attributes?.["trashbin-deleted-by-display-name"]);let s;const n=b()?.uid;return t===n&&(s=r("files_trashbin","You")),!t&&!a&&(s=r("files_trashbin","Unknown")),{userId:t,displayName:a,label:s}}function V(e){return e?String(e):null}const $="trashbin",et=new G({id:$,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:qe,order:50,sticky:!0,defaultSortKey:"deleted",columns:[Ze,Je,Qe],getContents:Xe}),j=Ee().setApp("files_trashbin").detectUser().build(),tt=new W({id:"restore",displayName(){return r("files_trashbin","Restore")},iconSvgInline:()=>je,enabled({nodes:e,view:t}){return t.id!==$?!1:e.length>0&&e.map(a=>a.permissions).every(a=>!!(a&Z.READ))},async exec({nodes:e}){const t=e[0];try{const a=he(X(`dav/trashbin/${b().uid}/restore/${t.basename}`));return await R.request({method:"MOVE",url:t.encodedSource,headers:{destination:a}}),O("files:node:deleted",t),!0}catch(a){return be(a)&&a.response?.status===507&&F(r("files_trashbin","Not enough free space to restore the file/folder")),j.error("Failed to restore node",{error:a,node:t}),!1}},async execBatch({nodes:e,view:t,folder:a,contents:s}){return Promise.all(e.map(n=>this.exec({nodes:[n],view:t,folder:a,contents:s})))},order:1,inline:()=>!0});async function at(){try{return await R.delete(`${ke}/trashbin/${b().uid}/trash`),_e(r("files_trashbin","All files have been permanently deleted")),!0}catch(e){return F(r("files_trashbin","Failed to empty deleted files")),j.error("Failed to empty deleted files",{error:e}),!1}}const st=new J({id:"empty-trash",displayName:()=>r("files_trashbin","Empty deleted files"),order:0,enabled({view:e,folder:t,contents:a}){return e.id!==$||!ve("files_trashbin","config").allow_delete?!1:a.length>0&&t.path==="/"},async exec({contents:e}){return await new Promise(t=>{xe(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:()=>t(!1)},{label:r("files_trashbin","Empty deleted files"),variant:"error",callback:()=>t(!0)}]).build().show().then(()=>{t(!1)})})===!0&&await at()&&e.forEach(t=>O("files:node:deleted",t)),null}}),nt=Q();nt.register(et),ee(st),te(tt);
|
|
//# sourceMappingURL=files_trashbin-init.mjs.map
|