nextcloud/dist/files-sidebar.js
nextcloud-command 7eda9ce7dd
chore(assets): Recompile assets
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
2026-02-12 09:54:00 +01:00

2 lines
No EOL
14 KiB
JavaScript

(()=>{var e,t={17445(e,t,i){"use strict";var o=i(10810),n=i(61338),r=i(70970),d=i(380),s=i(20005);function a(e,t,i){if(void 0!==e[t])if("array"===i){if(!Array.isArray(e[t]))throw new Error(`View ${t} must be an array`)}else{if(typeof e[t]!==i)throw new Error(`View ${t} must be a ${i}`);if("object"===i&&(null===e[t]||Array.isArray(e[t])))throw new Error(`View ${t} must be an object`)}}function l(e){if("object"!=typeof e||null===e)throw new Error("View column must be an object");if(!e.id||"string"!=typeof e.id)throw new Error("A column id is required");if(!e.title||"string"!=typeof e.title)throw new Error("A column title is required");if(!e.render||"function"!=typeof e.render)throw new Error("A render function is required");a(e,"sort","function"),a(e,"summary","function")}function c(e){if(!e.icon||"string"!=typeof e.icon||!(0,s.A)(e.icon))throw new Error("View icon is required and must be a valid svg string");if(!e.id||"string"!=typeof e.id)throw new Error("View id is required and must be a string");if(!e.getContents||"function"!=typeof e.getContents)throw new Error("View getContents is required and must be a function");if(!e.name||"string"!=typeof e.name)throw new Error("View name is required and must be a string");if(a(e,"caption","string"),a(e,"columns","array"),a(e,"defaultSortKey","string"),a(e,"emptyCaption","string"),a(e,"emptyTitle","string"),a(e,"emptyView","function"),a(e,"expanded","boolean"),a(e,"hidden","boolean"),a(e,"loadChildViews","function"),a(e,"order","number"),a(e,"params","object"),a(e,"parent","string"),a(e,"sticky","boolean"),e.columns&&(e.columns.forEach(l),e.columns.reduce((e,t)=>e.add(t.id),new Set).size!==e.columns.length))throw new Error("View columns must have unique ids")}i(53334),Object.freeze({DEFAULT:"default",HIDDEN:"hidden"}),d.m;class u extends d.m{_views=[];_currentView=null;register(...e){for(const t of e){if(this._views.find(e=>e.id===t.id))throw new Error(`IView id ${t.id} is already registered`);c(t)}this._views.push(...e),this.dispatchTypedEvent("update",new CustomEvent("update"))}remove(e){const t=this._views.findIndex(t=>t.id===e);-1!==t&&(this._views.splice(t,1),this.dispatchTypedEvent("update",new CustomEvent("update")))}setActive(e){if(null===e)this._currentView=null;else{const t=this._views.find(({id:t})=>t===e);if(!t)throw new Error(`No view with ${e} registered`);this._currentView=t}const t=new CustomEvent("updateActive",{detail:this._currentView});this.dispatchTypedEvent("updateActive",t)}get active(){return this._currentView}get views(){return this._views}}function f(){return r.s.navigation??=new u,r.s.navigation}Object.freeze({UploadFromDevice:0,CreateNew:1,Other:2}),Object.freeze({ReservedName:"reserved name",Character:"character",Extension:"extension"}),Error,Object.freeze({Name:"basename",Modified:"mtime",Size:"size"});var p=i(85471);const v=(0,i(35947).YK)().setApp("files").detectUser().build();var h=i(21777),w=i(63814),m=i(32505),g=i(44719);const b=["d:getcontentlength","d:getcontenttype","d:getetag","d:getlastmodified","d:creationdate","d:displayname","d:quota-available-bytes","d:resourcetype","nc:has-preview","nc:is-encrypted","nc:mount-type","oc:comments-unread","oc:favorite","oc:fileid","oc:owner-display-name","oc:owner-id","oc:permissions","oc:size"],y={d:"DAV:",nc:"http://nextcloud.org/ns",oc:"http://owncloud.org/ns",ocs:"http://open-collaboration-services.org/ns"};function N(){return(0,m.f)()?`/files/${(0,m.G)()}`:`/files/${(0,h.HW)()?.uid}`}const E=N();function P(){const e=(0,w.dC)("dav");return(0,m.f)()?e.replace("remote.php","public.php"):e}const _=P();const A=new r.b({id:0,source:P()+N(),root:N(),owner:(0,h.HW)()?.uid||null,permissions:r.P.NONE}),C=(0,o.nY)("active",()=>{const e=(0,p.IJ)(),t=(0,p.KR)(),i=(0,p.IJ)(),o=(0,p.KR)(A);function r(e){t.value&&t.value.source===e.source&&(t.value=void 0)}function d(e=null){v.debug("Setting active view",{view:e}),i.value=e??void 0,t.value=void 0}return(0,p.wB)(t,()=>{"number"==typeof t.value?.fileid&&t.value.fileid!==o.value?.fileid&&(v.debug("Updating active fileid in URL query",{fileid:t.value.fileid}),window.OCP.Files.Router.goToRoute(null,{...window.OCP.Files.Router.params,fileid:String(t.value.fileid)},{...window.OCP.Files.Router.query},!0))}),function(){const e=f();d(e.active),(0,n.B1)("files:node:deleted",r),e.addEventListener("updateActive",e=>{d(e.detail)})}(),{activeAction:e,activeFolder:o,activeNode:t,activeView:i}}),O=function(e=_,t={}){const i=(0,g.UU)(e,{headers:t});function o(e){i.setHeaders({...t,"X-Requested-With":"XMLHttpRequest",requesttoken:e??""})}return(0,h.zo)(o),o((0,h.do)()),(0,g.Gu)().patch("fetch",(e,t)=>{const i=t.headers;return i?.method&&(t.method=i.method,delete i.method),fetch(e,t)}),i}();async function F(e){const t=`<?xml version="1.0"?>\n\t\t<d:propfind ${r.s.davNamespaces??={...y},Object.keys(r.s.davNamespaces).map(e=>`xmlns:${e}="${r.s.davNamespaces?.[e]}"`).join(" ")}>\n\t\t\t<d:prop>\n\t\t\t\t${r.s.davProperties??=[...b],r.s.davProperties.map(e=>`<${e} />`).join(" ")}\n\t\t\t</d:prop>\n\t\t</d:propfind>`;return function(e,t=E,i=_){let o=(0,h.HW)()?.uid;if((0,m.f)())o=o??"anonymous";else if(!o)throw new Error("No user id found");const n=e.props,d=function(e=""){let t=r.P.NONE;return e?(e.includes("G")&&(t|=r.P.READ),e.includes("W")&&(t|=r.P.WRITE),e.includes("CK")&&(t|=r.P.CREATE),e.includes("NV")&&(t|=r.P.UPDATE),e.includes("D")&&(t|=r.P.DELETE),e.includes("R")&&(t|=r.P.SHARE),t):t}(n?.permissions),s=String(n?.["owner-id"]||o),a=n.fileid||0,l=new Date(Date.parse(e.lastmod)),c=new Date(Date.parse(n.creationdate)),u={id:a,source:`${i}${e.filename}`,mtime:isNaN(l.getTime())||0===l.getTime()?void 0:l,crtime:isNaN(c.getTime())||0===c.getTime()?void 0:c,mime:e.mime||"application/octet-stream",displayname:void 0!==n.displayname?String(n.displayname):void 0,size:n?.size||Number.parseInt(n.getcontentlength||"0"),status:a<0?r.c.FAILED:void 0,permissions:d,owner:s,root:t,attributes:{...e,...n,hasPreview:n?.["has-preview"]}};return delete u.attributes?.props,"file"===e.type?new r.a(u):new r.b(u)}((await O.stat(`${N()}${e}`,{details:!0,data:t})).data)}var R=i(71225);function T(...e){const t=(0,o.nY)("files",{state:()=>({files:{},roots:{}}),getters:{getNode:e=>t=>e.files[t],getNodes:e=>t=>t.map(t=>e.files[t]).filter(Boolean),getNodesById:e=>t=>Object.values(e.files).filter(e=>e.fileid===t),getRoot:e=>t=>e.roots[t]},actions:{getDirectoryByPath(e,t){const i=function(...e){const t=T(...e),i=(0,o.nY)("paths",{state:()=>({paths:{}}),getters:{getPath:e=>(t,i)=>{if(e.paths[t])return e.paths[t][i]}},actions:{addPath(e){this.paths[e.service]||p.Ay.set(this.paths,e.service,{}),p.Ay.set(this.paths[e.service],e.path,e.source)},deletePath(e,t){this.paths[e]&&p.Ay.delete(this.paths[e],t)},onCreatedNode(e){const t=f()?.active?.id||"files";e.fileid?(e.type===r.F.Folder&&this.addPath({service:t,path:e.path,source:e.source}),this.addNodeToParentChildren(e)):v.error("Node has no fileid",{node:e})},onDeletedNode(e){const t=f()?.active?.id||"files";e.type===r.F.Folder&&this.deletePath(t,e.path),this.deleteNodeFromParentChildren(e)},onMovedNode({node:e,oldSource:t}){const i=f()?.active?.id||"files";if(e.type===r.F.Folder){const o=Object.entries(this.paths[i]).find(([,e])=>e===t);o?.[0]&&this.deletePath(i,o[0]),this.addPath({service:i,path:e.path,source:e.source})}const o=new r.a({source:t,owner:e.owner,mime:e.mime,root:e.root});this.deleteNodeFromParentChildren(o),this.addNodeToParentChildren(e)},deleteNodeFromParentChildren(e){const i=f()?.active?.id||"files",o=(0,R.pD)(e.source),n="/"===e.dirname?t.getRoot(i):t.getNode(o);if(n){const t=new Set(n._children??[]);return t.delete(e.source),p.Ay.set(n,"_children",[...t.values()]),void v.debug("Children updated",{parent:n,node:e,children:n._children})}v.debug("Parent path does not exists, skipping children update",{node:e})},addNodeToParentChildren(e){const i=f()?.active?.id||"files",o=(0,R.pD)(e.source),n="/"===e.dirname?t.getRoot(i):t.getNode(o);if(n){const t=new Set(n._children??[]);return t.add(e.source),p.Ay.set(n,"_children",[...t.values()]),void v.debug("Children updated",{parent:n,node:e,children:n._children})}v.debug("Parent path does not exists, skipping children update",{node:e})}}})(...e);return i._initialized||((0,n.B1)("files:node:created",i.onCreatedNode),(0,n.B1)("files:node:deleted",i.onDeletedNode),(0,n.B1)("files:node:moved",i.onMovedNode),i._initialized=!0),i}();let d;if(t&&"/"!==t){const o=i.getPath(e,t);o&&(d=this.getNode(o))}else d=this.getRoot(e);return d},getNodesByPath(e,t){const i=this.getDirectoryByPath(e,t);return(i?._children??[]).map(e=>this.getNode(e)).filter(Boolean)},updateNodes(e){const t=e.reduce((e,t)=>t.fileid?(e[t.source]=t,e):(v.error("Trying to update/set a node without fileid",{node:t}),e),{});p.Ay.set(this,"files",{...this.files,...t})},deleteNodes(e){e.forEach(e=>{e.source&&p.Ay.delete(this.files,e.source)})},setRoot({service:e,root:t}){p.Ay.set(this.roots,e,t)},onDeletedNode(e){this.deleteNodes([e])},onCreatedNode(e){this.updateNodes([e])},onMovedNode({node:e,oldSource:t}){e.fileid?(p.Ay.delete(this.files,t),this.updateNodes([e])):v.error("Trying to update/set a node without fileid",{node:e})},async onUpdatedNode(e){if(!e.fileid)return void v.error("Trying to update/set a node without fileid",{node:e});const t=this.getNodesById(e.fileid);if(t.length>1)return await Promise.all(t.map(e=>F(e.path))).then(this.updateNodes),void v.debug(t.length+" nodes updated in store",{fileid:e.fileid});1!==t.length||e.source!==t[0].source?F(e.path).then(e=>this.updateNodes([e])):this.updateNodes([e])},onAddFavorite(e){const t=this.getNode(e.source);t&&p.Ay.set(t.attributes,"favorite",1)},onRemoveFavorite(e){const t=this.getNode(e.source);t&&p.Ay.set(t.attributes,"favorite",0)}}}),i=t(...e);return i._initialized||((0,n.B1)("files:node:created",i.onCreatedNode),(0,n.B1)("files:node:deleted",i.onDeletedNode),(0,n.B1)("files:node:updated",i.onUpdatedNode),(0,n.B1)("files:node:moved",i.onMovedNode),(0,n.B1)("files:favorites:added",i.onAddFavorite),(0,n.B1)("files:favorites:removed",i.onRemoveFavorite),i._initialized=!0),i}const V=(0,o.nY)("sidebar",()=>{const e=(0,p.KR)(),t=(0,p.KR)(!1),i=C(),o=(0,p.EW)(()=>t.value?i.activeNode:void 0),d=(0,p.EW)(()=>!!(o.value&&i.activeFolder&&i.activeView)),s=(0,p.EW)(()=>{if(d.value)return{node:o.value,folder:i.activeFolder,view:i.activeView}}),a=(0,p.EW)(()=>s.value?h(s.value):[]),l=(0,p.EW)(()=>s.value?f(s.value):[]);function c(n,r){if(!(n&&i.activeFolder&&i.activeView))throw v.debug("sidebar: cannot open sidebar because the active folder or view is not set.",{node:n,activeFolder:i.activeFolder,activeView:i.activeView}),new Error("Cannot open sidebar because the active folder or view is not set.");if(t.value&&o.value?.source===n.source)return v.debug("sidebar: already open for current node"),void(r&&(v.debug("sidebar: already open for current node - switching tab",{tabId:r}),w(r)));const d=f({node:n,folder:i.activeFolder,view:i.activeView});r&&!d.find(({id:e})=>e===r)?(v.warn(`sidebar: cannot open tab '${r}' because it is not available for the current context.`),e.value=d[0]?.id):e.value=r??d[0]?.id,v.debug(`sidebar: opening for ${n.displayname}`,{node:n}),i.activeNode=n,t.value=!0}function u(){t.value=!1}function f(e){let t=r.s.filesSidebarTabs?[...r.s.filesSidebarTabs.values()]:[];return e&&(t=t.filter(t=>void 0===t.enabled||t.enabled(e))),t.sort((e,t)=>e.order-t.order)}function h(e){let t=r.s.filesSidebarActions?[...r.s.filesSidebarActions.values()]:[];return e&&(t=t.filter(t=>void 0===t.enabled||t.enabled(e))),t.sort((e,t)=>e.order-t.order)}function w(t){if(!l.value.find(({id:e})=>e===t))throw new Error(`Cannot set sidebar tab '${t}' because it is not available for the current context.`);e.value=t}(0,n.B1)("files:node:updated",e=>{e.source===o.value?.source&&(i.activeNode=e)}),(0,n.B1)("files:node:deleted",e=>{e.fileid===o.value?.fileid&&u()}),(0,n.B1)("viewer:sidebar:open",({source:e})=>{const t=T().getNode(e);t?(v.debug("sidebar: opening for node from Viewer.",{node:t}),c(t)):v.error(`sidebar: cannot open for node '${e}' because it was not found in the current view.`)});let m=!1;return(0,n.B1)("files:list:updated",()=>{m||(m=!0,window.OCP.Files.Router._router.afterEach((e,t)=>{t.query&&"opendetails"in t.query&&e.query&&!("opendetails"in e.query)&&(v.debug('sidebar: closing because "opendetails" query parameter was removed from URL.'),u())}))}),(0,p.wB)(t,e=>{const t={...window.OCP?.Files?.Router?.params??{}},o={...window.OCP?.Files?.Router?.query??{}};v.debug("sidebar: current node changed: "+(e?"open":"closed"),{query:o,params:t,node:i.activeNode}),!e&&"opendetails"in o&&(delete o.opendetails,window.OCP.Files.Router.goToRoute(null,t,o,!0)),e&&!("opendetails"in o)&&window.OCP.Files.Router.goToRoute(null,t,{...o,opendetails:"true"},!0)}),{activeTab:e,currentActions:a,currentContext:s,currentNode:o,currentTabs:l,hasContext:d,isOpen:(0,p.tB)(t),open:c,close:u,getActions:h,getTabs:f,setActiveTab:w}});window.OCA.Files??={},window.OCA.Files._sidebar=()=>V((window._nc_files_pinia||(window._nc_files_pinia=(0,o.Ey)()),window._nc_files_pinia))},63779(){},77199(){}},i={};function o(e){var n=i[e];if(void 0!==n)return n.exports;var r=i[e]={id:e,loaded:!1,exports:{}};return t[e].call(r.exports,r,r.exports,o),r.loaded=!0,r.exports}o.m=t,e=[],o.O=(t,i,n,r)=>{if(!i){var d=1/0;for(c=0;c<e.length;c++){for(var[i,n,r]=e[c],s=!0,a=0;a<i.length;a++)(!1&r||d>=r)&&Object.keys(o.O).every(e=>o.O[e](i[a]))?i.splice(a--,1):(s=!1,r<d&&(d=r));if(s){e.splice(c--,1);var l=n();void 0!==l&&(t=l)}}return t}r=r||0;for(var c=e.length;c>0&&e[c-1][2]>r;c--)e[c]=e[c-1];e[c]=[i,n,r]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.e=()=>Promise.resolve(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),o.j=4763,(()=>{o.b="undefined"!=typeof document&&document.baseURI||self.location.href;var e={4763:0};o.O.j=t=>0===e[t];var t=(t,i)=>{var n,r,[d,s,a]=i,l=0;if(d.some(t=>0!==e[t])){for(n in s)o.o(s,n)&&(o.m[n]=s[n]);if(a)var c=a(o)}for(t&&t(i);l<d.length;l++)r=d[l],o.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return o.O(c)},i=globalThis.webpackChunknextcloud_ui_legacy=globalThis.webpackChunknextcloud_ui_legacy||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})(),o.nc=void 0;var n=o.O(void 0,[4208],()=>o(17445));n=o.O(n)})();
//# sourceMappingURL=files-sidebar.js.map?v=f4d152af2b1f095e1a8c