mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Rename service button to action button (#21511)
This commit is contained in:
parent
3a83cb36a1
commit
574fc99889
@ -717,7 +717,7 @@ export class HaServiceControl extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const value = {
|
const value = {
|
||||||
service: newService,
|
action: newService,
|
||||||
target,
|
target,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,5 +18,9 @@ const ALWAYS_LOADED_TYPES = new Set([
|
|||||||
"state-label",
|
"state-label",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const createHuiElement = (config: LovelaceElementConfig) =>
|
export const createHuiElement = (config: LovelaceElementConfig) => {
|
||||||
createLovelaceElement("element", config, ALWAYS_LOADED_TYPES);
|
if (config.type === "action-button") {
|
||||||
|
config = { ...config, type: "service-button" };
|
||||||
|
}
|
||||||
|
return createLovelaceElement("element", config, ALWAYS_LOADED_TYPES);
|
||||||
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { any, assert, literal, object, optional, string } from "superstruct";
|
import { any, assert, enums, object, optional, string } from "superstruct";
|
||||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||||
import "../../../../../components/ha-form/ha-form";
|
import "../../../../../components/ha-form/ha-form";
|
||||||
import type { SchemaUnion } from "../../../../../components/ha-form/types";
|
import type { SchemaUnion } from "../../../../../components/ha-form/types";
|
||||||
@ -12,7 +12,7 @@ import { ServiceButtonElementConfig } from "../../../elements/types";
|
|||||||
import { LovelacePictureElementEditor } from "../../../types";
|
import { LovelacePictureElementEditor } from "../../../types";
|
||||||
|
|
||||||
const serviceButtonElementConfigStruct = object({
|
const serviceButtonElementConfigStruct = object({
|
||||||
type: literal("service-button"),
|
type: enums(["service-button", "action-button"]),
|
||||||
style: optional(any()),
|
style: optional(any()),
|
||||||
title: optional(string()),
|
title: optional(string()),
|
||||||
action: optional(string()),
|
action: optional(string()),
|
||||||
|
@ -31,7 +31,7 @@ const elementTypes: string[] = [
|
|||||||
"state-badge",
|
"state-badge",
|
||||||
"state-icon",
|
"state-icon",
|
||||||
"state-label",
|
"state-label",
|
||||||
"service-button",
|
"action-button",
|
||||||
"icon",
|
"icon",
|
||||||
"image",
|
"image",
|
||||||
"conditional",
|
"conditional",
|
||||||
@ -141,9 +141,13 @@ export class HuiPictureElementsCardRowEditor extends LitElement {
|
|||||||
).entity ??
|
).entity ??
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
|
case "action-button":
|
||||||
case "service-button":
|
case "service-button":
|
||||||
return (
|
return (
|
||||||
element.title ?? (element as ServiceButtonElementConfig).service ?? ""
|
element.title ??
|
||||||
|
(element as ServiceButtonElementConfig).action ??
|
||||||
|
(element as ServiceButtonElementConfig).service ??
|
||||||
|
""
|
||||||
);
|
);
|
||||||
case "image":
|
case "image":
|
||||||
return (
|
return (
|
||||||
|
@ -7,7 +7,9 @@ import { getPictureElementClass } from "../../create-element/create-picture-elem
|
|||||||
@customElement("hui-picture-element-element-editor")
|
@customElement("hui-picture-element-element-editor")
|
||||||
export class HuiPictureElementElementEditor extends HuiElementEditor<LovelaceElementConfig> {
|
export class HuiPictureElementElementEditor extends HuiElementEditor<LovelaceElementConfig> {
|
||||||
protected get configElementType(): string | undefined {
|
protected get configElementType(): string | undefined {
|
||||||
return this.value?.type;
|
return this.value?.type === "action-button"
|
||||||
|
? "service-button"
|
||||||
|
: this.value?.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getConfigElement(): Promise<
|
protected async getConfigElement(): Promise<
|
||||||
|
@ -5997,6 +5997,7 @@
|
|||||||
"state-icon": "State icon",
|
"state-icon": "State icon",
|
||||||
"state-label": "State label",
|
"state-label": "State label",
|
||||||
"service-button": "Perform action button",
|
"service-button": "Perform action button",
|
||||||
|
"action-button": "Perform action button",
|
||||||
"icon": "Icon",
|
"icon": "Icon",
|
||||||
"image": "Image",
|
"image": "Image",
|
||||||
"conditional": "Conditional"
|
"conditional": "Conditional"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user