Skip to content

Commit dcbac1e

Browse files
author
Rob Tjalma
committed
Added improved UserInfo display
Signed-off-by: Rob Tjalma <[email protected]>
1 parent a72b8a4 commit dcbac1e

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

__snapshots__/open-scd.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,6 @@
394394
slot="title"
395395
>
396396
</div>
397-
<span
398-
id="userField"
399-
slot="actionItems"
400-
>
401-
</span>
402397
<mwc-icon-button
403398
disabled=""
404399
icon="undo"

src/Hosting.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { SettingElement } from './Setting.js';
1717

1818
import { UserInfoEvent } from './foundation.js';
1919
import { TextFieldBase } from '@material/mwc-textfield/mwc-textfield-base';
20+
import { string } from 'fast-check';
2021

2122
interface MenuItem {
2223
icon: string;
@@ -52,6 +53,9 @@ export function Hosting<
5253
@property({ attribute: false })
5354
validated: Promise<unknown> = Promise.resolve();
5455

56+
@property({ type: string})
57+
username: string | undefined;
58+
5559
@internalProperty()
5660
statusNumber = 0;
5761

@@ -203,12 +207,8 @@ export function Hosting<
203207
];
204208
}
205209

206-
getNameField() : TextFieldBase {
207-
return <TextFieldBase>this.shadowRoot!.querySelector('span[id="userField"]');
208-
}
209-
210210
private onUserInfo(event: UserInfoEvent) {
211-
this.getNameField().textContent = get('userinfo.loggedInAs', {name: event.detail.name});
211+
this.username = event.detail.name;
212212
}
213213

214214
constructor(...args: any[]) {
@@ -301,7 +301,9 @@ export function Hosting<
301301
@click=${() => (this.menuUI.open = true)}
302302
></mwc-icon-button>
303303
<div slot="title" id="title">${this.docName}</div>
304-
<span id="userField" slot="actionItems"></span>
304+
${this.username != undefined
305+
? html`<span id="userField" slot="actionItems">${translate('userinfo.loggedInAs', {name: this.username})}</span>`
306+
: ``}
305307
${this.menu.map(this.renderActionItem)}
306308
${this.doc
307309
? html`<mwc-tab-bar

0 commit comments

Comments
 (0)