@@ -109,26 +109,24 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", {
109109 osparc . data . Resources . get ( "apiKeys" )
110110 . then ( apiKeys => {
111111 apiKeys . forEach ( apiKey => {
112- const apiKeyForm = this . __createValidAPIKeyForm ( apiKey ) ;
112+ const apiKeyForm = this . __createAPIKeyEntry ( apiKey ) ;
113113 this . __apiKeysList . add ( apiKeyForm ) ;
114114 } ) ;
115115 } )
116116 . catch ( err => console . error ( err ) ) ;
117117 } ,
118118
119- __createValidAPIKeyForm : function ( apiKeyLabel ) {
119+ __createAPIKeyEntry : function ( apiKey ) {
120120 const grid = this . __createValidEntryLayout ( ) ;
121121
122- const nameLabel = new qx . ui . basic . Label ( apiKeyLabel ) ;
122+ const nameLabel = new qx . ui . basic . Label ( apiKey [ "display_name" ] ) ;
123123 grid . add ( nameLabel , {
124124 row : 0 ,
125125 column : 0
126126 } ) ;
127127
128128 const delAPIKeyBtn = new qx . ui . form . Button ( null , "@FontAwesome5Solid/trash/14" ) ;
129- delAPIKeyBtn . addListener ( "execute" , e => {
130- this . __deleteAPIKey ( apiKeyLabel ) ;
131- } , this ) ;
129+ delAPIKeyBtn . addListener ( "execute" , ( ) => this . __deleteAPIKey ( apiKey [ "id" ] ) , this ) ;
132130 grid . add ( delAPIKeyBtn , {
133131 row : 0 ,
134132 column : 1
@@ -137,7 +135,7 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", {
137135 return grid ;
138136 } ,
139137
140- __deleteAPIKey : function ( apiKeyLabel ) {
138+ __deleteAPIKey : function ( apiKeyId ) {
141139 if ( ! osparc . data . Permissions . getInstance ( ) . canDo ( "user.apikey.delete" , true ) ) {
142140 return ;
143141 }
@@ -153,13 +151,17 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", {
153151 win . addListener ( "close" , ( ) => {
154152 if ( win . getConfirmed ( ) ) {
155153 const params = {
156- data : {
157- "display_name " : apiKeyLabel
154+ url : {
155+ "apiKeyId " : apiKeyId
158156 }
159157 } ;
160158 osparc . data . Resources . fetch ( "apiKeys" , "delete" , params )
161159 . then ( ( ) => this . __rebuildAPIKeysList ( ) )
162- . catch ( err => console . error ( err ) ) ;
160+ . catch ( err => {
161+ const errorMsg = err . message || this . tr ( "Cannot delete API Key" ) ;
162+ osparc . FlashMessenger . getInstance ( ) . logAs ( errorMsg , "ERROR" ) ;
163+ console . error ( err )
164+ } ) ;
163165 }
164166 } , this ) ;
165167 } ,
@@ -203,7 +205,7 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", {
203205 const supportedExternalServices = osparc . utils . Utils . deepCloneObject ( this . __supportedExternalServices ( ) ) ;
204206
205207 tokensList . forEach ( token => {
206- const tokenForm = this . __createValidTokenEntry ( token ) ;
208+ const tokenForm = this . __createTokenEntry ( token ) ;
207209 this . __validTokensGB . add ( tokenForm ) ;
208210 const idx = supportedExternalServices . findIndex ( srv => srv . name === token . service ) ;
209211 if ( idx > - 1 ) {
@@ -244,7 +246,7 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", {
244246 . catch ( err => console . error ( err ) ) ;
245247 } ,
246248
247- __createValidTokenEntry : function ( token ) {
249+ __createTokenEntry : function ( token ) {
248250 const grid = this . __createValidEntryLayout ( ) ;
249251
250252 const service = token [ "service" ] ;
0 commit comments