12 |
- /*! third party licenses: dist/vendor.LICENSE.txt */
- import{cc as g,bP as S}from"./core-common.mjs";import{T as f}from"./chunks/index-YIotKjSS.mjs";import"./files_sharing-collaboration.mjs";(function(){_.extend(OC.Files.Client,{PROPERTY_SHARE_TYPES:"{"+OC.Files.Client.NS_OWNCLOUD+"}share-types",PROPERTY_OWNER_ID:"{"+OC.Files.Client.NS_OWNCLOUD+"}owner-id",PROPERTY_OWNER_DISPLAY_NAME:"{"+OC.Files.Client.NS_OWNCLOUD+"}owner-display-name"}),OCA.Sharing||(OCA.Sharing={}),OCA.Sharing.Util={_REMOTE_OWNER_REGEXP:new RegExp("^(([^@]*)@(([^@^/\\s]*)@)?)((https://)?[^[\\s/]*)([/](.*))?$"),attach:function(e){var u;if((u=g().files_sharing)!=null&&u.api_enabled&&!(e.id==="trashbin"||e.id==="files.public")){var n=e.fileActions,o=e._createRow;e._createRow=function(a){var r=o.apply(this,arguments),i=OCA.Sharing.Util.getSharePermissions(a);return a.permissions===0&&(delete n.actions.all.Comment,delete n.actions.all.Details,delete n.actions.all.Goto),_.isFunction(a.canDownload)&&!a.canDownload()&&(delete n.actions.all.Download,a.permissions&OC.PERMISSION_UPDATE||delete n.actions.all.MoveCopy),r.attr("data-share-permissions",i),r.attr("data-share-attributes",JSON.stringify(a.shareAttributes)),a.shareOwner&&(r.attr("data-share-owner",a.shareOwner),r.attr("data-share-owner-id",a.shareOwnerId),a.mountType==="shared-root"&&r.attr("data-permissions",a.permissions|OC.PERMISSION_UPDATE)),a.recipientData&&!_.isEmpty(a.recipientData)&&r.attr("data-share-recipient-data",JSON.stringify(a.recipientData)),a.shareTypes&&r.attr("data-share-types",a.shareTypes.join(",")),r};var l=e.elementToFile;e.elementToFile=function(a){var r=l.apply(this,arguments);if(r.shareAttributes=JSON.parse(a.attr("data-share-attributes")||"[]"),r.sharePermissions=a.attr("data-share-permissions")||void 0,r.shareOwner=a.attr("data-share-owner")||void 0,r.shareOwnerId=a.attr("data-share-owner-id")||void 0,a.attr("data-share-types")&&(r.shareTypes=a.attr("data-share-types").split(",")),a.attr("data-expiration")){var i=parseInt(a.attr("data-expiration"));r.shares=[],r.shares.push({expiration:i})}return r};var h=e._getWebdavProperties;e._getWebdavProperties=function(){var a=h.apply(this,arguments);return a.push(OC.Files.Client.PROPERTY_OWNER_ID),a.push(OC.Files.Client.PROPERTY_OWNER_DISPLAY_NAME),a.push(OC.Files.Client.PROPERTY_SHARE_TYPES),a},e.filesClient.addFileInfoParser(function(a){var r={},i=a.propStat[0].properties,p=i[OC.Files.Client.PROPERTY_PERMISSIONS];p&&p.indexOf("S")>=0&&(r.shareOwner=i[OC.Files.Client.PROPERTY_OWNER_DISPLAY_NAME],r.shareOwnerId=i[OC.Files.Client.PROPERTY_OWNER_ID]);var d=i[OC.Files.Client.PROPERTY_SHARE_TYPES];return d&&(r.shareTypes=_.chain(d).filter(function(s){return s.namespaceURI===OC.Files.Client.NS_OWNCLOUD&&s.nodeName.split(":")[1]==="share-type"}).map(function(s){return parseInt(s.textContent||s.text,10)}).value()),r}),e.$el.on("fileActionsReady",function(a){var r=a.$files;_.each(r,function(i){var p=$(i),d=p.attr("data-share-types")||"",s=p.attr("data-share-owner");if(d||s){var m=!1,C=!1;_.each(d.split(",")||[],function(E){let O=parseInt(E,10);O===f.SHARE_TYPE_LINK||O===f.SHARE_TYPE_EMAIL?m=!0:(O===f.SHARE_TYPE_USER||O===f.SHARE_TYPE_GROUP||O===f.SHARE_TYPE_REMOTE||O===f.SHARE_TYPE_REMOTE_GROUP||O===f.SHARE_TYPE_CIRCLE||O===f.SHARE_TYPE_ROOM||O===f.SHARE_TYPE_DECK||O===f.SHARE_TYPE_SCIENCEMESH)&&(C=!0)}),OCA.Sharing.Util._updateFileActionIcon(p,C,m)}})}),e.$el.on("changeDirectory",function(){OCA.Sharing.sharesLoaded=!1}),n.registerAction({name:"Share",displayName:function(a){if(a&&a.$file){var r=parseInt(a.$file.data("share-types"),10),i=a.$file.data("share-owner-id");if(r>=0||i)return t("files_sharing","Shared")}return t("files_sharing","Share")},altText:t("files_sharing","Share"),mime:"all",order:-150,permissions:OC.PERMISSION_ALL,iconClass:function(a,r){var i=parseInt(r.$file.data("share-types"),10);return i===f.SHARE_TYPE_EMAIL||i===f.SHARE_TYPE_LINK?"icon-public":"icon-shared"},icon:function(a,r){var i=r.$file.data("share-owner-id");if(i)return OC.generateUrl("/avatar/".concat(i,"/32"))},type:OCA.Files.FileActions.TYPE_INLINE,actionHandler:function(a,r){if(e._detailsView){var i=parseInt(r.$file.data("share-permissions"),10);(isNaN(i)||i>0)&&e.showDetailsView(a,"sharing")}},render:function(a,r,i){var p=parseInt(i.$file.data("permissions"),10);return p&OC.PERMISSION_SHARE||i.$file.attr("data-share-owner")?n._defaultRenderAction.call(n,a,r,i):null}});var c=new OCA.Sharing.ShareBreadCrumbView;e.registerBreadCrumbDetailView(c)}},_updateFileListDataAttributes:function(e,n,o){if(e.id!=="files"){var l=_.pluck(o.get("shares"),"share_with_displayname");if(l.length){var h=_.mapObject(o.get("shares"),function(c){return{shareWith:c.share_with,shareWithDisplayName:c.share_with_displayname}});n.attr("data-share-recipient-data",JSON.stringify(h))}else n.removeAttr("data-share-recipient-data")}},_updateFileActionIcon:function(e,n,o){return n||o||e.attr("data-share-recipient-data")||e.attr("data-share-owner")?(OCA.Sharing.Util._markFileAsShared(e,!0,o),!0):!1},_markFileAsShared:function(e,n,o){var l=e.find('.fileactions .action[data-action="Share"]'),h=e.data("type"),c=l.find(".icon"),u,a,r,i=e.attr("data-share-owner-id"),p=e.attr("data-share-owner"),d=e.attr("data-mounttype"),s,m="icon-shared";l.removeClass("shared-style");var C=e.attr("data-e2eencrypted");if(h==="dir"&&C==="true"?(s=OC.MimeType.getIconUrl("dir-encrypted"),e.attr("data-icon",s)):h==="dir"&&(n||o||i)?(typeof d<"u"&&d!=="shared-root"&&d!=="shared"?s=OC.MimeType.getIconUrl("dir-"+d):o?s=OC.MimeType.getIconUrl("dir-public"):s=OC.MimeType.getIconUrl("dir-shared"),e.find(".filename .thumbnail").css("background-image","url("+s+")"),e.attr("data-icon",s)):h==="dir"&&(d&&d.indexOf("external")===0?(s=OC.MimeType.getIconUrl("dir-external"),e.attr("data-icon",s)):(s=OC.MimeType.getIconUrl("dir"),e.removeAttr("data-icon")),e.find(".filename .thumbnail").css("background-image","url("+s+")")),n||i){if(a=e.data("share-recipient-data"),l.addClass("shared-style"),r="<span>"+t("files_sharing","Shared")+"</span>",i?(u=t("files_sharing","Shared by"),r=OCA.Sharing.Util._formatRemoteShare(i,p,u)):a&&(r=OCA.Sharing.Util._formatShareList(a)),l.html(r).prepend(c),i||a){var E=l.find(".avatar");E.each(function(){$(this).avatar($(this).data("username"),32)})}}else l.html('<span class="hidden-visually">'+t("files_sharing","Shared")+"</span>").prepend(c);o&&(m="icon-public"),c.removeClass("icon-shared icon-public").addClass(m)},_formatRemoteShare:function(e,n,o){var l=OCA.Sharing.Util._REMOTE_OWNER_REGEXP.exec(e);if(!l||!l[7]){var h='<span class="avatar" data-username="'+S(e)+'" title="'+o+" "+S(n)+'"></span>',c='<span class="hidden-visually">'+o+" "+S(n)+"</span> ";return h+c}var u=l[2],a=l[4],r=l[5],i=l[6],p=l[8]?l[7]:"",d=o+" "+u;a&&(d+="@"+a),r&&(d+="@"+r.replace(i,"")+p);var s='<span class="remoteAddress" title="'+S(d)+'">';return s+='<span class="username">'+S(u)+"</span>",a&&(s+='<span class="userDomain">@'+S(a)+"</span>"),s+="</span> ",s},_formatShareList:function(e){var n=this;return e=_.toArray(e),e.sort(function(o,l){return o.shareWithDisplayName.localeCompare(l.shareWithDisplayName)}),$.map(e,function(o){return n._formatRemoteShare(o.shareWith,o.shareWithDisplayName,t("files_sharing","Shared with"))})},markFileAsShared:function(e,n,o){var l=e.find('.fileactions .action[data-action="Share"]'),h=e.data("type"),c=l.find(".icon"),u,a,r,i=e.attr("data-share-owner-id"),p=e.attr("data-share-owner"),d=e.attr("data-mounttype"),s,m="icon-shared";if(l.removeClass("shared-style"),h==="dir"&&(n||o||i))typeof d<"u"&&d!=="shared-root"&&d!=="shared"?s=OC.MimeType.getIconUrl("dir-"+d):o?s=OC.MimeType.getIconUrl("dir-public"):s=OC.MimeType.getIconUrl("dir-shared"),e.find(".filename .thumbnail").css("background-image","url("+s+")"),e.attr("data-icon",s);else if(h==="dir"){var C=e.attr("data-e2eencrypted");C==="true"?(s=OC.MimeType.getIconUrl("dir-encrypted"),e.attr("data-icon",s)):d&&d.indexOf("external")===0?(s=OC.MimeType.getIconUrl("dir-external"),e.attr("data-icon",s)):(s=OC.MimeType.getIconUrl("dir"),e.removeAttr("data-icon")),e.find(".filename .thumbnail").css("background-image","url("+s+")")}if(n||i){if(a=e.data("share-recipient-data"),l.addClass("shared-style"),r="<span>"+t("files_sharing","Shared")+"</span>",i?(u=t("files_sharing","Shared by"),r=this._formatRemoteShare(i,p,u)):a&&(r=this._formatShareList(a)),l.html(r).prepend(c),i||a){var E=l.find(".avatar");E.each(function(){$(this).avatar($(this).data("username"),32)})}}else l.html('<span class="hidden-visually">'+t("files_sharing","Shared")+"</span>").prepend(c);o&&(m="icon-public"),c.removeClass("icon-shared icon-public").addClass(m)},getSharePermissions:function(e){return e.sharePermissions}}})(),OC.Plugins.register("OCA.Files.FileList",OCA.Sharing.Util),function(){const e=OC.Backbone.View.extend({tagName:"span",events:{click:"_onClick"},_dirInfo:void 0,render(n){if(this._dirInfo=n.dirInfo||null,this._dirInfo!==null&&(this._dirInfo.path!=="/"||this._dirInfo.name!=="")){const o=n.dirInfo&&n.dirInfo.shareTypes&&n.dirInfo.shareTypes.length>0;this.$el.removeClass("shared icon-public icon-shared"),o?(this.$el.addClass("shared"),n.dirInfo.shareTypes.indexOf(f.SHARE_TYPE_LINK)!==-1?this.$el.addClass("icon-public"):this.$el.addClass("icon-shared")):this.$el.addClass("icon-shared"),this.$el.show(),this.delegateEvents()}else this.$el.removeClass("shared icon-public icon-shared"),this.$el.hide();return this},_onClick(n){n.preventDefault(),n.stopPropagation();const o=new OCA.Files.FileInfoModel(this._dirInfo),l=this;o.on("change",function(){l.render({dirInfo:l._dirInfo})});const h=o.attributes.path+"/"+o.attributes.name;OCA.Files.Sidebar.open(h),OCA.Files.Sidebar.setActiveTab("sharing")}});OCA.Sharing.ShareBreadCrumbView=e}(),window.OCA.Sharing=OCA.Sharing;
|