Skip to content

Commit a9c816e

Browse files
silamonMindFreeze
andauthored
Migrate analytics dropdown to ha-dropdown (#28038)
* Migrate analytics dropdown * Apply suggestion from @MindFreeze * Apply suggestion from @MindFreeze --------- Co-authored-by: Petar Petrov <[email protected]>
1 parent c3201ee commit a9c816e

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

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

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { mdiDotsVertical, mdiDownload } from "@mdi/js";
22
import type { TemplateResult } from "lit";
33
import { css, html, LitElement, nothing } from "lit";
44
import { customElement, property } from "lit/decorators";
5-
import "../../../components/ha-button-menu";
65
import "../../../components/ha-icon-button";
7-
import "../../../components/ha-list-item";
86
import "../../../components/ha-svg-icon";
97
import { getSignedPath } from "../../../data/auth";
108
import "../../../layouts/hass-subpage";
@@ -14,6 +12,8 @@ import {
1412
downloadFileSupported,
1513
fileDownload,
1614
} from "../../../util/file_download";
15+
import "../../../components/ha-dropdown-item";
16+
import "../../../components/ha-dropdown";
1717

1818
@customElement("ha-config-section-analytics")
1919
class HaConfigSectionAnalytics extends LitElement {
@@ -33,22 +33,19 @@ class HaConfigSectionAnalytics extends LitElement {
3333
>
3434
${downloadFileSupported(this.hass)
3535
? html`
36-
<ha-button-menu
37-
@action=${this._handleOverflowAction}
36+
<ha-dropdown
37+
@wa-select=${this._handleOverflowAction}
3838
slot="toolbar-icon"
3939
>
4040
<ha-icon-button slot="trigger" .path=${mdiDotsVertical}>
4141
</ha-icon-button>
42-
<ha-list-item graphic="icon">
43-
<ha-svg-icon
44-
slot="graphic"
45-
.path=${mdiDownload}
46-
></ha-svg-icon>
42+
<ha-dropdown-item .value=${"download_device_info"}>
43+
<ha-svg-icon slot="icon" .path=${mdiDownload}></ha-svg-icon>
4744
${this.hass.localize(
4845
"ui.panel.config.analytics.download_device_info"
4946
)}
50-
</ha-list-item>
51-
</ha-button-menu>
47+
</ha-dropdown-item>
48+
</ha-dropdown>
5249
`
5350
: nothing}
5451
<div class="content">
@@ -58,9 +55,16 @@ class HaConfigSectionAnalytics extends LitElement {
5855
`;
5956
}
6057

61-
private async _handleOverflowAction(): Promise<void> {
62-
const signedPath = await getSignedPath(this.hass, "/api/analytics/devices");
63-
fileDownload(signedPath.path);
58+
private async _handleOverflowAction(
59+
ev: CustomEvent<{ item: { value: string } }>
60+
): Promise<void> {
61+
if (ev.detail.item.value === "download_device_info") {
62+
const signedPath = await getSignedPath(
63+
this.hass,
64+
"/api/analytics/devices"
65+
);
66+
fileDownload(signedPath.path);
67+
}
6468
}
6569

6670
static styles = css`

0 commit comments

Comments
 (0)