mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 23:36:36 +00:00
Add default actions to button row (#7026)
This commit is contained in:
parent
a8a1563586
commit
ad34f98e6d
@ -4,10 +4,12 @@ import {
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
internalProperty,
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { DOMAINS_TOGGLE } from "../../../common/const";
|
||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||
import "../../../components/ha-icon";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
@ -31,11 +33,16 @@ export class HuiButtonRow extends LitElement implements LovelaceRow {
|
||||
throw new Error("Error in card configuration. No name specified.");
|
||||
}
|
||||
|
||||
if (!config.tap_action) {
|
||||
throw new Error("Error in card configuration. No action specified.");
|
||||
}
|
||||
|
||||
this._config = config;
|
||||
this._config = {
|
||||
tap_action: {
|
||||
action:
|
||||
config.entity && DOMAINS_TOGGLE.has(computeDomain(config.entity))
|
||||
? "toggle"
|
||||
: "more-info",
|
||||
},
|
||||
hold_action: { action: "more-info" },
|
||||
...config,
|
||||
};
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
|
Loading…
x
Reference in New Issue
Block a user