Skip to content

Commit

Permalink
Merge pull request #1757 from nextcloud/fix/messages
Browse files Browse the repository at this point in the history
fix: More accurate error messages
  • Loading branch information
artonge authored Aug 26, 2024
2 parents 8d62eff + 73a9539 commit 87d1b09
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion js/Activity-C5xuhov_.chunk.mjs.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/Activity-iVcEzjDi.chunk.mjs.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".activity[data-v-4f32db6b]{display:flex;flex-direction:column;overflow:hidden;height:100%}.activity__actions[data-v-4f32db6b]{display:flex;flex-direction:column;width:100%}.activity__empty-content[data-v-4f32db6b]{height:100%}[data-v-4f32db6b] .empty-content__icon span{background-size:64px;width:64px;height:64px}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
import{b as c,d as l,e as u,v}from"./NcCheckboxRadioSwitch-D2GbHtCS-2fCS121m.chunk.mjs";import{d as f,e as p,o as d,b as y,k as g,t as o}from"./index-CL4CgOWu.chunk.mjs";import{a as m,b as h,N as _,c as b}from"./Activity-C5xuhov_.chunk.mjs";import{g as r,a as I,b as A}from"./api-wy7VpNU4.chunk.mjs";import{l as S}from"./logger-CimJwhmx.chunk.mjs";import{l as P}from"./activity-sidebar.mjs";import"./_commonjsHelpers-D9DevfhH.chunk.mjs";const x=f({__name:"ActivitySidebarPlugin",props:{plugin:null,fileInfo:null},emits:["reload-activities"],setup(t,{emit:i}){const a=t,s=p();return d(()=>{var n;return a.plugin.mount(s.value,{context:(n=y())==null?void 0:n.proxy,fileInfo:a.fileInfo,reload:()=>i("reload-activities")})}),g(()=>a.plugin.unmount()),{__sfc:!0,props:a,emit:i,attachTarget:s}}});var N=function(){var t=this,i=t._self._c;return t._self._setupProxy,i("div",{ref:"attachTarget"})},w=[],C=c(x,N,w,!1,null,null);const k=C.exports,E={name:"ActivityTab",components:{Activity:m,NcEmptyContent:h,NcIconSvgWrapper:_,NcLoadingIcon:l,ActivitySidebarPlugin:k},data(){return{error:"",loading:!0,fileInfo:null,activities:[],lightningBoltSVG:P,sidebarPlugins:[]}},mounted(){this.sidebarPlugins=r()},methods:{async update(t){this.sidebarPlugins=[];let i=r();i.length>0&&this.$nextTick(()=>{this.sidebarPlugins=i}),this.fileInfo=t,this.resetState(),await this.getActivities()},async getActivities(){try{this.loading=!0;const t=await this.processActivities(await this.loadRealActivities()),i=await I({fileInfo:this.fileInfo});this.activities=[...t,...i].sort((a,s)=>s.timestamp-a.timestamp)}catch(t){this.error=o("activity","Unable to load the activity list"),console.error("Error loading the activity list",t)}finally{this.loading=!1}},resetState(){this.loading=!0,this.error="",this.activities=[]},async loadRealActivities(){try{const{data:t}=await u.get(v("apps/activity/api/v2/activity/filter"),{params:{format:"json",object_type:"files",object_id:this.fileInfo.id}});return t.ocs.data}catch(t){if(t.response!==void 0&&t.response.status===304)return[];throw e}},processActivities(t){t=t.map(a=>new b(a)),S.debug("Processed ".concat(t.length," activity(ies)"),{activities:t,fileInfo:this.fileInfo});const i=A();return t.filter(a=>!i||i.every(s=>s(a)))},t:o}};var T=function(){var t=this,i=t._self._c;return i("div",{staticClass:"activity",class:{"icon-loading":t.loading}},[t.error?i("NcEmptyContent",{attrs:{name:t.error},scopedSlots:t._u([{key:"icon",fn:function(){return[i("NcIconSvgWrapper",{attrs:{svg:t.lightningBoltSVG}})]},proxy:!0}],null,!1,63559581)}):[t.sidebarPlugins.length>0?i("div",{staticClass:"activity__actions"},t._l(t.sidebarPlugins,function(a,s){return i("ActivitySidebarPlugin",{key:s,attrs:{plugin:a,"file-info":t.fileInfo},on:{"reload-activities":function(n){return t.getActivities()}}})}),1):t._e(),t.loading?i("NcEmptyContent",{staticClass:"activity__empty-content",attrs:{name:t.t("activity","Loading activities")},scopedSlots:t._u([{key:"icon",fn:function(){return[i("NcLoadingIcon")]},proxy:!0}],null,!1,3085876643)}):t.activities.length===0?i("NcEmptyContent",{staticClass:"activity__empty-content",attrs:{name:t.t("activity","No activity yet")},scopedSlots:t._u([{key:"icon",fn:function(){return[i("span",{staticClass:"icon-activity"})]},proxy:!0}])}):i("ul",t._l(t.activities,function(a){return i("Activity",{key:a.id,attrs:{activity:a,"show-previews":!1},on:{reload:function(s){return t.getActivities()}}})}),1)]],2)},j=[],L=c(E,T,j,!1,null,"4f32db6b");const U=L.exports;export{U as default};
import{b as c,d as l,e as u,v}from"./NcCheckboxRadioSwitch-D2GbHtCS-2fCS121m.chunk.mjs";import{d as f,e as p,o as d,b as y,k as g,t as o}from"./index-CL4CgOWu.chunk.mjs";import{a as m,b as h,N as _,c as b}from"./Activity-iVcEzjDi.chunk.mjs";import{g as r,a as I,b as A}from"./api-wy7VpNU4.chunk.mjs";import{l as S}from"./logger-CimJwhmx.chunk.mjs";import{l as P}from"./activity-sidebar.mjs";import"./_commonjsHelpers-D9DevfhH.chunk.mjs";const x=f({__name:"ActivitySidebarPlugin",props:{plugin:null,fileInfo:null},emits:["reload-activities"],setup(t,{emit:i}){const a=t,s=p();return d(()=>{var n;return a.plugin.mount(s.value,{context:(n=y())==null?void 0:n.proxy,fileInfo:a.fileInfo,reload:()=>i("reload-activities")})}),g(()=>a.plugin.unmount()),{__sfc:!0,props:a,emit:i,attachTarget:s}}});var N=function(){var t=this,i=t._self._c;return t._self._setupProxy,i("div",{ref:"attachTarget"})},w=[],C=c(x,N,w,!1,null,null);const k=C.exports,E={name:"ActivityTab",components:{Activity:m,NcEmptyContent:h,NcIconSvgWrapper:_,NcLoadingIcon:l,ActivitySidebarPlugin:k},data(){return{error:"",loading:!0,fileInfo:null,activities:[],lightningBoltSVG:P,sidebarPlugins:[]}},mounted(){this.sidebarPlugins=r()},methods:{async update(t){this.sidebarPlugins=[];let i=r();i.length>0&&this.$nextTick(()=>{this.sidebarPlugins=i}),this.fileInfo=t,this.resetState(),await this.getActivities()},async getActivities(){try{this.loading=!0;const t=await this.processActivities(await this.loadRealActivities()),i=await I({fileInfo:this.fileInfo});this.activities=[...t,...i].sort((a,s)=>s.timestamp-a.timestamp)}catch(t){this.error=o("activity","Unable to load the activity list"),console.error("Error loading the activity list",t)}finally{this.loading=!1}},resetState(){this.loading=!0,this.error="",this.activities=[]},async loadRealActivities(){try{const{data:t}=await u.get(v("apps/activity/api/v2/activity/filter"),{params:{format:"json",object_type:"files",object_id:this.fileInfo.id}});return t.ocs.data}catch(t){if(t.response!==void 0&&t.response.status===304)return[];throw e}},processActivities(t){t=t.map(a=>new b(a)),S.debug("Processed ".concat(t.length," activity(ies)"),{activities:t,fileInfo:this.fileInfo});const i=A();return t.filter(a=>!i||i.every(s=>s(a)))},t:o}};var T=function(){var t=this,i=t._self._c;return i("div",{staticClass:"activity",class:{"icon-loading":t.loading}},[t.error?i("NcEmptyContent",{attrs:{name:t.error},scopedSlots:t._u([{key:"icon",fn:function(){return[i("NcIconSvgWrapper",{attrs:{svg:t.lightningBoltSVG}})]},proxy:!0}],null,!1,63559581)}):[t.sidebarPlugins.length>0?i("div",{staticClass:"activity__actions"},t._l(t.sidebarPlugins,function(a,s){return i("ActivitySidebarPlugin",{key:s,attrs:{plugin:a,"file-info":t.fileInfo},on:{"reload-activities":function(n){return t.getActivities()}}})}),1):t._e(),t.loading?i("NcEmptyContent",{staticClass:"activity__empty-content",attrs:{name:t.t("activity","Loading activities")},scopedSlots:t._u([{key:"icon",fn:function(){return[i("NcLoadingIcon")]},proxy:!0}],null,!1,3085876643)}):t.activities.length===0?i("NcEmptyContent",{staticClass:"activity__empty-content",attrs:{name:t.t("activity","No activity yet")},scopedSlots:t._u([{key:"icon",fn:function(){return[i("span",{staticClass:"icon-activity"})]},proxy:!0}])}):i("ul",t._l(t.activities,function(a){return i("Activity",{key:a.id,attrs:{activity:a,"show-previews":!1},on:{reload:function(s){return t.getActivities()}}})}),1)]],2)},j=[],L=c(E,T,j,!1,null,"4f32db6b");const U=L.exports;export{U as default};

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/activity-app.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/activity-sidebar.mjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=[window.OC.filePath('activity', '', 'js/ActivityTab-DkyYsMgn.chunk.mjs'),window.OC.filePath('activity', '', 'js/NcCheckboxRadioSwitch-D2GbHtCS-2fCS121m.chunk.mjs'),window.OC.filePath('activity', '', 'js/index-CL4CgOWu.chunk.mjs'),window.OC.filePath('activity', '', 'js/_commonjsHelpers-D9DevfhH.chunk.mjs'),window.OC.filePath('activity', '', 'js/logger-CimJwhmx.chunk.mjs'),window.OC.filePath('activity', '', 'js/Activity-C5xuhov_.chunk.mjs'),window.OC.filePath('activity', '', 'js/api-wy7VpNU4.chunk.mjs')])))=>i.map(i=>d[i]);
import{V as m,t as h,h as g}from"./index-CL4CgOWu.chunk.mjs";import"./_commonjsHelpers-D9DevfhH.chunk.mjs";const E="modulepreload",_=function(n,r){return new URL(n,r).href},y={},w=function(n,r,c){let u=Promise.resolve();if(r&&r.length>0){const l=document.getElementsByTagName("link"),e=document.querySelector("meta[property=csp-nonce]"),f=(e==null?void 0:e.nonce)||(e==null?void 0:e.getAttribute("nonce"));u=Promise.all(r.map(o=>{if(o=_(o,c),o in y)return;y[o]=!0;const s=o.endsWith(".css"),v=s?'[rel="stylesheet"]':"";if(c)for(let d=l.length-1;d>=0;d--){const p=l[d];if(p.href===o&&(!s||p.rel==="stylesheet"))return}else if(document.querySelector('link[href="'.concat(o,'"]').concat(v)))return;const i=document.createElement("link");if(i.rel=s?"stylesheet":E,s||(i.as="script",i.crossOrigin=""),i.href=o,f&&i.setAttribute("nonce",f),document.head.appendChild(i),s)return new Promise((d,p)=>{i.addEventListener("load",d),i.addEventListener("error",()=>p(new Error("Unable to preload CSS for ".concat(o))))})}))}return u.then(()=>n()).catch(l=>{const e=new Event("vite:preloadError",{cancelable:!0});if(e.payload=l,window.dispatchEvent(e),!e.defaultPrevented)throw l})},b='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-lightning-bolt" viewBox="0 0 24 24"><path d="M11 15H6L13 1V9H18L11 23V15Z" /></svg>';m.prototype.t=h,m.prototype.n=g;let t=null,a=null;const A=new OCA.Files.Sidebar.Tab({id:"activity",name:h("activity","Activity"),iconSvg:b,async mount(n,r,c){if(t===null){const{default:u}=await w(async()=>{const{default:l}=await import("./ActivityTab-DkyYsMgn.chunk.mjs");return{default:l}},__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url);t=t!=null?t:m.extend(u)}a&&a.$destroy(),a=new t({parent:c}),a.update(r),a.$mount(n)},update(n){a.update(n)},destroy(){a.$destroy(),a=null}});window.addEventListener("DOMContentLoaded",async function(){if(OCA.Files&&OCA.Files.Sidebar){OCA.Files.Sidebar.registerTab(A);const{default:n}=await w(async()=>{const{default:r}=await import("./ActivityTab-DkyYsMgn.chunk.mjs");return{default:r}},__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url);t=t!=null?t:m.extend(n)}});export{b as l};
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=[window.OC.filePath('activity', '', 'js/ActivityTab-DOClPsq6.chunk.mjs'),window.OC.filePath('activity', '', 'js/NcCheckboxRadioSwitch-D2GbHtCS-2fCS121m.chunk.mjs'),window.OC.filePath('activity', '', 'js/index-CL4CgOWu.chunk.mjs'),window.OC.filePath('activity', '', 'js/_commonjsHelpers-D9DevfhH.chunk.mjs'),window.OC.filePath('activity', '', 'js/logger-CimJwhmx.chunk.mjs'),window.OC.filePath('activity', '', 'js/Activity-iVcEzjDi.chunk.mjs'),window.OC.filePath('activity', '', 'js/api-wy7VpNU4.chunk.mjs')])))=>i.map(i=>d[i]);
import{V as m,t as h,h as g}from"./index-CL4CgOWu.chunk.mjs";import"./_commonjsHelpers-D9DevfhH.chunk.mjs";const E="modulepreload",_=function(n,r){return new URL(n,r).href},y={},w=function(n,r,c){let u=Promise.resolve();if(r&&r.length>0){const l=document.getElementsByTagName("link"),e=document.querySelector("meta[property=csp-nonce]"),f=(e==null?void 0:e.nonce)||(e==null?void 0:e.getAttribute("nonce"));u=Promise.all(r.map(o=>{if(o=_(o,c),o in y)return;y[o]=!0;const s=o.endsWith(".css"),v=s?'[rel="stylesheet"]':"";if(c)for(let d=l.length-1;d>=0;d--){const p=l[d];if(p.href===o&&(!s||p.rel==="stylesheet"))return}else if(document.querySelector('link[href="'.concat(o,'"]').concat(v)))return;const i=document.createElement("link");if(i.rel=s?"stylesheet":E,s||(i.as="script",i.crossOrigin=""),i.href=o,f&&i.setAttribute("nonce",f),document.head.appendChild(i),s)return new Promise((d,p)=>{i.addEventListener("load",d),i.addEventListener("error",()=>p(new Error("Unable to preload CSS for ".concat(o))))})}))}return u.then(()=>n()).catch(l=>{const e=new Event("vite:preloadError",{cancelable:!0});if(e.payload=l,window.dispatchEvent(e),!e.defaultPrevented)throw l})},b='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-lightning-bolt" viewBox="0 0 24 24"><path d="M11 15H6L13 1V9H18L11 23V15Z" /></svg>';m.prototype.t=h,m.prototype.n=g;let t=null,a=null;const A=new OCA.Files.Sidebar.Tab({id:"activity",name:h("activity","Activity"),iconSvg:b,async mount(n,r,c){if(t===null){const{default:u}=await w(async()=>{const{default:l}=await import("./ActivityTab-DOClPsq6.chunk.mjs");return{default:l}},__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url);t=t!=null?t:m.extend(u)}a&&a.$destroy(),a=new t({parent:c}),a.update(r),a.$mount(n)},update(n){a.update(n)},destroy(){a.$destroy(),a=null}});window.addEventListener("DOMContentLoaded",async function(){if(OCA.Files&&OCA.Files.Sidebar){OCA.Files.Sidebar.registerTab(A);const{default:n}=await w(async()=>{const{default:r}=await import("./ActivityTab-DOClPsq6.chunk.mjs");return{default:r}},__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url);t=t!=null?t:m.extend(n)}});export{b as l};
10 changes: 5 additions & 5 deletions src/models/ActivityModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ export default class ActivityModel {

// Sanity checks
if (typeof rawActivity.activity_id !== 'number') {
throw new Error('The activity_id argument is not a valid string')
throw new Error('The activity_id argument is not a number')
}
if (typeof rawActivity.type !== 'string' || rawActivity.type.trim() === '') {
throw new Error('The activity_id argument is not a valid string')
throw new Error('The type argument is not a valid string')
}
if (typeof rawActivity.subject !== 'string' || rawActivity.subject.trim() === '') {
throw new Error('The activity_id argument is not a valid string')
throw new Error('The subject argument is not a valid string')
}
if (typeof rawActivity.icon !== 'string' || rawActivity.icon.trim() === '') {
throw new Error('The activity_id argument is not a valid string')
throw new Error('The icon argument is not a valid string')
}
if (typeof rawActivity.datetime !== 'string' || rawActivity.datetime.trim() === '') {
throw new Error('The activity_id argument is not a valid string')
throw new Error('The datetime argument is not a valid string')
}

// store state
Expand Down

0 comments on commit 87d1b09

Please sign in to comment.