From: John Molakvoæ Date: Wed, 4 Jan 2023 10:55:43 +0000 (+0100) Subject: fix(files): Settings & cypress fixes X-Git-Tag: v26.0.0beta1~138^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=811ba0bd3be3862dbd13167695b7fc15988bbd0c;p=nextcloud-server.git fix(files): Settings & cypress fixes Signed-off-by: John Molakvoæ --- diff --git a/apps/files/src/views/Navigation.cy.ts b/apps/files/src/views/Navigation.cy.ts index 1c0ecf6e4b4..65c5d8938a9 100644 --- a/apps/files/src/views/Navigation.cy.ts +++ b/apps/files/src/views/Navigation.cy.ts @@ -8,8 +8,6 @@ import router from '../router/router.js' const Navigation = new NavigationService() -console.log(FolderSvg) - describe('Navigation renders', () => { it('renders', () => { cy.mount(NavigationView, { diff --git a/apps/files/src/views/Navigation.vue b/apps/files/src/views/Navigation.vue index a907fe4fbf3..05fc7cdacd2 100644 --- a/apps/files/src/views/Navigation.vue +++ b/apps/files/src/views/Navigation.vue @@ -31,7 +31,7 @@ :pinned="view.sticky" :title="view.name" :to="generateToNavigation(view)" - @update:open="onToggleExpand($event, view)"> + @update:open="onToggleExpand(view)"> -1?this.basename.split(".").slice(0,-1).join("."):this.basename},id:function(){return"template-picker-".concat(this.fileid)},realPreviewUrl:function(){return this.failedPreview&&this.mimeIcon?this.mimeIcon:this.previewUrl?this.previewUrl:(0,s.ts)()?(0,l.generateUrl)("/core/preview?fileId=".concat(this.fileid,"&x=").concat(C,"&y=").concat(C,"&a=1")):(0,l.generateUrl)("/apps/files_sharing/publicpreview/".concat(document.getElementById("sharingToken")&&document.getElementById("sharingToken").value,"?fileId=").concat(this.fileid,"&file=").concat(function(e){var t=(e.startsWith("/")?e:"/".concat(e)).split("/"),n="";return t.forEach((function(e){""!==e&&(n+="/"+encodeURIComponent(e))})),n}(this.filename),"&x=").concat(C,"&y=").concat(C,"&a=1"))},mimeIcon:function(){return OC.MimeType.getIconUrl(this.mime)}},methods:{onCheck:function(){this.$emit("check",this.fileid)},onFailure:function(){this.failedPreview=!0}}},k=_,O=i(93379),S=i.n(O),x=i(7795),P=i.n(x),j=i(90569),E=i.n(j),N=i(3565),F=i.n(N),T=i(19216),D=i.n(T),I=i(44589),B=i.n(I),U=i(87027),V={};V.styleTagTransform=B(),V.setAttributes=F(),V.insert=E().bind(null,"head"),V.domAPI=P(),V.insertStyleElement=D(),S()(U.Z,V),U.Z&&U.Z.locals&&U.Z.locals;var Z=i(51900),M=(0,Z.Z)(k,(function(){var e=this,t=e._self._c;return t("li",{staticClass:"template-picker__item"},[t("input",{staticClass:"radio",attrs:{id:e.id,type:"radio",name:"template-picker"},domProps:{checked:e.checked},on:{change:e.onCheck}}),e._v(" "),t("label",{staticClass:"template-picker__label",attrs:{for:e.id}},[t("div",{staticClass:"template-picker__preview",class:e.failedPreview?"template-picker__preview--failed":""},[t("img",{staticClass:"template-picker__image",attrs:{src:e.realPreviewUrl,alt:"",draggable:"false"},on:{error:e.onFailure}})]),e._v(" "),t("span",{staticClass:"template-picker__title"},[e._v("\n\t\t\t"+e._s(e.nameWithoutExt)+"\n\t\t")])])])}),[],!1,null,"440aea22",null).exports;function q(e,t,n,i,r,o,a){try{var l=e[o](a),s=l.value}catch(e){return void n(e)}l.done?t(s):Promise.resolve(s).then(i,r)}function R(e){return function(){var t=this,n=arguments;return new Promise((function(i,r){var o=e.apply(t,n);function a(e){q(o,i,r,a,l,"next",e)}function l(e){q(o,i,r,a,l,"throw",e)}a(void 0)}))}}var L={name:"TemplatePicker",components:{NcEmptyContent:v(),NcModal:h(),TemplatePreview:M},props:{logger:{type:Object,required:!0}},data:function(){return{checked:-1,loading:!1,name:null,opened:!1,provider:null}},computed:{nameWithoutExt:function(){return this.name.indexOf(".")>-1?this.name.split(".").slice(0,-1).join("."):this.name},emptyTemplate:function(){var e,n;return{basename:t("files","Blank"),fileid:-1,filename:this.t("files","Blank"),hasPreview:!1,mime:(null===(e=this.provider)||void 0===e?void 0:e.mimetypes[0])||(null===(n=this.provider)||void 0===n?void 0:n.mimetypes)}},selectedTemplate:function(){var e=this;return this.provider.templates.find((function(t){return t.fileid===e.checked}))},style:function(){return{"--margin":"8px","--width":"160px","--border":"2px","--fullwidth":"180px","--height":this.provider.ratio?Math.round(160/this.provider.ratio)+"px":null}}},methods:{open:function(e,t){var n=this;return R(regeneratorRuntime.mark((function i(){var r,o;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return n.checked=n.emptyTemplate.fileid,n.name=e,n.provider=t,i.next=5,b();case 5:if(r=i.sent,null!==(o=r.find((function(e){return e.app===t.app&&e.label===t.label})))){i.next=9;break}throw new Error("Failed to match provider in results");case 9:if(n.provider=o,0!==o.templates.length){i.next=13;break}return n.onSubmit(),i.abrupt("return");case 13:n.opened=!0;case 14:case"end":return i.stop()}}),i)})))()},close:function(){this.checked=this.emptyTemplate.fileid,this.loading=!1,this.name=null,this.opened=!1,this.provider=null},onCheck:function(e){this.checked=e},onSubmit:function(){var e=this;return R(regeneratorRuntime.mark((function t(){var n,i,r,o,a,l,s,u,p,m,v,g,h;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e.loading=!0,o=c(),a=null===(n=OCA)||void 0===n||null===(i=n.Files)||void 0===i||null===(r=i.App)||void 0===r?void 0:r.currentFileList,e.nameWithoutExt===e.name&&(e.logger.debug("Fixed invalid filename",{name:e.name,extension:null===(l=e.provider)||void 0===l?void 0:l.extension}),e.name=e.name+(null===(s=e.provider)||void 0===s?void 0:s.extension)),t.prev=4,t.next=7,w((0,d.normalize)("".concat(o,"/").concat(e.name)),null===(u=e.selectedTemplate)||void 0===u?void 0:u.filename,null===(p=e.selectedTemplate)||void 0===p?void 0:p.templateType);case 7:return m=t.sent,e.logger.debug("Created new file",m),t.next=11,null==a?void 0:a.addAndFetchFileInfo(e.name).then((function(e,t){return t}));case 11:v=t.sent,g=new OCA.Files.FileInfoModel(v,{filesClient:null==a?void 0:a.filesClient}),(h=OCA.Files.fileActions.getDefaultFileAction(m.mime,"file",OC.PERMISSION_ALL))&&h.action(m.basename,{$file:null==a?void 0:a.findFileEl(e.name),dir:o,fileList:a,fileActions:null==a?void 0:a.fileActions,fileInfoModel:g}),e.close(),t.next=23;break;case 18:t.prev=18,t.t0=t.catch(4),e.logger.error("Error while creating the new file from template"),console.error(t.t0),(0,f.x2)(e.t("files","Unable to create new file from template"));case 23:return t.prev=23,e.loading=!1,t.finish(23);case 26:case"end":return t.stop()}}),t,null,[[4,18,23,26]])})))()}}},W=L,Q=i(74502),$={};$.styleTagTransform=B(),$.setAttributes=F(),$.insert=E().bind(null,"head"),$.domAPI=P(),$.insertStyleElement=D(),S()(Q.Z,$),Q.Z&&Q.Z.locals&&Q.Z.locals;var z=(0,Z.Z)(W,(function(){var e=this,t=e._self._c;return e.opened?t("NcModal",{staticClass:"templates-picker",attrs:{"clear-view-delay":-1,size:"normal"},on:{close:e.close}},[t("form",{staticClass:"templates-picker__form",style:e.style,on:{submit:function(t){return t.preventDefault(),t.stopPropagation(),e.onSubmit.apply(null,arguments)}}},[t("h2",[e._v(e._s(e.t("files","Pick a template for {name}",{name:e.nameWithoutExt})))]),e._v(" "),t("ul",{staticClass:"templates-picker__list"},[t("TemplatePreview",e._b({attrs:{checked:e.checked===e.emptyTemplate.fileid},on:{check:e.onCheck}},"TemplatePreview",e.emptyTemplate,!1)),e._v(" "),e._l(e.provider.templates,(function(n){return t("TemplatePreview",e._b({key:n.fileid,attrs:{checked:e.checked===n.fileid,ratio:e.provider.ratio},on:{check:e.onCheck}},"TemplatePreview",n,!1))}))],2),e._v(" "),t("div",{staticClass:"templates-picker__buttons"},[t("button",{on:{click:e.close}},[e._v("\n\t\t\t\t"+e._s(e.t("files","Cancel"))+"\n\t\t\t")]),e._v(" "),t("input",{staticClass:"primary",attrs:{type:"submit","aria-label":e.t("files","Create a new file with the selected template")},domProps:{value:e.t("files","Create")}})])]),e._v(" "),e.loading?t("NcEmptyContent",{staticClass:"templates-picker__loading",attrs:{icon:"icon-loading"}},[e._v("\n\t\t"+e._s(e.t("files","Creating file"))+"\n\t")]):e._e()],1):e._e()}),[],!1,null,"55dd9121",null),G=z.exports;function Y(e,t,n,i,r,o,a){try{var l=e[o](a),s=l.value}catch(e){return void n(e)}l.done?t(s):Promise.resolve(s).then(i,r)}var H=(0,r.IY)().setApp("files").detectUser().build();p.ZP.mixin({methods:{t:a.translate,n:a.translatePlural}});var K=document.createElement("div");K.id="template-picker",document.body.appendChild(K);var J=(0,o.j)("files","templates",[]),X=(0,o.j)("files","templates_path",!1);H.debug("Templates providers",J),H.debug("Templates folder",{templatesPath:X});var ee=new(p.ZP.extend(G))({name:"TemplatePicker",propsData:{logger:H}});ee.$mount("#template-picker"),window.addEventListener("DOMContentLoaded",(function(){if(!X){H.debug("Templates folder not initialized");var e={attach:function(e){e.addMenuEntry({id:"template-init",displayName:(0,a.translate)("files","Set up templates folder"),templateName:(0,a.translate)("files","Templates"),iconClass:"icon-template-add",fileType:"file",actionHandler:function(t){ne(t),e.removeMenuEntry("template-init")}})}};OC.Plugins.register("OCA.Files.NewFileMenu",e)}})),J.forEach((function(e,t){var n={attach:function(n){var i=n.fileList;"files"!==i.id&&"files.public"!==i.id||n.addMenuEntry({id:"template-new-".concat(e.app,"-").concat(t),displayName:e.label,templateName:e.label+e.extension,iconClass:e.iconClass||"icon-file",fileType:"file",actionHandler:function(t){ee.open(t,e)}})}};OC.Plugins.register("OCA.Files.NewFileMenu",n)}));var te,ne=function(){var e,t=(e=regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(c()+"/".concat(t)).replace("//","/"),e.prev=1,H.debug("Initializing the templates directory",{templatePath:n}),e.next=5,u.default.post((0,l.generateOcsUrl)("apps/files/api/v1/templates/path"),{templatePath:n,copySystemTemplates:!0});case 5:i=e.sent,OCA.Files.App.currentFileList.changeDirectory(n,!0,!0),J=i.data.ocs.data.templates,X=i.data.ocs.data.template_path,e.next=15;break;case 11:e.prev=11,e.t0=e.catch(1),H.error("Unable to initialize the templates directory"),(0,f.x2)((0,a.translate)("files","Unable to initialize the templates directory"));case 15:case"end":return e.stop()}}),e,null,[[1,11]])})),function(){var t=this,n=arguments;return new Promise((function(i,r){var o=e.apply(t,n);function a(e){Y(o,i,r,a,l,"next",e)}function l(e){Y(o,i,r,a,l,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}(),ie=i(78595);te={attach:function(e){var t=this;(0,ie.Ld)("nextcloud:unified-search.search",(function(t){var n=t.query;e.setFilter(n)})),(0,ie.Ld)("nextcloud:unified-search.reset",(function(){t.query=null,e.setFilter("")}))}},window.OC.Plugins.register("OCA.Files.FileList",te);var re=(0,r.IY)().setApp("files").detectUser().build();function oe(e){return oe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},oe(e)}function ae(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function le(e){for(var t=1;t