Skip to content

Commit 1be16f1

Browse files
committed
Migrate upgrade dropdown
1 parent be31950 commit 1be16f1

File tree

1 file changed

+27
-33
lines changed

1 file changed

+27
-33
lines changed

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

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
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";
1210
import "../../../components/ha-button-menu";
@@ -33,6 +31,9 @@ import "../../../layouts/hass-subpage";
3331
import type { HomeAssistant } from "../../../types";
3432
import "../dashboard/ha-config-updates";
3533
import { showJoinBetaDialog } from "./updates/show-dialog-join-beta";
34+
import "../../../components/ha-dropdown";
35+
import "../../../components/ha-dropdown-item";
36+
import "@home-assistant/webawesome/dist/components/divider/divider";
3637

3738
@customElement("ha-config-section-updates")
3839
class HaConfigSectionUpdates extends LitElement {
@@ -73,35 +74,36 @@ class HaConfigSectionUpdates extends LitElement {
7374
.path=${mdiRefresh}
7475
@click=${this._checkUpdates}
7576
></ha-icon-button>
76-
<ha-button-menu multi>
77+
<ha-dropdown @wa-select=${this._handleOverflowAction}>
7778
<ha-icon-button
7879
slot="trigger"
7980
.label=${this.hass.localize("ui.common.menu")}
8081
.path=${mdiDotsVertical}
8182
></ha-icon-button>
82-
<ha-check-list-item
83-
left
84-
@request-selected=${this._toggleSkipped}
85-
.selected=${this._showSkipped}
83+
84+
<ha-dropdown-item
85+
type="checkbox"
86+
value="show_skipped"
87+
.checked=${this._showSkipped}
8688
>
8789
${this.hass.localize("ui.panel.config.updates.show_skipped")}
88-
</ha-check-list-item>
90+
</ha-dropdown-item>
8991
${this._supervisorInfo
9092
? html`
91-
<li divider role="separator"></li>
92-
<ha-list-item
93-
@request-selected=${this._toggleBeta}
93+
<wa-divider></wa-divider>
94+
<ha-dropdown-item
95+
value="toggle_beta"
9496
.disabled=${this._supervisorInfo.channel === "dev"}
9597
>
9698
${this._supervisorInfo.channel === "stable"
9799
? this.hass.localize("ui.panel.config.updates.join_beta")
98100
: this.hass.localize(
99101
"ui.panel.config.updates.leave_beta"
100102
)}
101-
</ha-list-item>
103+
</ha-dropdown-item>
102104
`
103105
: ""}
104-
</ha-button-menu>
106+
</ha-dropdown>
105107
</div>
106108
<div class="content">
107109
<ha-card outlined>
@@ -133,27 +135,19 @@ class HaConfigSectionUpdates extends LitElement {
133135
this._supervisorInfo = await fetchHassioSupervisorInfo(this.hass);
134136
}
135137

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>
138+
private async _handleOverflowAction(
139+
ev: CustomEvent<{ item: { value: string } }>
146140
): 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");
141+
if (ev.detail.item.value === "toggle_beta") {
142+
if (this._supervisorInfo!.channel === "stable") {
143+
showJoinBetaDialog(this, {
144+
join: async () => this._setChannel("beta"),
145+
});
146+
} else {
147+
this._setChannel("stable");
148+
}
149+
} else if (ev.detail.item.value === "show_skipped") {
150+
this._showSkipped = !this._showSkipped;
157151
}
158152
}
159153

0 commit comments

Comments
 (0)