Update thread-config-panel.ts

This commit is contained in:
Bram Kragten 2023-08-16 10:01:50 +02:00
parent 05e08cdcc0
commit b19fe68686

View File

@ -164,14 +164,15 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
})} })}
</h4> </h4>
</div> </div>
${network.routers.map( ${network.routers.map((router) => {
(router) => const showOverflow =
html`<ha-list-item ("dataset" in network && router.border_agent_id) ||
router.extended_address === this._otbrInfo?.extended_address;
return html`<ha-list-item
class="router" class="router"
twoline twoline
graphic="avatar" graphic="avatar"
.hasMeta=${("dataset" in network && router.border_agent_id) || .hasMeta=${showOverflow}
router.extended_address === this._otbrInfo?.extended_address}
> >
<img <img
slot="graphic" slot="graphic"
@ -190,8 +191,7 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
router.server?.replace(".local.", "") || router.server?.replace(".local.", "") ||
""} ""}
<span slot="secondary">${router.server}</span> <span slot="secondary">${router.server}</span>
${(network.dataset && router.border_agent_id) || ${showOverflow
router.extended_address === this._otbrInfo?.extended_address
? html`${network.dataset && ? html`${network.dataset &&
router.border_agent_id === router.border_agent_id ===
network.dataset.preferred_border_agent_id network.dataset.preferred_border_agent_id
@ -231,14 +231,7 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
: ""} : ""}
${router.extended_address === ${router.extended_address ===
this._otbrInfo?.extended_address this._otbrInfo?.extended_address
? html`<ha-icon-button ? html`<ha-list-item>
.label=${this.hass.localize(
"ui.common.overflow_menu"
)}
.path=${mdiDotsVertical}
slot="trigger"
></ha-icon-button>
<ha-list-item>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.thread.reset_border_router" "ui.panel.config.thread.reset_border_router"
)}</ha-list-item )}</ha-list-item
@ -258,8 +251,8 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
: ""} : ""}
</ha-button-menu>` </ha-button-menu>`
: ""} : ""}
</ha-list-item>` </ha-list-item>`;
)}` })}`
: html`<div class="card-content no-routers"> : html`<div class="card-content no-routers">
<ha-svg-icon .path=${mdiDevices}></ha-svg-icon> <ha-svg-icon .path=${mdiDevices}></ha-svg-icon>
${network.dataset?.extended_pan_id && ${network.dataset?.extended_pan_id &&
@ -509,7 +502,7 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
) { ) {
const datasetId = dataset.dataset_id; const datasetId = dataset.dataset_id;
const borderAgentId = router.border_agent_id; const borderAgentId = router.border_agent_id;
if (!router.border_agent_id) { if (!borderAgentId) {
return; return;
} }
await setPreferredBorderAgent(this.hass, datasetId, borderAgentId); await setPreferredBorderAgent(this.hass, datasetId, borderAgentId);