Fix integration card rename dialog logic (#9467)

This commit is contained in:
Philip Allgaier 2021-06-29 15:00:27 +02:00 committed by GitHub
parent 43503ba085
commit 4665db4f27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -303,7 +303,7 @@ export class HaIntegrationCard extends LitElement {
> >
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon> <ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
</mwc-icon-button> </mwc-icon-button>
<mwc-list-item @request-selected="${this._editEntryName}"> <mwc-list-item @request-selected="${this._handleRename}">
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.integrations.config_entry.rename" "ui.panel.config.integrations.config_entry.rename"
)} )}
@ -420,6 +420,15 @@ export class HaIntegrationCard extends LitElement {
showOptionsFlowDialog(this, ev.target.closest("ha-card").configEntry); showOptionsFlowDialog(this, ev.target.closest("ha-card").configEntry);
} }
private _handleRename(ev: CustomEvent<RequestSelectedDetail>): void {
if (!shouldHandleRequestSelectedEvent(ev)) {
return;
}
this._editEntryName(
((ev.target as HTMLElement).closest("ha-card") as any).configEntry
);
}
private _handleReload(ev: CustomEvent<RequestSelectedDetail>): void { private _handleReload(ev: CustomEvent<RequestSelectedDetail>): void {
if (!shouldHandleRequestSelectedEvent(ev)) { if (!shouldHandleRequestSelectedEvent(ev)) {
return; return;
@ -578,8 +587,7 @@ export class HaIntegrationCard extends LitElement {
}); });
} }
private async _editEntryName(ev) { private async _editEntryName(configEntry: ConfigEntry) {
const configEntry = ev.target.closest("ha-card").configEntry;
const newName = await showPromptDialog(this, { const newName = await showPromptDialog(this, {
title: this.hass.localize("ui.panel.config.integrations.rename_dialog"), title: this.hass.localize("ui.panel.config.integrations.rename_dialog"),
defaultValue: configEntry.title, defaultValue: configEntry.title,