mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Make "button row" name optional to be consistent with "button card" and "buttons row" (#8189)
This commit is contained in:
parent
9e99d158fd
commit
599dd81e3c
@ -10,6 +10,8 @@ import {
|
|||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { DOMAINS_TOGGLE } from "../../../common/const";
|
import { DOMAINS_TOGGLE } from "../../../common/const";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
|
import { stateIcon } from "../../../common/entity/state_icon";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
@ -29,8 +31,8 @@ export class HuiButtonRow extends LitElement implements LovelaceRow {
|
|||||||
throw new Error("Invalid configuration");
|
throw new Error("Invalid configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.name) {
|
if (!config.name && !config.entity) {
|
||||||
throw new Error("No name specified");
|
throw new Error("No name and no entity specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
this._config = {
|
this._config = {
|
||||||
@ -50,10 +52,21 @@ export class HuiButtonRow extends LitElement implements LovelaceRow {
|
|||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const stateObj =
|
||||||
|
this._config.entity && this.hass
|
||||||
|
? this.hass.states[this._config.entity]
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-icon .icon=${this._config.icon || "hass:remote"}></ha-icon>
|
<ha-icon
|
||||||
|
.icon=${this._config.icon ||
|
||||||
|
(stateObj ? stateIcon(stateObj) : "hass:remote")}
|
||||||
|
>
|
||||||
|
</ha-icon>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<div>${this._config.name}</div>
|
<div>
|
||||||
|
${this._config.name || (stateObj ? computeStateName(stateObj) : "")}
|
||||||
|
</div>
|
||||||
<mwc-button
|
<mwc-button
|
||||||
@action=${this._handleAction}
|
@action=${this._handleAction}
|
||||||
.actionHandler=${actionHandler({
|
.actionHandler=${actionHandler({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user