@@ -28,38 +28,6 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
2828 } ,
2929
3030 statics : {
31- getNoReadAccess : function ( ) {
32- return {
33- "read" : false ,
34- "write" : false ,
35- "delete" : false
36- } ;
37- } ,
38-
39- getReadAccess : function ( ) {
40- return {
41- "read" : true ,
42- "write" : false ,
43- "delete" : false
44- } ;
45- } ,
46-
47- getWriteAccess : function ( ) {
48- return {
49- "read" : true ,
50- "write" : true ,
51- "delete" : false
52- } ;
53- } ,
54-
55- getDeleteAccess : function ( ) {
56- return {
57- "read" : true ,
58- "write" : true ,
59- "delete" : true
60- } ;
61- } ,
62-
6331 sortOrgMembers : function ( a , b ) {
6432 const sorted = osparc . share . Collaborators . sortByAccessRights ( a [ "accessRights" ] , b [ "accessRights" ] ) ;
6533 if ( sorted !== 0 ) {
@@ -356,15 +324,16 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
356324 return ;
357325 }
358326
359- const newAccessRights = this . self ( ) . getReadAccess ( ) ;
327+ const readAccessRole = osparc . data . Roles . ORG [ "read" ] ;
328+ const newAccessRights = readAccessRole . accessRights ;
360329 const groupsStore = osparc . store . Groups . getInstance ( ) ;
361330 groupsStore . patchMember ( this . __currentOrg . getGroupId ( ) , listedMember [ "id" ] , newAccessRights )
362331 . then ( ( ) => {
363- osparc . FlashMessenger . logAs ( this . tr ( `Successfully promoted to ${ osparc . data . Roles . ORG [ "read" ] . label } ` ) ) ;
332+ osparc . FlashMessenger . logAs ( this . tr ( `Successfully promoted to ${ readAccessRole . label } ` ) ) ;
364333 this . __reloadOrgMembers ( ) ;
365334 } )
366335 . catch ( err => {
367- const msg = this . tr ( "Something went wrong while promoting to " ) + osparc . data . Roles . ORG [ "read" ] . label ;
336+ const msg = this . tr ( "Something went wrong while promoting to " ) + readAccessRole . label ;
368337 osparc . FlashMessenger . logError ( err , msg ) ;
369338 } ) ;
370339 } ,
@@ -374,20 +343,21 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
374343 return ;
375344 }
376345
346+ const noReadAccessRole = osparc . data . Roles . ORG [ "noRead" ] ;
347+ const newAccessRights = noReadAccessRole . accessRights ;
377348 const orgId = this . __currentOrg . getGroupId ( ) ;
378349 const userId = "id" in listedMember ? listedMember [ "id" ] : listedMember [ "key" ]
379- const newAccessRights = this . self ( ) . getNoReadAccess ( ) ;
380350 const groupsStore = osparc . store . Groups . getInstance ( ) ;
381351 groupsStore . patchAccessRights ( orgId , userId , newAccessRights )
382352 . then ( ( ) => {
383353 if ( msg === undefined ) {
384- msg = this . tr ( `Successfully demoted to ${ osparc . data . Roles . ORG [ "noRead" ] . label } ` ) ;
354+ msg = this . tr ( `Successfully demoted to ${ noReadAccessRole . label } ` ) ;
385355 }
386356 osparc . FlashMessenger . logAs ( msg ) ;
387357 this . __reloadOrgMembers ( ) ;
388358 } )
389359 . catch ( err => {
390- const errorMsg = this . tr ( "Something went wrong while demoting to " ) + osparc . data . Roles . ORG [ "noRead" ] . label ;
360+ const errorMsg = this . tr ( "Something went wrong while demoting to " ) + noReadAccessRole . label ;
391361 osparc . FlashMessenger . logError ( err , errorMsg ) ;
392362 } ) ;
393363 } ,
@@ -397,17 +367,18 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
397367 return ;
398368 }
399369
370+ const writeAccessRole = osparc . data . Roles . ORG [ "write" ] ;
371+ const newAccessRights = writeAccessRole . accessRights ;
400372 const orgId = this . __currentOrg . getGroupId ( ) ;
401373 const userId = listedMember [ "id" ] ;
402- const newAccessRights = this . self ( ) . getWriteAccess ( ) ;
403374 const groupsStore = osparc . store . Groups . getInstance ( ) ;
404375 groupsStore . patchAccessRights ( orgId , userId , newAccessRights )
405376 . then ( ( ) => {
406- osparc . FlashMessenger . logAs ( this . tr ( `Successfully promoted to ${ osparc . data . Roles . ORG [ "write" ] . label } ` ) ) ;
377+ osparc . FlashMessenger . logAs ( this . tr ( `Successfully promoted to ${ writeAccessRole . label } ` ) ) ;
407378 this . __reloadOrgMembers ( ) ;
408379 } )
409380 . catch ( err => {
410- const msg = this . tr ( "Something went wrong while promoting to " ) + osparc . data . Roles . ORG [ "write" ] . label ;
381+ const msg = this . tr ( "Something went wrong while promoting to " ) + writeAccessRole . label ;
411382 osparc . FlashMessenger . logError ( err , msg ) ;
412383 } ) ;
413384 } ,
@@ -417,17 +388,18 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
417388 return ;
418389 }
419390
391+ const deleteAccessRole = osparc . data . Roles . ORG [ "delete" ] ;
392+ const newAccessRights = deleteAccessRole . accessRights ;
420393 const orgId = this . __currentOrg . getGroupId ( ) ;
421394 const userId = listedMember [ "id" ] ;
422- const newAccessRights = this . self ( ) . getDeleteAccess ( ) ;
423395 const groupsStore = osparc . store . Groups . getInstance ( ) ;
424396 groupsStore . patchAccessRights ( orgId , userId , newAccessRights )
425397 . then ( ( ) => {
426- osparc . FlashMessenger . logAs ( this . tr ( `Successfully promoted to ${ osparc . data . Roles . ORG [ "delete" ] . label } ` ) ) ;
398+ osparc . FlashMessenger . logAs ( this . tr ( `Successfully promoted to ${ deleteAccessRole . label } ` ) ) ;
427399 this . __reloadOrgMembers ( ) ;
428400 } )
429401 . catch ( err => {
430- const msg = this . tr ( "Something went wrong while promoting to " ) + osparc . data . Roles . ORG [ "delete" ] . label ;
402+ const msg = this . tr ( "Something went wrong while promoting to " ) + deleteAccessRole . label ;
431403 osparc . FlashMessenger . logError ( err , msg ) ;
432404 } ) ;
433405 } ,
@@ -437,17 +409,18 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
437409 return ;
438410 }
439411
412+ const readAccessRole = osparc . data . Roles . ORG [ "read" ] ;
413+ const newAccessRights = readAccessRole . accessRights ;
440414 const orgId = this . __currentOrg . getGroupId ( ) ;
441415 const userId = listedMember [ "id" ] ;
442- const newAccessRights = this . self ( ) . getReadAccess ( ) ;
443416 const groupsStore = osparc . store . Groups . getInstance ( ) ;
444417 groupsStore . patchAccessRights ( orgId , userId , newAccessRights )
445418 . then ( ( ) => {
446- osparc . FlashMessenger . logAs ( this . tr ( `Successfully demoted to ${ osparc . data . Roles . ORG [ "read" ] . label } ` ) ) ;
419+ osparc . FlashMessenger . logAs ( this . tr ( `Successfully demoted to ${ readAccessRole . label } ` ) ) ;
447420 this . __reloadOrgMembers ( ) ;
448421 } )
449422 . catch ( err => {
450- const msg = this . tr ( "Something went wrong while demoting to " ) + osparc . data . Roles . ORG [ "read" ] . label ;
423+ const msg = this . tr ( "Something went wrong while demoting to " ) + readAccessRole . label ;
451424 osparc . FlashMessenger . logError ( err , msg ) ;
452425 } ) ;
453426 } ,
@@ -457,17 +430,18 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
457430 return ;
458431 }
459432
433+ const writeAccessRole = osparc . data . Roles . ORG [ "write" ] ;
434+ const newAccessRights = writeAccessRole . accessRights ;
460435 const orgId = this . __currentOrg . getGroupId ( ) ;
461436 const userId = listedMember [ "id" ] ;
462- const newAccessRights = this . self ( ) . getWriteAccess ( ) ;
463437 const groupsStore = osparc . store . Groups . getInstance ( ) ;
464438 groupsStore . patchAccessRights ( orgId , userId , newAccessRights )
465439 . then ( ( ) => {
466- osparc . FlashMessenger . logAs ( this . tr ( `Successfully demoted to ${ osparc . data . Roles . ORG [ "write" ] . label } ` ) ) ;
440+ osparc . FlashMessenger . logAs ( this . tr ( `Successfully demoted to ${ writeAccessRole . label } ` ) ) ;
467441 this . __reloadOrgMembers ( ) ;
468442 } )
469443 . catch ( err => {
470- const msg = this . tr ( "Something went wrong while demoting to " ) + osparc . data . Roles . ORG [ "write" ] . label ;
444+ const msg = this . tr ( "Something went wrong while demoting to " ) + writeAccessRole . label ;
471445 osparc . FlashMessenger . logError ( err , msg ) ;
472446 } ) ;
473447 } ,
0 commit comments