@@ -57,30 +57,6 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
5757 return canWrite ;
5858 } ,
5959
60- getViewerAccessRight : function ( ) {
61- return {
62- "read" : true ,
63- "write" : false ,
64- "delete" : false
65- } ;
66- } ,
67-
68- getCollaboratorAccessRight : function ( ) {
69- return {
70- "read" : true ,
71- "write" : true ,
72- "delete" : false
73- } ;
74- } ,
75-
76- getOwnerAccessRight : function ( ) {
77- return {
78- "read" : true ,
79- "write" : true ,
80- "delete" : true
81- } ;
82- } ,
83-
8460 __getDeleters : function ( studyData ) {
8561 const deleters = [ ] ;
8662 Object . entries ( studyData [ "accessRights" ] ) . forEach ( ( [ key , value ] ) => {
@@ -107,12 +83,14 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
10783 return ;
10884 }
10985
86+ const readAccessRole = osparc . data . Roles . STUDY [ "read" ] ;
87+ const writeAccessRole = osparc . data . Roles . STUDY [ "read" ] ;
11088 const resourceAlias = this . _resourceType === "template" ?
11189 osparc . product . Utils . getTemplateAlias ( { firstUpperCase : true } ) :
11290 osparc . product . Utils . getStudyAlias ( { firstUpperCase : true } ) ;
11391 const newCollaborators = { } ;
11492 gids . forEach ( gid => {
115- newCollaborators [ gid ] = this . _resourceType === "study" ? this . self ( ) . getCollaboratorAccessRight ( ) : this . self ( ) . getViewerAccessRight ( ) ;
93+ newCollaborators [ gid ] = this . _resourceType === "study" ? writeAccessRole . accessRights : readAccessRole . accessRights
11694 } ) ;
11795 osparc . store . Study . addCollaborators ( this . _serializedDataCopy , newCollaborators )
11896 . then ( ( ) => {
@@ -164,40 +142,43 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
164142 } ,
165143
166144 _promoteToEditor : function ( collaborator , item ) {
145+ const writeAccessRole = osparc . data . Roles . STUDY [ "write" ] ;
167146 this . __make (
168147 collaborator [ "gid" ] ,
169- this . self ( ) . getCollaboratorAccessRight ( ) ,
170- this . tr ( `Successfully promoted to ${ osparc . data . Roles . STUDY [ "write" ] . label } ` ) ,
171- this . tr ( `Something went wrong while promoting to ${ osparc . data . Roles . STUDY [ "write" ] . label } ` ) ,
148+ writeAccessRole . accessRights ,
149+ this . tr ( `Successfully promoted to ${ writeAccessRole . label } ` ) ,
150+ this . tr ( `Something went wrong while promoting to ${ writeAccessRole . label } ` ) ,
172151 item
173152 ) ;
174153 } ,
175154
176155 _promoteToOwner : function ( collaborator , item ) {
156+ const deleteAccessRole = osparc . data . Roles . STUDY [ "delete" ] ;
177157 this . __make (
178158 collaborator [ "gid" ] ,
179- this . self ( ) . getOwnerAccessRight ( ) ,
180- this . tr ( `Successfully promoted to ${ osparc . data . Roles . STUDY [ "delete" ] . label } ` ) ,
181- this . tr ( `Something went wrong while promoting to ${ osparc . data . Roles . STUDY [ "delete" ] . label } ` ) ,
159+ deleteAccessRole . accessRights ,
160+ this . tr ( `Successfully promoted to ${ deleteAccessRole . label } ` ) ,
161+ this . tr ( `Something went wrong while promoting to ${ deleteAccessRole . label } ` ) ,
182162 item
183163 ) ;
184164 } ,
185165
186166 _demoteToUser : async function ( collaborator , item ) {
167+ const readAccessRole = osparc . data . Roles . STUDY [ "read" ] ;
187168 const groupId = collaborator [ "gid" ] ;
188169 const demoteToUser = ( gid , itm ) => {
189170 this . __make (
190171 gid ,
191- this . self ( ) . getViewerAccessRight ( ) ,
192- this . tr ( `Successfully demoted to ${ osparc . data . Roles . STUDY [ "read" ] . label } ` ) ,
193- this . tr ( `Something went wrong while demoting to ${ osparc . data . Roles . STUDY [ "read" ] . label } ` ) ,
172+ readAccessRole . accessRights ,
173+ this . tr ( `Successfully demoted to ${ readAccessRole . label } ` ) ,
174+ this . tr ( `Something went wrong while demoting to ${ readAccessRole . label } ` ) ,
194175 itm
195176 ) ;
196177 } ;
197178
198179 const organization = osparc . store . Groups . getInstance ( ) . getOrganization ( groupId ) ;
199180 if ( organization ) {
200- const msg = this . tr ( `Demoting to ${ osparc . data . Roles . STUDY [ "read" ] . label } will remove write access to all the members of the Organization. Are you sure?` ) ;
181+ const msg = this . tr ( `Demoting to ${ readAccessRole . label } will remove write access to all the members of the Organization. Are you sure?` ) ;
201182 const win = new osparc . ui . window . Confirmation ( msg ) . set ( {
202183 caption : this . tr ( "Demote" ) ,
203184 confirmAction : "delete" ,
@@ -216,11 +197,12 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
216197 } ,
217198
218199 _demoteToEditor : function ( collaborator , item ) {
200+ const writeAccessRole = osparc . data . Roles . STUDY [ "write" ] ;
219201 this . __make (
220202 collaborator [ "gid" ] ,
221- this . self ( ) . getCollaboratorAccessRight ( ) ,
222- this . tr ( `Successfully demoted to ${ osparc . data . Roles . STUDY [ "write" ] . label } ` ) ,
223- this . tr ( `Something went wrong while demoting to ${ osparc . data . Roles . STUDY [ "write" ] . label } ` ) ,
203+ writeAccessRole . accessRights ,
204+ this . tr ( `Successfully demoted to ${ writeAccessRole . label } ` ) ,
205+ this . tr ( `Something went wrong while demoting to ${ writeAccessRole . label } ` ) ,
224206 item
225207 ) ;
226208 } ,
0 commit comments