@@ -5,32 +5,48 @@ import { Dialog, ReactWidget, showDialog } from '@jupyterlab/apputils';
55
66import { ServerConnection , User } from '@jupyterlab/services' ;
77
8+ import { URLExt } from '@jupyterlab/coreutils' ;
9+
10+ import { IRenderMime } from '@jupyterlab/rendermime-interfaces' ;
11+
812import { Panel } from '@lumino/widgets' ;
913
1014import * as React from 'react' ;
1115
1216import { UserDetailsBody , UserIconComponent } from './components' ;
13- import { URLExt } from '@jupyterlab/coreutils' ;
17+
18+ /**
19+ * The properties for the UserInfoBody.
20+ */
21+ type UserInfoProps = {
22+ userManager : User . IManager ;
23+ translation : IRenderMime . TranslationBundle ;
24+ } ;
1425
1526export class UserInfoPanel extends Panel {
1627 private _profile : User . IManager ;
1728 private _body : UserInfoBody | null ;
1829
19- constructor ( user : User . IManager ) {
30+ constructor ( options : UserInfoProps ) {
2031 super ( { } ) ;
2132 this . addClass ( 'jp-UserInfoPanel' ) ;
22-
23- this . _profile = user ;
33+ this . _profile = options . userManager ;
2434 this . _body = null ;
2535
2636 if ( this . _profile . isReady ) {
27- this . _body = new UserInfoBody ( { userManager : this . _profile } ) ;
37+ this . _body = new UserInfoBody ( {
38+ userManager : this . _profile ,
39+ translation : options . translation
40+ } ) ;
2841 this . addWidget ( this . _body ) ;
2942 this . update ( ) ;
3043 } else {
3144 this . _profile . ready
3245 . then ( ( ) => {
33- this . _body = new UserInfoBody ( { userManager : this . _profile } ) ;
46+ this . _body = new UserInfoBody ( {
47+ userManager : this . _profile ,
48+ translation : options . translation
49+ } ) ;
3450 this . addWidget ( this . _body ) ;
3551 this . update ( ) ;
3652 } )
@@ -39,13 +55,6 @@ export class UserInfoPanel extends Panel {
3955 }
4056}
4157
42- /**
43- * The properties for the UserInfoBody.
44- */
45- type UserInfoBodyProps = {
46- userManager : User . IManager ;
47- } ;
48-
4958/**
5059 * A SettingsWidget for the user.
5160 */
@@ -54,13 +63,14 @@ export class UserInfoBody
5463 implements Dialog . IBodyWidget < User . IManager >
5564{
5665 private _userManager : User . IManager ;
57-
66+ private _translation : IRenderMime . TranslationBundle ;
5867 /**
5968 * Constructs a new settings widget.
6069 */
61- constructor ( props : UserInfoBodyProps ) {
70+ constructor ( props : UserInfoProps ) {
6271 super ( ) ;
6372 this . _userManager = props . userManager ;
73+ this . _translation = props . translation ;
6474 }
6575
6676 get user ( ) : User . IManager {
@@ -80,7 +90,7 @@ export class UserInfoBody
8090 body : new UserDetailsBody ( {
8191 userManager : this . _userManager
8292 } ) ,
83- title : 'User Details'
93+ title : this . _translation . __ ( 'User Details' )
8494 } ) . then ( async result => {
8595 if ( result . button . accept ) {
8696 // Call the Jupyter Server API to update the user field
@@ -100,7 +110,8 @@ export class UserInfoBody
100110 }
101111
102112 if ( ! response . ok ) {
103- throw new Error ( 'Failed to update user data' ) ;
113+ const errorMsg = this . _translation . __ ( 'Failed to update user data' ) ;
114+ throw new Error ( errorMsg ) ;
104115 }
105116
106117 // Refresh user information
0 commit comments