@@ -118,31 +118,44 @@ qx.Class.define("osparc.dashboard.CardBase", {
118118 } ,
119119
120120 filterSharedWith : function ( checks , sharedWith ) {
121- if ( sharedWith && sharedWith !== "show-all" ) {
121+ if ( sharedWith && checks ) {
122122 const groupsStore = osparc . store . Groups . getInstance ( ) ;
123123 const myGroupId = groupsStore . getMyGroupId ( ) ;
124- if ( checks && myGroupId in checks ) {
125- const myAccessRights = checks [ myGroupId ] ;
126- const totalAccess = "delete" in myAccessRights ? myAccessRights [ "delete" ] : myAccessRights [ "write" ] ;
127- if ( sharedWith === "my-resources" ) {
128- return ! totalAccess ;
129- } else if ( sharedWith === "shared-with-me" ) {
130- return totalAccess ;
131- } else if ( sharedWith === "shared-with-everyone" ) {
124+
125+ switch ( sharedWith ) {
126+ case "show-all" :
127+ return false ;
128+ case "my-resources" : {
129+ if ( myGroupId in checks ) {
130+ const myAccessRights = checks [ myGroupId ] ;
131+ const totalAccess = "delete" in myAccessRights ? myAccessRights [ "delete" ] : myAccessRights [ "write" ] ;
132+ // show those that I have ownership of: have explicit delete (study/template) or write (service) access
133+ return ! totalAccess ;
134+ }
135+ return true ;
136+ }
137+ case "shared-with-me" : {
138+ if ( myGroupId in checks ) {
139+ const myAccessRights = checks [ myGroupId ] ;
140+ const totalAccess = "delete" in myAccessRights ? myAccessRights [ "delete" ] : myAccessRights [ "write" ] ;
141+ // hide those that I'm ownership of: have explicit and delete (study/template) or write (service) access
142+ return totalAccess ;
143+ }
144+ // if we get here, it means that it was shared-with-me via an organization
145+ return false ;
146+ }
147+ case "shared-with-everyone" : {
132148 const everyoneGroupIds = [
133149 groupsStore . getEveryoneProductGroup ( ) . getGroupId ( ) ,
134150 groupsStore . getEveryoneGroup ( ) . getGroupId ( ) ,
135151 ] ;
136152 const found = Object . keys ( checks ) . some ( gId => everyoneGroupIds . includes ( parseInt ( gId ) ) ) ;
153+ // show those that are shared with "1" or product everyone's groupId
137154 return ! found ;
138155 }
139- return false ;
140- }
141- // if we get here, it means that it was shared-with-me via an organization
142- if ( sharedWith === "shared-with-me" ) {
143- return false ;
156+ default :
157+ return true ;
144158 }
145- return true ;
146159 }
147160 return false ;
148161 } ,
0 commit comments