Skip to content

Commit ba9bab3

Browse files
silamonMindFreeze
andauthored
Migrate updates dropdown to ha-dropdown (#28039)
* Migrate upgrade dropdown * Apply suggestion from @MindFreeze * Update src/panels/config/core/ha-config-section-updates.ts --------- Co-authored-by: Petar Petrov <[email protected]>
1 parent 085b388 commit ba9bab3

File tree

1 file changed

+27
-36
lines changed

1 file changed

+27
-36
lines changed

src/panels/config/core/ha-config-section-updates.ts

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
import type { RequestSelectedDetail } from "@material/mwc-list/mwc-list-item";
21
import { mdiDotsVertical, mdiRefresh } from "@mdi/js";
32
import type { HassEntities } from "home-assistant-js-websocket";
43
import type { TemplateResult } from "lit";
54
import { LitElement, css, html } from "lit";
65
import { customElement, property, state } from "lit/decorators";
76
import memoizeOne from "memoize-one";
87
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
9-
import { shouldHandleRequestSelectedEvent } from "../../../common/mwc/handle-request-selected-event";
108
import "../../../components/ha-alert";
119
import "../../../components/ha-bar";
12-
import "../../../components/ha-button-menu";
1310
import "../../../components/ha-card";
14-
import "../../../components/ha-check-list-item";
15-
import "../../../components/ha-list-item";
1611
import "../../../components/ha-metric";
1712
import { extractApiErrorMessage } from "../../../data/hassio/common";
1813
import type {
@@ -33,6 +28,9 @@ import "../../../layouts/hass-subpage";
3328
import type { HomeAssistant } from "../../../types";
3429
import "../dashboard/ha-config-updates";
3530
import { showJoinBetaDialog } from "./updates/show-dialog-join-beta";
31+
import "../../../components/ha-dropdown";
32+
import "../../../components/ha-dropdown-item";
33+
import "@home-assistant/webawesome/dist/components/divider/divider";
3634

3735
@customElement("ha-config-section-updates")
3836
class HaConfigSectionUpdates extends LitElement {
@@ -73,35 +71,36 @@ class HaConfigSectionUpdates extends LitElement {
7371
.path=${mdiRefresh}
7472
@click=${this._checkUpdates}
7573
></ha-icon-button>
76-
<ha-button-menu multi>
74+
<ha-dropdown @wa-select=${this._handleOverflowAction}>
7775
<ha-icon-button
7876
slot="trigger"
7977
.label=${this.hass.localize("ui.common.menu")}
8078
.path=${mdiDotsVertical}
8179
></ha-icon-button>
82-
<ha-check-list-item
83-
left
84-
@request-selected=${this._toggleSkipped}
85-
.selected=${this._showSkipped}
80+
81+
<ha-dropdown-item
82+
type="checkbox"
83+
value="show_skipped"
84+
.checked=${this._showSkipped}
8685
>
8786
${this.hass.localize("ui.panel.config.updates.show_skipped")}
88-
</ha-check-list-item>
87+
</ha-dropdown-item>
8988
${this._supervisorInfo
9089
? html`
91-
<li divider role="separator"></li>
92-
<ha-list-item
93-
@request-selected=${this._toggleBeta}
90+
<wa-divider></wa-divider>
91+
<ha-dropdown-item
92+
value="toggle_beta"
9493
.disabled=${this._supervisorInfo.channel === "dev"}
9594
>
9695
${this._supervisorInfo.channel === "stable"
9796
? this.hass.localize("ui.panel.config.updates.join_beta")
9897
: this.hass.localize(
9998
"ui.panel.config.updates.leave_beta"
10099
)}
101-
</ha-list-item>
100+
</ha-dropdown-item>
102101
`
103102
: ""}
104-
</ha-button-menu>
103+
</ha-dropdown>
105104
</div>
106105
<div class="content">
107106
<ha-card outlined>
@@ -133,27 +132,19 @@ class HaConfigSectionUpdates extends LitElement {
133132
this._supervisorInfo = await fetchHassioSupervisorInfo(this.hass);
134133
}
135134

136-
private _toggleSkipped(ev: CustomEvent<RequestSelectedDetail>): void {
137-
if (ev.detail.source !== "property") {
138-
return;
139-
}
140-
141-
this._showSkipped = !this._showSkipped;
142-
}
143-
144-
private async _toggleBeta(
145-
ev: CustomEvent<RequestSelectedDetail>
135+
private async _handleOverflowAction(
136+
ev: CustomEvent<{ item: { value: string } }>
146137
): Promise<void> {
147-
if (!shouldHandleRequestSelectedEvent(ev)) {
148-
return;
149-
}
150-
151-
if (this._supervisorInfo!.channel === "stable") {
152-
showJoinBetaDialog(this, {
153-
join: async () => this._setChannel("beta"),
154-
});
155-
} else {
156-
this._setChannel("stable");
138+
if (ev.detail.item.value === "toggle_beta") {
139+
if (this._supervisorInfo!.channel === "stable") {
140+
showJoinBetaDialog(this, {
141+
join: async () => this._setChannel("beta"),
142+
});
143+
} else {
144+
this._setChannel("stable");
145+
}
146+
} else if (ev.detail.item.value === "show_skipped") {
147+
this._showSkipped = !this._showSkipped;
157148
}
158149
}
159150

0 commit comments

Comments
 (0)