12 |
- /*! third party licenses: dist/vendor.LICENSE.txt */
- import{k as H,P as C,p as G,n as U,V as g,F as y,r as b,D as q,j as S}from"./chunks/index-DG15V7L3.mjs";import{bW as _,c1 as k,b$ as u,bR as p,bS as a,c5 as T,bQ as N,bZ as z}from"./core-common.mjs";import{aq as E,ar as K,as as D,at as F,ab as Z,au as Q,av as W,aw as J,ax as X}from"./chunks/icons-TElqpmA8.mjs";import{_ as $}from"./chunks/preload-helper-BG02UnR2.mjs";import{g as ee}from"./chunks/index-CiG5J8j_.mjs";import{T as w}from"./chunks/index-YIotKjSS.mjs";import{a as se}from"./chunks/sidebarAction-DYCQBJiz.mjs";import"./chunks/index-PaKKd09k.mjs";import"./chunks/index-CPb3EwrS.mjs";import"./chunks/index-tn-fAC9x.mjs";import"./chunks/logger-R_K4lHwR.mjs";const ie=ee().setApp("files_sharing").detectUser().build();var x;const R="/files/".concat((x=_())==null?void 0:x.uid),A={"Content-Type":"application/json"},te=async function(e){var s;try{if((e==null?void 0:e.remote_id)!==void 0){const h=(await $(async()=>{const{default:c}=await import("./chunks/index-Ch_r7sDk.mjs");return{default:c}},[],import.meta.url)).default;e.mimetype=h.getType(e.name),e.item_type=e.mimetype?"file":"folder",e.item_permissions=C.NONE,e.permissions=C.NONE,e.uid_owner=e.owner,e.displayname_owner=e.owner}const i=(e==null?void 0:e.item_type)==="folder",r=(e==null?void 0:e.has_preview)===!0,n=i?H:G,o=e.file_source||e.id,t=(e==null?void 0:e.path)||e.file_target||e.name,d=k("dav/".concat(R,"/").concat(t).replaceAll(/\/\//gm,"/"));let l=e!=null&&e.item_mtime?new Date(e.item_mtime*1e3):void 0;return(e==null?void 0:e.stime)>((e==null?void 0:e.item_mtime)||0)&&(l=new Date(e.stime*1e3)),new n({id:o,source:d,owner:e==null?void 0:e.uid_owner,mime:(e==null?void 0:e.mimetype)||"application/octet-stream",mtime:l,size:e==null?void 0:e.item_size,permissions:(e==null?void 0:e.item_permissions)||(e==null?void 0:e.permissions),root:R,attributes:{...e,"has-preview":r,"owner-id":e==null?void 0:e.uid_owner,"owner-display-name":e==null?void 0:e.displayname_owner,"share-types":e==null?void 0:e.share_type,favorite:(s=e==null?void 0:e.tags)!=null&&s.includes(window.OC.TAG_FAVORITE)?1:0}})}catch(i){return ie.error("Error while parsing OCS entry",{error:i}),null}},L=function(e=!1){const s=u("apps/files_sharing/api/v1/shares");return p.get(s,{headers:A,params:{shared_with_me:e,include_tags:!0}})},re=function(){return L(!0)},ae=function(){return L()},ne=function(){const e=u("apps/files_sharing/api/v1/remote_shares");return p.get(e,{headers:A,params:{include_tags:!0}})},oe=function(){const e=u("apps/files_sharing/api/v1/shares/pending");return p.get(e,{headers:A,params:{include_tags:!0}})},le=function(){const e=u("apps/files_sharing/api/v1/remote_shares/pending");return p.get(e,{headers:A,params:{include_tags:!0}})},de=function(){const e=u("apps/files_sharing/api/v1/deletedshares");return p.get(e,{headers:A,params:{include_tags:!0}})},he=function(e,s){return Object.values(e.reduce(function(i,r){return(i[r[s]]=i[r[s]]||[]).push(r),i},{}))},f=async(e=!0,s=!0,i=!1,r=!1,n=[])=>{var o;const t=[];e&&t.push(re(),ne()),s&&t.push(ae()),i&&t.push(oe(),le()),r&&t.push(de());const d=(await Promise.all(t)).map(h=>h.data.ocs.data).flat();let l=(await Promise.all(d.map(te))).filter(h=>h!==null);return n.length>0&&(l=l.filter(h=>{var c;return n.includes((c=h.attributes)==null?void 0:c.share_type)})),l=he(l,"source").map(h=>{const c=h[0];return c.attributes["share-types"]=h.map(Y=>Y.attributes["share-types"]),c}),{folder:new H({id:0,source:k("dav"+R),owner:((o=_())==null?void 0:o.uid)||null}),contents:l}},m="shareoverview",M="sharingin",B="sharingout",V="sharinglinks",j="deletedshares",O="pendingshares",ue=()=>{const e=U();e.register(new g({id:m,name:a("files_sharing","Shares"),caption:a("files_sharing","Overview of shared files."),emptyTitle:a("files_sharing","No shares"),emptyCaption:a("files_sharing","Files and folders you shared or have been shared with you will show up here"),icon:E,order:20,columns:[],getContents:()=>f()})),e.register(new g({id:M,name:a("files_sharing","Shared with you"),caption:a("files_sharing","List of files that are shared with you."),emptyTitle:a("files_sharing","Nothing shared with you yet"),emptyCaption:a("files_sharing","Files and folders others shared with you will show up here"),icon:K,order:1,parent:m,columns:[],getContents:()=>f(!0,!1,!1,!1)})),e.register(new g({id:B,name:a("files_sharing","Shared with others"),caption:a("files_sharing","List of files that you shared with others."),emptyTitle:a("files_sharing","Nothing shared yet"),emptyCaption:a("files_sharing","Files and folders you shared will show up here"),icon:D,order:2,parent:m,columns:[],getContents:()=>f(!1,!0,!1,!1)})),e.register(new g({id:V,name:a("files_sharing","Shared by link"),caption:a("files_sharing","List of files that are shared by link."),emptyTitle:a("files_sharing","No shared links"),emptyCaption:a("files_sharing","Files and folders you shared by link will show up here"),icon:F,order:3,parent:m,columns:[],getContents:()=>f(!1,!0,!1,!1,[window.OC.Share.SHARE_TYPE_LINK])})),e.register(new g({id:j,name:a("files_sharing","Deleted shares"),caption:a("files_sharing","List of shares you left."),emptyTitle:a("files_sharing","No deleted shares"),emptyCaption:a("files_sharing","Shares you have left will show up here"),icon:Z,order:4,parent:m,columns:[],getContents:()=>f(!1,!1,!1,!0)})),e.register(new g({id:O,name:a("files_sharing","Pending shares"),caption:a("files_sharing","List of unapproved shares."),emptyTitle:a("files_sharing","No pending shares"),emptyCaption:a("files_sharing","Shares you have received but not approved will show up here"),icon:Q,order:5,parent:m,columns:[],getContents:()=>f(!1,!1,!0,!1)}))},pe=new y({id:"accept-share",displayName:e=>T("files_sharing","Accept share","Accept shares",e.length),iconSvgInline:()=>W,enabled:(e,s)=>e.length>0&&s.id===O,async exec(e){try{const s=!!e.attributes.remote,i=u("apps/files_sharing/api/v1/{shareBase}/pending/{id}",{shareBase:s?"remote_shares":"shares",id:e.attributes.id});return await p.post(i),N("files:node:deleted",e),!0}catch{return!1}},async execBatch(e,s,i){return Promise.all(e.map(r=>this.exec(r,s,i)))},order:1,inline:()=>!0});b(pe);const ce=new y({id:"open-in-files",displayName:()=>a("files","Open in Files"),iconSvgInline:()=>"",enabled:(e,s)=>[m,M,B,V].includes(s.id),async exec(e){return window.OCP.Files.Router.goToRoute(null,{view:"files",fileid:e.fileid},{dir:e.dirname,openfile:"true"}),null},order:-1e3,default:q.HIDDEN});b(ce);const me=new y({id:"reject-share",displayName:e=>T("files_sharing","Reject share","Reject shares",e.length),iconSvgInline:()=>J,enabled:(e,s)=>!(s.id!==O||e.length===0||e.some(i=>i.attributes.remote_id&&i.attributes.share_type===window.OC.Share.SHARE_TYPE_REMOTE_GROUP)),async exec(e){try{const s=!!e.attributes.remote,i=u("apps/files_sharing/api/v1/{shareBase}/{id}",{shareBase:s?"remote_shares":"shares",id:e.attributes.id});return await p.delete(i),N("files:node:deleted",e),!0}catch{return!1}},async execBatch(e,s,i){return Promise.all(e.map(r=>this.exec(r,s,i)))},order:2,inline:()=>!0});b(me);const ge=new y({id:"restore-share",displayName:e=>T("files_sharing","Restore share","Restore shares",e.length),iconSvgInline:()=>X,enabled:(e,s)=>e.length>0&&s.id===j,async exec(e){try{const s=u("apps/files_sharing/api/v1/deletedshares/{id}",{id:e.attributes.id});return await p.post(s),N("files:node:deleted",e),!0}catch{return!1}},async execBatch(e,s,i){return Promise.all(e.map(r=>this.exec(r,s,i)))},order:1,inline:()=>!0});b(ge);const fe='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12,5.5A3.5,3.5 0 0,1 15.5,9A3.5,3.5 0 0,1 12,12.5A3.5,3.5 0 0,1 8.5,9A3.5,3.5 0 0,1 12,5.5M5,8C5.56,8 6.08,8.15 6.53,8.42C6.38,9.85 6.8,11.27 7.66,12.38C7.16,13.34 6.16,14 5,14A3,3 0 0,1 2,11A3,3 0 0,1 5,8M19,8A3,3 0 0,1 22,11A3,3 0 0,1 19,14C17.84,14 16.84,13.34 16.34,12.38C17.2,11.27 17.62,9.85 17.47,8.42C17.92,8.15 18.44,8 19,8M5.5,18.25C5.5,16.18 8.41,14.5 12,14.5C15.59,14.5 18.5,16.18 18.5,18.25V20H5.5V18.25M0,20V18.5C0,17.11 1.89,15.94 4.45,15.6C3.86,16.28 3.5,17.22 3.5,18.25V20H0M24,20H20.5V18.25C20.5,17.22 20.14,16.28 19.55,15.6C22.11,15.94 24,17.11 24,18.5V20Z" /></svg>';var P,I;const _e=((I=(P=window==null?void 0:window.matchMedia)==null?void 0:P.call(window,"(prefers-color-scheme: dark)"))==null?void 0:I.matches)===!0||document.querySelector("[data-themes*=dark]")!==null,we=(e,s=!1)=>{const i=_e?"/avatar/{userId}/32/dark":"/avatar/{userId}/32",r=z(s?i:i+"?guestFallback=true",{userId:e});return'<svg width="32" height="32" viewBox="0 0 32 32"\n xmlns="http://www.w3.org/2000/svg" class="sharing-status__avatar">\n <image href="'.concat(r,'" height="32" width="32" />\n </svg>')},v=e=>e.attributes.remote_id!==void 0,ve=new y({id:"sharing-status",displayName(e){var s,i,r;const n=e[0],o=Object.values(((s=n==null?void 0:n.attributes)==null?void 0:s["share-types"])||{}).flat(),t=(i=n==null?void 0:n.attributes)==null?void 0:i["owner-id"];return o.length>0||t!==((r=_())==null?void 0:r.uid)||v(n)?a("files_sharing","Shared"):""},title(e){var s,i,r,n,o;const t=e[0],d=(s=t==null?void 0:t.attributes)==null?void 0:s["owner-id"],l=(i=t==null?void 0:t.attributes)==null?void 0:i["owner-display-name"];return Array.isArray((r=t.attributes)==null?void 0:r["share-types"])&&((n=t.attributes)==null?void 0:n["share-types"].length)>1?a("files_sharing","Shared multiple times with different people"):d&&(d!==((o=_())==null?void 0:o.uid)||v(t))?a("files_sharing","Shared by {ownerDisplayName}",{ownerDisplayName:l}):a("files_sharing","Show sharing options")},iconSvgInline(e){var s,i,r,n,o;const t=e[0],d=Object.values(((s=t==null?void 0:t.attributes)==null?void 0:s["share-types"])||{}).flat();if(Array.isArray((i=t.attributes)==null?void 0:i["share-types"])&&((r=t.attributes)==null?void 0:r["share-types"].length)>1)return E;if(d.includes(w.SHARE_TYPE_LINK)||d.includes(w.SHARE_TYPE_EMAIL))return F;if(d.includes(w.SHARE_TYPE_GROUP)||d.includes(w.SHARE_TYPE_REMOTE_GROUP))return D;if(d.includes(w.SHARE_TYPE_CIRCLE))return fe;const l=(n=t==null?void 0:t.attributes)==null?void 0:n["owner-id"];return l&&(l!==((o=_())==null?void 0:o.uid)||v(t))?we(l,v(t)):E},enabled(e){var s,i,r;if(e.length!==1)return!1;const n=e[0],o=(s=n==null?void 0:n.attributes)==null?void 0:s["owner-id"];return Array.isArray((i=n.attributes)==null?void 0:i["share-types"])||o&&(o!==((r=_())==null?void 0:r.uid)||v(n))?!0:(n.permissions&C.SHARE)!==0},async exec(e,s,i){var r,n,o,t;return e.permissions&C.READ?((t=(o=(n=(r=window.OCA)==null?void 0:r.Files)==null?void 0:n.Sidebar)==null?void 0:o.setActiveTab)==null||t.call(o,"sharing"),se.exec(e,s,i)):null},inline:()=>!0});b(ve);ue(),S("nc:share-attributes",{nc:"http://nextcloud.org/ns"}),S("oc:share-types",{oc:"http://owncloud.org/ns"}),S("ocs:share-permissions",{ocs:"http://open-collaboration-services.org/ns"});
|