mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 23:06:40 +00:00
Use service name in action confirmation popup (#8493)
This commit is contained in:
parent
89b82bb778
commit
20858db96d
@ -1,6 +1,7 @@
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import { navigate } from "../../../common/navigate";
|
||||
import { forwardHaptic } from "../../../data/haptics";
|
||||
import { domainToName } from "../../../data/integration";
|
||||
import { ActionConfig } from "../../../data/lovelace";
|
||||
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
@ -50,6 +51,18 @@ export const handleAction = async (
|
||||
) {
|
||||
forwardHaptic("warning");
|
||||
|
||||
let serviceName;
|
||||
if (actionConfig.action === "call-service") {
|
||||
const [domain, service] = actionConfig.service.split(".", 2);
|
||||
const serviceDomains = hass.services;
|
||||
if (domain in serviceDomains && service in serviceDomains[domain]) {
|
||||
const localize = await hass.loadBackendTranslation("title");
|
||||
serviceName = `${domainToName(localize, domain)}: ${
|
||||
serviceDomains[domain][service].name || service
|
||||
}`;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
!(await showConfirmationDialog(node, {
|
||||
text:
|
||||
@ -57,10 +70,12 @@ export const handleAction = async (
|
||||
hass.localize(
|
||||
"ui.panel.lovelace.cards.actions.action_confirmation",
|
||||
"action",
|
||||
serviceName ||
|
||||
hass.localize(
|
||||
"ui.panel.lovelace.editor.action-editor.actions." +
|
||||
actionConfig.action
|
||||
) || actionConfig.action
|
||||
) ||
|
||||
actionConfig.action
|
||||
),
|
||||
}))
|
||||
) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user