@@ -118,28 +118,37 @@ 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" ) {
124+
125+ if ( sharedWith === "show-all" ) {
126+ // show all
127+ return false ;
128+ } else if ( sharedWith === "shared-with-everyone" ) {
129+ const everyoneGroupIds = [
130+ groupsStore . getEveryoneProductGroup ( ) . getGroupId ( ) ,
131+ groupsStore . getEveryoneGroup ( ) . getGroupId ( ) ,
132+ ] ;
133+ const found = Object . keys ( checks ) . some ( gId => everyoneGroupIds . includes ( parseInt ( gId ) ) ) ;
134+ // show those that are shared with "1" or product everyone's groupId
135+ return ! found ;
136+ } else if ( sharedWith === "my-resources" ) {
137+ if ( myGroupId in checks ) {
138+ const myAccessRights = checks [ myGroupId ] ;
139+ const totalAccess = "delete" in myAccessRights ? myAccessRights [ "delete" ] : myAccessRights [ "write" ] ;
140+ // show those that I have ownership of: have explicit delete (study/template) or write (service) access
128141 return ! totalAccess ;
129- } else if ( sharedWith === "shared-with-me" ) {
142+ }
143+ return true ;
144+ } else if ( sharedWith === "shared-with-me" ) {
145+ if ( myGroupId in checks ) {
146+ const myAccessRights = checks [ myGroupId ] ;
147+ const totalAccess = "delete" in myAccessRights ? myAccessRights [ "delete" ] : myAccessRights [ "write" ] ;
148+ // hide those that I'm ownership of: have explicit and delete (study/template) or write (service) access
130149 return totalAccess ;
131- } else if ( sharedWith === "shared-with-everyone" ) {
132- const everyoneGroupIds = [
133- groupsStore . getEveryoneProductGroup ( ) . getGroupId ( ) ,
134- groupsStore . getEveryoneGroup ( ) . getGroupId ( ) ,
135- ] ;
136- const found = Object . keys ( checks ) . some ( gId => everyoneGroupIds . includes ( parseInt ( gId ) ) ) ;
137- return ! found ;
138150 }
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" ) {
151+ // if we get here, it means that it was shared-with-me via an organization
143152 return false ;
144153 }
145154 return true ;
0 commit comments