@@ -5,32 +5,48 @@ import { Dialog, ReactWidget, showDialog } from '@jupyterlab/apputils';
5
5
6
6
import { ServerConnection , User } from '@jupyterlab/services' ;
7
7
8
+ import { URLExt } from '@jupyterlab/coreutils' ;
9
+
10
+ import { IRenderMime } from '@jupyterlab/rendermime-interfaces' ;
11
+
8
12
import { Panel } from '@lumino/widgets' ;
9
13
10
14
import * as React from 'react' ;
11
15
12
16
import { 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
+ } ;
14
25
15
26
export class UserInfoPanel extends Panel {
16
27
private _profile : User . IManager ;
17
28
private _body : UserInfoBody | null ;
18
29
19
- constructor ( user : User . IManager ) {
30
+ constructor ( options : UserInfoProps ) {
20
31
super ( { } ) ;
21
32
this . addClass ( 'jp-UserInfoPanel' ) ;
22
-
23
- this . _profile = user ;
33
+ this . _profile = options . userManager ;
24
34
this . _body = null ;
25
35
26
36
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
+ } ) ;
28
41
this . addWidget ( this . _body ) ;
29
42
this . update ( ) ;
30
43
} else {
31
44
this . _profile . ready
32
45
. then ( ( ) => {
33
- this . _body = new UserInfoBody ( { userManager : this . _profile } ) ;
46
+ this . _body = new UserInfoBody ( {
47
+ userManager : this . _profile ,
48
+ translation : options . translation
49
+ } ) ;
34
50
this . addWidget ( this . _body ) ;
35
51
this . update ( ) ;
36
52
} )
@@ -39,13 +55,6 @@ export class UserInfoPanel extends Panel {
39
55
}
40
56
}
41
57
42
- /**
43
- * The properties for the UserInfoBody.
44
- */
45
- type UserInfoBodyProps = {
46
- userManager : User . IManager ;
47
- } ;
48
-
49
58
/**
50
59
* A SettingsWidget for the user.
51
60
*/
@@ -54,13 +63,14 @@ export class UserInfoBody
54
63
implements Dialog . IBodyWidget < User . IManager >
55
64
{
56
65
private _userManager : User . IManager ;
57
-
66
+ private _translation : IRenderMime . TranslationBundle ;
58
67
/**
59
68
* Constructs a new settings widget.
60
69
*/
61
- constructor ( props : UserInfoBodyProps ) {
70
+ constructor ( props : UserInfoProps ) {
62
71
super ( ) ;
63
72
this . _userManager = props . userManager ;
73
+ this . _translation = props . translation ;
64
74
}
65
75
66
76
get user ( ) : User . IManager {
@@ -80,7 +90,7 @@ export class UserInfoBody
80
90
body : new UserDetailsBody ( {
81
91
userManager : this . _userManager
82
92
} ) ,
83
- title : 'User Details'
93
+ title : this . _translation . __ ( 'User Details' )
84
94
} ) . then ( async result => {
85
95
if ( result . button . accept ) {
86
96
// Call the Jupyter Server API to update the user field
@@ -100,7 +110,8 @@ export class UserInfoBody
100
110
}
101
111
102
112
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 ) ;
104
115
}
105
116
106
117
// Refresh user information
0 commit comments