mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Minor improvements to service call descriptions. (#20733)
* Minor improvements to service call descriptions.
This commit is contained in:
parent
6421a9443d
commit
9e9cb15a42
@ -89,7 +89,8 @@ const tryDescribeAction = <T extends ActionType>(
|
|||||||
const config = action as ActionTypes["service"];
|
const config = action as ActionTypes["service"];
|
||||||
|
|
||||||
const targets: string[] = [];
|
const targets: string[] = [];
|
||||||
if (config.target) {
|
const targetOrData = config.target || config.data;
|
||||||
|
if (targetOrData) {
|
||||||
for (const [key, name] of Object.entries({
|
for (const [key, name] of Object.entries({
|
||||||
area_id: "areas",
|
area_id: "areas",
|
||||||
device_id: "devices",
|
device_id: "devices",
|
||||||
@ -97,12 +98,10 @@ const tryDescribeAction = <T extends ActionType>(
|
|||||||
floor_id: "floors",
|
floor_id: "floors",
|
||||||
label_id: "labels",
|
label_id: "labels",
|
||||||
})) {
|
})) {
|
||||||
if (!(key in config.target)) {
|
if (!(key in targetOrData)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const keyConf: string[] = Array.isArray(config.target[key])
|
const keyConf: string[] = ensureArray(targetOrData[key]) || [];
|
||||||
? config.target[key]
|
|
||||||
: [config.target[key]];
|
|
||||||
|
|
||||||
for (const targetThing of keyConf) {
|
for (const targetThing of keyConf) {
|
||||||
if (isTemplate(targetThing)) {
|
if (isTemplate(targetThing)) {
|
||||||
@ -195,8 +194,12 @@ const tryDescribeAction = <T extends ActionType>(
|
|||||||
(config.service && isTemplate(config.service))
|
(config.service && isTemplate(config.service))
|
||||||
) {
|
) {
|
||||||
return hass.localize(
|
return hass.localize(
|
||||||
`${actionTranslationBaseKey}.service.description.service_based_on_template`,
|
targets.length
|
||||||
{ targets: formatListWithAnds(hass.locale, targets) }
|
? `${actionTranslationBaseKey}.service.description.service_based_on_template`
|
||||||
|
: `${actionTranslationBaseKey}.service.description.service_based_on_template_no_targets`,
|
||||||
|
{
|
||||||
|
targets: formatListWithAnds(hass.locale, targets),
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +211,9 @@ const tryDescribeAction = <T extends ActionType>(
|
|||||||
|
|
||||||
if (config.metadata) {
|
if (config.metadata) {
|
||||||
return hass.localize(
|
return hass.localize(
|
||||||
`${actionTranslationBaseKey}.service.description.service_name`,
|
targets.length
|
||||||
|
? `${actionTranslationBaseKey}.service.description.service_name`
|
||||||
|
: `${actionTranslationBaseKey}.service.description.service_name_no_targets`,
|
||||||
{
|
{
|
||||||
domain: domainToName(hass.localize, domain),
|
domain: domainToName(hass.localize, domain),
|
||||||
name: service || config.service,
|
name: service || config.service,
|
||||||
@ -218,7 +223,9 @@ const tryDescribeAction = <T extends ActionType>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return hass.localize(
|
return hass.localize(
|
||||||
`${actionTranslationBaseKey}.service.description.service_based_on_name`,
|
targets.length
|
||||||
|
? `${actionTranslationBaseKey}.service.description.service_based_on_name`
|
||||||
|
: `${actionTranslationBaseKey}.service.description.service_based_on_name_no_targets`,
|
||||||
{
|
{
|
||||||
name: service
|
name: service
|
||||||
? `${domainToName(hass.localize, domain)}: ${service}`
|
? `${domainToName(hass.localize, domain)}: ${service}`
|
||||||
|
@ -3251,6 +3251,9 @@
|
|||||||
"service_based_on_template": "Call a service based on a template on {targets}",
|
"service_based_on_template": "Call a service based on a template on {targets}",
|
||||||
"service_based_on_name": "Call a service ''{name}'' on {targets}",
|
"service_based_on_name": "Call a service ''{name}'' on {targets}",
|
||||||
"service_name": "{domain} ''{name}'' on {targets}",
|
"service_name": "{domain} ''{name}'' on {targets}",
|
||||||
|
"service_based_on_template_no_targets": "Call a service based on a template",
|
||||||
|
"service_based_on_name_no_targets": "Call a service ''{name}''",
|
||||||
|
"service_name_no_targets": "{domain} ''{name}''",
|
||||||
"service": "Call a service",
|
"service": "Call a service",
|
||||||
"target_template": "templated {name}",
|
"target_template": "templated {name}",
|
||||||
"target_unknown_entity": "unknown entity",
|
"target_unknown_entity": "unknown entity",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user