@@ -151,35 +151,34 @@ qx.Class.define("osparc.editor.AnnotationNoteCreator", {
151151 } ,
152152
153153 __recipientSelected : function ( userGid ) {
154- this . __setRecipientGid ( userGid ) ;
155154 const currentAccessRights = this . __study . getAccessRights ( ) ;
156- const proposeSharing = [ ] ;
157- if ( ! ( userGid in currentAccessRights ) ) {
158- proposeSharing . push ( userGid ) ;
159- }
160- if ( proposeSharing . length ) {
161- const collaboratorsManager = new osparc . share . NewCollaboratorsManager ( currentStudy , false , true , proposeSharing ) ;
162- collaboratorsManager . addListener ( "addCollaborators" , ev => {
163- const {
164- selectedGids ,
165- newAccessRights ,
166- } = ev . getData ( ) ;
167- const newCollaborators = { } ;
168- selectedGids . forEach ( gid => {
169- newCollaborators [ gid ] = newAccessRights ;
170- } ) ;
171- const studyData = this . __study . serialize ( ) ;
172- osparc . store . Study . addCollaborators ( studyData , newCollaborators )
173- . then ( ( ) => {
174- const potentialCollaborators = osparc . store . Groups . getInstance ( ) . getPotentialCollaborators ( )
175- selectedGids . forEach ( gid => {
176- if ( gid in potentialCollaborators && "getUserId" in potentialCollaborators [ gid ] ) {
177- const uid = potentialCollaborators [ gid ] . getUserId ( ) ;
155+ if ( userGid in currentAccessRights ) {
156+ this . __setRecipientGid ( userGid ) ;
157+ } else {
158+ const msg = this . tr ( "This user has no access to the project. Do you want to share it?" ) ;
159+ const win = new osparc . ui . window . Confirmation ( msg ) . set ( {
160+ caption : this . tr ( "Share" ) ,
161+ confirmText : this . tr ( "Share" ) ,
162+ confirmAction : "create"
163+ } ) ;
164+ win . center ( ) ;
165+ win . open ( ) ;
166+ win . addListener ( "close" , ( ) => {
167+ if ( win . getConfirmed ( ) ) {
168+ const newCollaborators = {
169+ [ userGid ] : osparc . data . Roles . STUDY [ "write" ] . accessRights
170+ } ;
171+ osparc . store . Study . addCollaborators ( this . __studyData , newCollaborators )
172+ . then ( ( ) => {
173+ this . __setRecipientGid ( userGid ) ;
174+ const potentialCollaborators = osparc . store . Groups . getInstance ( ) . getPotentialCollaborators ( )
175+ if ( userGid in potentialCollaborators && "getUserId" in potentialCollaborators [ userGid ] ) {
176+ const uid = potentialCollaborators [ userGid ] . getUserId ( ) ;
178177 osparc . notification . Notifications . postNewStudy ( uid , studyData [ "uuid" ] ) ;
179178 }
180- } ) ;
181- } )
182- . finally ( ( ) => collaboratorsManager . close ( ) ) ;
179+ } )
180+ . finally ( ( ) => collaboratorsManager . close ( ) ) ;
181+ }
183182 } ) ;
184183 }
185184 } ,
0 commit comments