@@ -9,12 +9,15 @@ import {
9
9
TemplateResult ,
10
10
} from 'lit-element' ;
11
11
import { until } from 'lit-html/directives/until' ;
12
- import { translate } from 'lit-translate' ;
12
+ import { get , translate } from 'lit-translate' ;
13
13
import { Mixin , newPendingStateEvent , ValidateEvent } from './foundation.js' ;
14
14
import { LoggingElement } from './Logging.js' ;
15
15
import { Plugin , PluggingElement , pluginIcons } from './Plugging.js' ;
16
16
import { SettingElement } from './Setting.js' ;
17
17
18
+ import { UserInfoEvent } from './foundation.js' ;
19
+ import { TextFieldBase } from '@material/mwc-textfield/mwc-textfield-base' ;
20
+
18
21
interface MenuItem {
19
22
icon : string ;
20
23
name : string ;
@@ -200,6 +203,14 @@ export function Hosting<
200
203
] ;
201
204
}
202
205
206
+ getNameField ( ) : TextFieldBase {
207
+ return < TextFieldBase > this . shadowRoot ! . querySelector ( 'span[id="userField"]' ) ;
208
+ }
209
+
210
+ private onUserInfo ( event : UserInfoEvent ) {
211
+ this . getNameField ( ) . textContent = get ( 'userinfo.loggedInAs' , { name : event . detail . name } ) ;
212
+ }
213
+
203
214
constructor ( ...args : any [ ] ) {
204
215
super ( ...args ) ;
205
216
@@ -216,6 +227,8 @@ export function Hosting<
216
227
} )
217
228
) ;
218
229
} ) ;
230
+
231
+ this . addEventListener ( 'userinfo' , this . onUserInfo ) ;
219
232
}
220
233
221
234
renderMenuItem ( me : MenuItem | 'divider' ) : TemplateResult {
@@ -288,6 +301,7 @@ export function Hosting<
288
301
@click =${ ( ) => ( this . menuUI . open = true ) }
289
302
> </ mwc-icon-button >
290
303
< div slot ="title " id ="title "> ${ this . docName } </ div >
304
+ < span id ="userField " slot ="actionItems "> </ span >
291
305
${ this . menu . map ( this . renderActionItem ) }
292
306
${ this . doc
293
307
? html `< mwc-tab-bar
0 commit comments