Use action button text name for empty state card (#28948)

This commit is contained in:
Paul Bottein
2026-01-12 17:42:01 +01:00
committed by GitHub
parent c551bf03b6
commit 50be1d9345
5 changed files with 8 additions and 8 deletions

View File

@ -55,10 +55,10 @@ export class HuiEmptyStateCard extends LitElement implements LovelaceCard {
${this._config.content
? html`<p>${this._config.content}</p>`
: nothing}
${this._config.tap_action && this._config.action_label
${this._config.tap_action && this._config.action_button_text
? html`
<ha-button @click=${this._handleAction}>
${this._config.action_label}
${this._config.action_button_text}
</ha-button>
`
: nothing}

View File

@ -62,7 +62,7 @@ export interface EmptyStateCardConfig extends LovelaceCardConfig {
icon?: string;
title?: string;
content?: string;
action_label?: string;
action_button_text?: string;
tap_action?: ActionConfig;
}

View File

@ -23,7 +23,7 @@ const cardConfigStruct = assign(
icon: optional(string()),
title: optional(string()),
content: optional(string()),
action_label: optional(string()),
action_button_text: optional(string()),
tap_action: optional(actionConfigStruct),
})
);
@ -78,7 +78,7 @@ export class HuiEmptyStateCardEditor
flatten: true,
iconPath: mdiGestureTap,
schema: [
{ name: "action_label", selector: { text: {} } },
{ name: "action_button_text", selector: { text: {} } },
{
name: "tap_action",
selector: {
@ -134,7 +134,7 @@ export class HuiEmptyStateCardEditor
switch (schema.name) {
case "style":
case "content":
case "action_label":
case "action_button_text":
return this.hass!.localize(
`ui.panel.lovelace.editor.card.empty_state.${schema.name}`
);

View File

@ -80,7 +80,7 @@ export class OriginalStatesViewStrategy extends ReactiveElement {
),
...(hass.user?.is_admin
? {
action_label: hass.localize(
action_button_text: hass.localize(
"ui.panel.lovelace.strategy.original-states.empty_state_action"
),
tap_action: {

View File

@ -7992,7 +7992,7 @@
"content-only": "Content only"
},
"content": "Content",
"action_label": "Action label"
"action_text": "Action button text"
},
"button": {
"name": "Button",