mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16: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,
|
CSSResult,
|
||||||
customElement,
|
customElement,
|
||||||
html,
|
html,
|
||||||
LitElement,
|
|
||||||
internalProperty,
|
internalProperty,
|
||||||
|
LitElement,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
import { DOMAINS_TOGGLE } from "../../../common/const";
|
||||||
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
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";
|
||||||
@ -31,11 +33,16 @@ export class HuiButtonRow extends LitElement implements LovelaceRow {
|
|||||||
throw new Error("Error in card configuration. No name specified.");
|
throw new Error("Error in card configuration. No name specified.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.tap_action) {
|
this._config = {
|
||||||
throw new Error("Error in card configuration. No action specified.");
|
tap_action: {
|
||||||
}
|
action:
|
||||||
|
config.entity && DOMAINS_TOGGLE.has(computeDomain(config.entity))
|
||||||
this._config = config;
|
? "toggle"
|
||||||
|
: "more-info",
|
||||||
|
},
|
||||||
|
hold_action: { action: "more-info" },
|
||||||
|
...config,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user