fix hui-panel-view for a "warning_multiple_cards" (#25899)

This commit is contained in:
ildar170975 2025-06-25 18:20:14 +03:00 committed by GitHub
parent 93df473ad2
commit 6006e926a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,8 +10,8 @@ import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
import type { HomeAssistant } from "../../../types"; import type { HomeAssistant } from "../../../types";
import type { HuiCard } from "../cards/hui-card"; import type { HuiCard } from "../cards/hui-card";
import type { HuiCardOptions } from "../components/hui-card-options"; import type { HuiCardOptions } from "../components/hui-card-options";
import type { HuiWarning } from "../components/hui-warning";
import type { Lovelace } from "../types"; import type { Lovelace } from "../types";
import "../../../components/ha-alert";
let editCodeLoaded = false; let editCodeLoaded = false;
@ -26,7 +26,7 @@ export class PanelView extends LitElement implements LovelaceViewElement {
@property({ attribute: false }) public cards: HuiCard[] = []; @property({ attribute: false }) public cards: HuiCard[] = [];
@state() private _card?: HuiCard | HuiWarning | HuiCardOptions; @state() private _card?: HuiCard | HuiCardOptions;
// eslint-disable-next-line @typescript-eslint/no-empty-function // eslint-disable-next-line @typescript-eslint/no-empty-function
public setConfig(_config: LovelaceViewConfig): void {} public setConfig(_config: LovelaceViewConfig): void {}
@ -63,11 +63,11 @@ export class PanelView extends LitElement implements LovelaceViewElement {
protected render(): TemplateResult { protected render(): TemplateResult {
return html` return html`
${this.cards!.length > 1 ${this.cards!.length > 1
? html`<hui-warning .hass=${this.hass}> ? html`<ha-alert alert-type="warning"
${this.hass!.localize( >${this.hass!.localize(
"ui.panel.lovelace.editor.view.panel_mode.warning_multiple_cards" "ui.panel.lovelace.editor.view.panel_mode.warning_multiple_cards"
)} )}</ha-alert
</hui-warning>` >`
: ""} : ""}
${this._card} ${this._card}
${this.lovelace?.editMode && this.cards.length === 0 ${this.lovelace?.editMode && this.cards.length === 0