@@ -335,6 +335,13 @@ qx.Class.define("osparc.share.Collaborators", {
335335 } ) ;
336336 item . addListener ( "removeMember" , e => {
337337 const orgMember = e . getData ( ) ;
338+ if (
339+ [ "study" , "template" ] . includes ( this . _resourceType ) &&
340+ ! osparc . share . CollaboratorsStudy . canCollaboratorBeRemoved ( this . _serializedDataCopy , orgMember [ "gid" ] )
341+ ) {
342+ const msg = "Nope" ;
343+ osparc . FlashMessenger . logError ( msg ) ;
344+ }
338345 this . _deleteMember ( orgMember , item ) ;
339346 } ) ;
340347 }
@@ -349,11 +356,8 @@ qx.Class.define("osparc.share.Collaborators", {
349356 __getLeaveStudyButton : function ( ) {
350357 const myGid = osparc . auth . Data . getInstance ( ) . getGroupId ( ) ;
351358 if (
352- ( this . _resourceType === "study" ) &&
353- // check if I'm part of the access rights (not through an organization)
354- Object . keys ( this . _serializedDataCopy [ "accessRights" ] ) . includes ( myGid . toString ( ) ) &&
355- // check also user is not "prjOwner". Backend will silently not let the frontend remove that user.
356- ( this . _serializedDataCopy [ "prjOwner" ] !== osparc . auth . Data . getInstance ( ) . getEmail ( ) )
359+ [ "study" , "template" ] . includes ( this . _resourceType ) &&
360+ osparc . share . CollaboratorsStudy . canCollaboratorBeRemoved ( this . _serializedDataCopy , myGid )
357361 ) {
358362 const leaveText = this . tr ( "Leave" ) + " " + osparc . product . Utils . getStudyAlias ( {
359363 firstUpperCase : true
@@ -363,29 +367,14 @@ qx.Class.define("osparc.share.Collaborators", {
363367 visibility : Object . keys ( this . _serializedDataCopy [ "accessRights" ] ) . includes ( myGid . toString ( ) ) ? "visible" : "excluded"
364368 } ) ;
365369 leaveButton . addListener ( "execute" , ( ) => {
366- let msg = `"${ this . _serializedDataCopy [ "name" ] } " ` + this . tr ( "will no longer be listed." ) ;
367- if ( ! osparc . share . CollaboratorsStudy . checkRemoveCollaborator ( this . _serializedDataCopy , myGid ) ) {
368- msg += "<br>" ;
369- msg += this . tr ( "If you remove yourself, there won't be any other Owners." ) ;
370+ const collaborator = {
371+ gid : myGid ,
372+ name : osparc . store . Groups . getInstance ( ) . getGroupMe ( ) . getLabel ( ) ,
370373 }
371- const win = new osparc . ui . window . Confirmation ( msg ) . set ( {
372- caption : leaveText ,
373- confirmText : this . tr ( "Leave" ) ,
374- confirmAction : "delete"
375- } ) ;
376- win . open ( ) ;
377- win . addListener ( "close" , ( ) => {
378- if ( win . getConfirmed ( ) ) {
379- const collaborator = {
380- gid : myGid ,
381- name : osparc . store . Groups . getInstance ( ) . getGroupMe ( ) . getLabel ( ) ,
382- }
383- this . _deleteMember ( collaborator )
384- . then ( ( ) => {
385- qx . event . message . Bus . dispatchByName ( "reloadStudies" ) ;
386- } ) ;
387- }
388- } , this ) ;
374+ this . _deleteMember ( collaborator )
375+ . then ( ( ) => {
376+ qx . event . message . Bus . dispatchByName ( "reloadStudies" ) ;
377+ } ) ;
389378 } , this ) ;
390379 return leaveButton ;
391380 }
0 commit comments