files_sharing-files_sharing.js 17 KB

123
  1. /*! For license information please see files_sharing-files_sharing.js.LICENSE.txt */
  2. (()=>{"use strict";var e,t={64123:(e,t,i)=>{var r,n,s,o=i(31352),a=i(77958),l=i(17499),d=i(62520);null===(r=(0,a.ts)())?(0,l.IY)().setApp("files").build():(0,l.IY)().setApp("files").setUid(r.uid).build(),function(e){e.Folder="folder",e.File="file"}(n||(n={})),function(e){e[e.NONE=0]="NONE",e[e.CREATE=4]="CREATE",e[e.READ=1]="READ",e[e.UPDATE=2]="UPDATE",e[e.DELETE=8]="DELETE",e[e.SHARE=16]="SHARE",e[e.ALL=31]="ALL"}(s||(s={}));const c=function(e,t){return null!==e.match(t)},u=(e,t)=>{if("id"in e&&("number"!=typeof e.id||e.id<0))throw new Error("Invalid id type of value");if(!e.source)throw new Error("Missing mandatory source");try{new URL(e.source)}catch(e){throw new Error("Invalid source format, source must be a valid URL")}if(!e.source.startsWith("http"))throw new Error("Invalid source format, only http(s) is supported");if("mtime"in e&&!(e.mtime instanceof Date))throw new Error("Invalid mtime type");if("crtime"in e&&!(e.crtime instanceof Date))throw new Error("Invalid crtime type");if(!e.mime||"string"!=typeof e.mime||!e.mime.match(/^[-\w.]+\/[-+\w.]+$/gi))throw new Error("Missing or invalid mandatory mime");if("size"in e&&"number"!=typeof e.size)throw new Error("Invalid size type");if("permissions"in e&&!("number"==typeof e.permissions&&e.permissions>=s.NONE&&e.permissions<=s.ALL))throw new Error("Invalid permissions");if("owner"in e&&null!==e.owner&&"string"!=typeof e.owner)throw new Error("Invalid owner type");if("attributes"in e&&"object"!=typeof e.attributes)throw new Error("Invalid attributes format");if("root"in e&&"string"!=typeof e.root)throw new Error("Invalid root format");if(e.root&&!e.root.startsWith("/"))throw new Error("Root must start with a leading slash");if(e.root&&!e.source.includes(e.root))throw new Error("Root must be part of the source");if(e.root&&c(e.source,t)){const i=e.source.match(t)[0];if(!e.source.includes((0,d.join)(i,e.root)))throw new Error("The root must be relative to the service. e.g /files/emma")}};class h{_data;_attributes;_knownDavService=/(remote|public)\.php\/(web)?dav/i;constructor(e,t){u(e,t||this._knownDavService),this._data=e;const i={set:(e,t,i)=>(this._data.mtime=new Date,Reflect.set(e,t,i)),deleteProperty:(e,t)=>(this._data.mtime=new Date,Reflect.deleteProperty(e,t))};this._attributes=new Proxy(e.attributes||{},i),delete this._data.attributes,t&&(this._knownDavService=t)}get source(){return this._data.source.replace(/\/$/i,"")}get basename(){return(0,d.basename)(this.source)}get extension(){return(0,d.extname)(this.source)}get dirname(){if(this.root){const e=this.source.indexOf(this.root);return(0,d.dirname)(this.source.slice(e+this.root.length)||"/")}const e=new URL(this.source);return(0,d.dirname)(e.pathname)}get mime(){return this._data.mime}get mtime(){return this._data.mtime}get crtime(){return this._data.crtime}get size(){return this._data.size}get attributes(){return this._attributes}get permissions(){return null!==this.owner||this.isDavRessource?void 0!==this._data.permissions?this._data.permissions:s.NONE:s.READ}get owner(){return this.isDavRessource?this._data.owner:null}get isDavRessource(){return c(this.source,this._knownDavService)}get root(){return this._data.root?this._data.root.replace(/^(.+)\/$/,"$1"):this.isDavRessource&&(0,d.dirname)(this.source).split(this._knownDavService).pop()||null}get path(){if(this.root){const e=this.source.indexOf(this.root);return this.source.slice(e+this.root.length)||"/"}return(this.dirname+"/"+this.basename).replace(/\/\//g,"/")}get fileid(){return this._data?.id||this.attributes?.fileid}move(e){u({...this._data,source:e},this._knownDavService),this._data.source=e,this._data.mtime=new Date}rename(e){if(e.includes("/"))throw new Error("Invalid basename");this.move((0,d.dirname)(this.source)+"/"+e)}}class f extends h{get type(){return n.File}}class p extends h{constructor(e){super({...e,mime:"httpd/unix-directory"})}get type(){return n.Folder}get extension(){return null}get mime(){return"httpd/unix-directory"}}var g=i(79753),m=i(26937);const v=(0,l.IY)().setApp("files_sharing").detectUser().build();var w;const _="/files/".concat(null===(w=(0,a.ts)())||void 0===w?void 0:w.uid),y={"Content-Type":"application/json"},b=function(e){try{var t;const i="folder"===(null==e?void 0:e.item_type),r=!0===(null==e?void 0:e.has_preview),n=i?p:f,s=e.file_source,o=r?(0,g.generateUrl)("/core/preview?fileId={fileid}&x=32&y=32&forceIcon=0",{fileid:s}):void 0,a=(null==e?void 0:e.path)||e.file_target,l=(0,g.generateRemoteUrl)("dav/".concat(_,"/").concat(a).replaceAll(/\/\//gm,"/"));let d=null!=e&&e.item_mtime?new Date(1e3*e.item_mtime):void 0;return(null==e?void 0:e.stime)>((null==e?void 0:e.item_mtime)||0)&&(d=new Date(1e3*e.stime)),new n({id:s,source:l,owner:null==e?void 0:e.uid_owner,mime:null==e?void 0:e.mimetype,mtime:d,size:null==e?void 0:e.item_size,permissions:(null==e?void 0:e.item_permissions)||(null==e?void 0:e.permissions),root:_,attributes:{...e,previewUrl:o,"has-preview":r,favorite:null!=e&&null!==(t=e.tags)&&void 0!==t&&t.includes(window.OC.TAG_FAVORITE)?1:0}})}catch(e){return v.error("Error while parsing OCS entry",{error:e}),null}},C=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/shares");return m.Z.get(t,{headers:y,params:{shared_with_me:e,include_tags:!0}})},E=async function(){var e;let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];const s=[];(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&s.push(C(!0),function(){const e=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/remote_shares");return m.Z.get(e,{headers:y,params:{include_tags:!0}})}()),t&&s.push(C()),i&&s.push(function(){const e=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/shares/pending");return m.Z.get(e,{headers:y,params:{include_tags:!0}})}(),function(){const e=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/remote_shares/pending");return m.Z.get(e,{headers:y,params:{include_tags:!0}})}()),r&&s.push(function(){const e=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/deletedshares");return m.Z.get(e,{headers:y,params:{include_tags:!0}})}());let o=(await Promise.all(s)).map((e=>e.data.ocs.data)).flat().map(b).filter((e=>null!==e));return n.length>0&&(o=o.filter((e=>{var t;return n.includes(null===(t=e.attributes)||void 0===t?void 0:t.share_type)}))),{folder:new p({id:0,source:(0,g.generateRemoteUrl)("dav"+_),owner:(null===(e=(0,a.ts)())||void 0===e?void 0:e.uid)||null}),contents:o}},I="shareoverview",x="sharingin",A="sharingout",L="sharinglinks",O="deletedshares",S="pendingshares";var H=i(69183);const R=(0,l.IY)().setApp("files").detectUser().build();var D;!function(e){e.DEFAULT="default",e.HIDDEN="hidden"}(D||(D={}));class M{constructor(e){var t,i,r;t=this,r=void 0,(i=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(i="_action"))in t?Object.defineProperty(t,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[i]=r,this.validateAction(e),this._action=e}get id(){return this._action.id}get displayName(){return this._action.displayName}get iconSvgInline(){return this._action.iconSvgInline}get enabled(){return this._action.enabled}get exec(){return this._action.exec}get execBatch(){return this._action.execBatch}get order(){return this._action.order}get default(){return this._action.default}get inline(){return this._action.inline}get renderInline(){return this._action.renderInline}validateAction(e){if(!e.id||"string"!=typeof e.id)throw new Error("Invalid id");if(!e.displayName||"function"!=typeof e.displayName)throw new Error("Invalid displayName function");if(!e.iconSvgInline||"function"!=typeof e.iconSvgInline)throw new Error("Invalid iconSvgInline function");if(!e.exec||"function"!=typeof e.exec)throw new Error("Invalid exec function");if("enabled"in e&&"function"!=typeof e.enabled)throw new Error("Invalid enabled function");if("execBatch"in e&&"function"!=typeof e.execBatch)throw new Error("Invalid execBatch function");if("order"in e&&"number"!=typeof e.order)throw new Error("Invalid order");if(e.default&&!Object.values(D).includes(e.default))throw new Error("Invalid default");if("inline"in e&&"function"!=typeof e.inline)throw new Error("Invalid inline function");if("renderInline"in e&&"function"!=typeof e.renderInline)throw new Error("Invalid renderInline function")}}const N=function(e){void 0===window._nc_fileactions&&(window._nc_fileactions=[],R.debug("FileActions initialized")),window._nc_fileactions.find((t=>t.id===e.id))?R.error("FileAction ".concat(e.id," already registered"),{action:e}):window._nc_fileactions.push(e)};N(new M({id:"accept-share",displayName:e=>(0,o.uN)("files_sharing","Accept share","Accept shares",e.length),iconSvgInline:()=>'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-check" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" /></svg>',enabled:(e,t)=>e.length>0&&t.id===S,async exec(e){try{const t=!!e.attributes.remote,i=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/{shareBase}/pending/{id}",{shareBase:t?"remote_shares":"shares",id:e.attributes.id});return await m.Z.post(i),(0,H.j8)("files:node:deleted",e),!0}catch(e){return!1}},async execBatch(e,t,i){return Promise.all(e.map((e=>this.exec(e,t,i))))},order:1,inline:()=>!0})),N(new M({id:"open-in-files",displayName:()=>(0,o.Iu)("files","Open in files"),iconSvgInline:()=>"",enabled:(e,t)=>[I,x,A,L].includes(t.id),exec:async e=>(window.OCP.Files.Router.goToRoute(null,{view:"files",fileid:e.fileid},{dir:e.dirname,fileid:e.fileid}),null),default:D.HIDDEN,order:-1e3})),N(new M({id:"reject-share",displayName:e=>(0,o.uN)("files_sharing","Reject share","Reject shares",e.length),iconSvgInline:()=>'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-close" viewBox="0 0 24 24"><path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" /></svg>',enabled:(e,t)=>t.id===S&&0!==e.length&&!e.some((e=>e.attributes.remote_id&&e.attributes.share_type===window.OC.Share.SHARE_TYPE_REMOTE_GROUP)),async exec(e){try{const t=!!e.attributes.remote,i=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/{shareBase}/{id}",{shareBase:t?"remote_shares":"shares",id:e.attributes.id});return await m.Z.delete(i),(0,H.j8)("files:node:deleted",e),!0}catch(e){return!1}},async execBatch(e,t,i){return Promise.all(e.map((e=>this.exec(e,t,i))))},order:2,inline:()=>!0})),N(new M({id:"restore-share",displayName:e=>(0,o.uN)("files_sharing","Restore share","Restore shares",e.length),iconSvgInline:()=>'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-arrow-u-left-top" viewBox="0 0 24 24"><path d="M20 13.5C20 17.09 17.09 20 13.5 20H6V18H13.5C16 18 18 16 18 13.5S16 9 13.5 9H7.83L10.91 12.09L9.5 13.5L4 8L9.5 2.5L10.92 3.91L7.83 7H13.5C17.09 7 20 9.91 20 13.5Z" /></svg>',enabled:(e,t)=>e.length>0&&t.id===O,async exec(e){try{const t=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/deletedshares/{id}",{id:e.attributes.id});return await m.Z.post(t),(0,H.j8)("files:node:deleted",e),!0}catch(e){return!1}},async execBatch(e,t,i){return Promise.all(e.map((e=>this.exec(e,t,i))))},order:1,inline:()=>!0})),(()=>{const e=window.OCP.Files.Navigation;e.register({id:I,name:(0,o.Iu)("files_sharing","Shares"),caption:(0,o.Iu)("files_sharing","Overview of shared files."),icon:'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-share-variant" viewBox="0 0 24 24"><path d="M18,16.08C17.24,16.08 16.56,16.38 16.04,16.85L8.91,12.7C8.96,12.47 9,12.24 9,12C9,11.76 8.96,11.53 8.91,11.3L15.96,7.19C16.5,7.69 17.21,8 18,8A3,3 0 0,0 21,5A3,3 0 0,0 18,2A3,3 0 0,0 15,5C15,5.24 15.04,5.47 15.09,5.7L8.04,9.81C7.5,9.31 6.79,9 6,9A3,3 0 0,0 3,12A3,3 0 0,0 6,15C6.79,15 7.5,14.69 8.04,14.19L15.16,18.34C15.11,18.55 15.08,18.77 15.08,19C15.08,20.61 16.39,21.91 18,21.91C19.61,21.91 20.92,20.61 20.92,19A2.92,2.92 0 0,0 18,16.08Z" /></svg>',order:20,columns:[],getContents:()=>E()}),e.register({id:x,name:(0,o.Iu)("files_sharing","Shared with you"),caption:(0,o.Iu)("files_sharing","List of files that are shared with you."),icon:'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-account" viewBox="0 0 24 24"><path d="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z" /></svg>',order:1,parent:I,columns:[],getContents:()=>E(!0,!1,!1,!1)}),e.register({id:A,name:(0,o.Iu)("files_sharing","Shared with others"),caption:(0,o.Iu)("files_sharing","List of files that you shared with others."),icon:'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-account-group" 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>',order:2,parent:I,columns:[],getContents:()=>E(!1,!0,!1,!1)}),e.register({id:L,name:(0,o.Iu)("files_sharing","Shared by link"),caption:(0,o.Iu)("files_sharing","List of files that are shared by link."),icon:'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-link" viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',order:3,parent:I,columns:[],getContents:()=>E(!1,!0,!1,!1,[window.OC.Share.SHARE_TYPE_LINK])}),e.register({id:O,name:(0,o.Iu)("files_sharing","Deleted shares"),caption:(0,o.Iu)("files_sharing","List of shares that you removed yourself from."),icon:'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-delete" viewBox="0 0 24 24"><path d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z" /></svg>',order:4,parent:I,columns:[],getContents:()=>E(!1,!1,!1,!0)}),e.register({id:S,name:(0,o.Iu)("files_sharing","Pending shares"),caption:(0,o.Iu)("files_sharing","List of unapproved shares."),icon:'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-account-clock" viewBox="0 0 24 24"><path d="M10.63,14.1C12.23,10.58 16.38,9.03 19.9,10.63C23.42,12.23 24.97,16.38 23.37,19.9C22.24,22.4 19.75,24 17,24C14.3,24 11.83,22.44 10.67,20H1V18C1.06,16.86 1.84,15.93 3.34,15.18C4.84,14.43 6.72,14.04 9,14C9.57,14 10.11,14.05 10.63,14.1V14.1M9,4C10.12,4.03 11.06,4.42 11.81,5.17C12.56,5.92 12.93,6.86 12.93,8C12.93,9.14 12.56,10.08 11.81,10.83C11.06,11.58 10.12,11.95 9,11.95C7.88,11.95 6.94,11.58 6.19,10.83C5.44,10.08 5.07,9.14 5.07,8C5.07,6.86 5.44,5.92 6.19,5.17C6.94,4.42 7.88,4.03 9,4M17,22A5,5 0 0,0 22,17A5,5 0 0,0 17,12A5,5 0 0,0 12,17A5,5 0 0,0 17,22M16,14H17.5V16.82L19.94,18.23L19.19,19.53L16,17.69V14Z" /></svg>',order:5,parent:I,columns:[],getContents:()=>E(!1,!1,!0,!1)})})()}},i={};function r(e){var n=i[e];if(void 0!==n)return n.exports;var s=i[e]={id:e,loaded:!1,exports:{}};return t[e].call(s.exports,s,s.exports,r),s.loaded=!0,s.exports}r.m=t,e=[],r.O=(t,i,n,s)=>{if(!i){var o=1/0;for(c=0;c<e.length;c++){i=e[c][0],n=e[c][1],s=e[c][2];for(var a=!0,l=0;l<i.length;l++)(!1&s||o>=s)&&Object.keys(r.O).every((e=>r.O[e](i[l])))?i.splice(l--,1):(a=!1,s<o&&(o=s));if(a){e.splice(c--,1);var d=n();void 0!==d&&(t=d)}}return t}s=s||0;for(var c=e.length;c>0&&e[c-1][2]>s;c--)e[c]=e[c-1];e[c]=[i,n,s]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),r.j=6691,(()=>{r.b=document.baseURI||self.location.href;var e={6691:0};r.O.j=t=>0===e[t];var t=(t,i)=>{var n,s,o=i[0],a=i[1],l=i[2],d=0;if(o.some((t=>0!==e[t]))){for(n in a)r.o(a,n)&&(r.m[n]=a[n]);if(l)var c=l(r)}for(t&&t(i);d<o.length;d++)s=o[d],r.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return r.O(c)},i=self.webpackChunknextcloud=self.webpackChunknextcloud||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})(),r.nc=void 0;var n=r.O(void 0,[7874],(()=>r(64123)));n=r.O(n)})();
  3. //# sourceMappingURL=files_sharing-files_sharing.js.map?v=a35ed0dcd9492bcd9f00