mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Use proper styled confirmation dialog for handled actions (#8077)
This commit is contained in:
parent
cb2c6d8560
commit
f2e9b3577d
@ -4,6 +4,7 @@ import { forwardHaptic } from "../../../data/haptics";
|
|||||||
import { ActionConfig } from "../../../data/lovelace";
|
import { ActionConfig } from "../../../data/lovelace";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { toggleEntity } from "./entity/toggle-entity";
|
import { toggleEntity } from "./entity/toggle-entity";
|
||||||
|
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HASSDomEvents {
|
interface HASSDomEvents {
|
||||||
@ -11,7 +12,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const handleAction = (
|
export const handleAction = async (
|
||||||
node: HTMLElement,
|
node: HTMLElement,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: {
|
config: {
|
||||||
@ -22,7 +23,7 @@ export const handleAction = (
|
|||||||
double_tap_action?: ActionConfig;
|
double_tap_action?: ActionConfig;
|
||||||
},
|
},
|
||||||
action: string
|
action: string
|
||||||
): void => {
|
): Promise<void> => {
|
||||||
let actionConfig: ActionConfig | undefined;
|
let actionConfig: ActionConfig | undefined;
|
||||||
|
|
||||||
if (action === "double_tap" && config.double_tap_action) {
|
if (action === "double_tap" && config.double_tap_action) {
|
||||||
@ -49,10 +50,15 @@ export const handleAction = (
|
|||||||
forwardHaptic("warning");
|
forwardHaptic("warning");
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!confirm(
|
!(await showConfirmationDialog(node, {
|
||||||
actionConfig.confirmation.text ||
|
text:
|
||||||
`Are you sure you want to ${actionConfig.action}?`
|
actionConfig.confirmation.text ||
|
||||||
)
|
hass.localize(
|
||||||
|
"ui.panel.lovelace.cards.action_confirmation",
|
||||||
|
"action",
|
||||||
|
actionConfig.action
|
||||||
|
),
|
||||||
|
}))
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,9 @@ export class HuiServiceButtonElement extends LitElement
|
|||||||
return html`
|
return html`
|
||||||
<ha-call-service-button
|
<ha-call-service-button
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.domain="${this._domain}"
|
.domain=${this._domain}
|
||||||
.service="${this._service}"
|
.service=${this._service}
|
||||||
.serviceData="${this._config.service_data}"
|
.serviceData=${this._config.service_data}
|
||||||
>${this._config.title}</ha-call-service-button
|
>${this._config.title}</ha-call-service-button
|
||||||
>
|
>
|
||||||
`;
|
`;
|
||||||
|
@ -2390,6 +2390,7 @@
|
|||||||
"lovelace": {
|
"lovelace": {
|
||||||
"cards": {
|
"cards": {
|
||||||
"confirm_delete": "Are you sure you want to delete this card?",
|
"confirm_delete": "Are you sure you want to delete this card?",
|
||||||
|
"action_confirmation": "Are you sure you want to exectue action \"{action}\"?",
|
||||||
"empty_state": {
|
"empty_state": {
|
||||||
"title": "Welcome Home",
|
"title": "Welcome Home",
|
||||||
"no_devices": "This page allows you to control your devices, however it looks like you have no devices set up yet. Head to the integrations page to get started.",
|
"no_devices": "This page allows you to control your devices, however it looks like you have no devices set up yet. Head to the integrations page to get started.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user