Skip to content

Commit

Permalink
Rename service call to action (#21362)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Jul 11, 2024
1 parent 5ead5ed commit d958358
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 89 deletions.
6 changes: 4 additions & 2 deletions src/components/ha-service-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export class HaServiceControl extends LitElement {
>
<span slot="description"
>${this.hass.localize(
"ui.components.service-control.target_description"
"ui.components.service-control.target_secondary"
)}</span
><ha-selector
.hass=${this.hass}
Expand All @@ -478,7 +478,9 @@ export class HaServiceControl extends LitElement {
${shouldRenderServiceDataYaml
? html`<ha-yaml-editor
.hass=${this.hass}
.label=${this.hass.localize("ui.components.service-control.data")}
.label=${this.hass.localize(
"ui.components.service-control.action_data"
)}
.name=${"data"}
.readOnly=${this.disabled}
.defaultValue=${this._value?.data}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ha-service-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class HaServicePicker extends LitElement {
return html`
<ha-combo-box
.hass=${this.hass}
.label=${this.hass.localize("ui.components.service-picker.service")}
.label=${this.hass.localize("ui.components.service-picker.action")}
.filteredItems=${this._filteredServices(
this.hass.localize,
this.hass.services,
Expand Down
9 changes: 6 additions & 3 deletions src/panels/config/cloud/account/cloud-tts-pref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ export class CloudTTSPref extends LitElement {
header=${this.hass.localize("ui.panel.config.cloud.account.tts.title")}
>
<div class="card-content">
${this.hass.localize("ui.panel.config.cloud.account.tts.info", {
service: '"tts.cloud_say"',
})}
${this.hass.localize(
"ui.panel.config.cloud.account.tts.description",
{
service: '"tts.cloud_say"',
}
)}
<br /><br />
<div class="row">
<ha-language-picker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
>
<span slot="description"
>${this.hass.localize(
"ui.dialogs.entity_registry.editor.hidden_description"
"ui.dialogs.entity_registry.editor.hidden_explanation"
)}</span
>
<ha-switch
Expand Down
2 changes: 1 addition & 1 deletion src/panels/config/entities/ha-config-entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ ${
{ number: this._selected.length }
),
text: this.hass.localize(
"ui.panel.config.entities.picker.hide_selected.confirm_text"
"ui.panel.config.entities.picker.hide_selected.confirm"
),
confirmText: this.hass.localize("ui.common.hide"),
dismissText: this.hass.localize("ui.common.cancel"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mdiHelpCircle } from "@mdi/js";
import { ERR_CONNECTION_LOST } from "home-assistant-js-websocket";
import { load } from "js-yaml";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { property, query, state } from "lit/decorators";
import { customElement, property, query, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { storage } from "../../../common/decorators/storage";
import { computeDomain } from "../../../common/entity/compute_domain";
Expand Down Expand Up @@ -31,7 +31,8 @@ import { haStyle } from "../../../resources/styles";
import { HomeAssistant } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url";

class HaPanelDevService extends LitElement {
@customElement("developer-tools-action")
class HaPanelDevAction extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;

@property({ type: Boolean }) public narrow = false;
Expand Down Expand Up @@ -112,7 +113,7 @@ class HaPanelDevService extends LitElement {
<div class="content">
<p>
${this.hass.localize(
"ui.panel.developer-tools.tabs.services.description"
"ui.panel.developer-tools.tabs.actions.description"
)}
</p>
<ha-card>
Expand Down Expand Up @@ -154,23 +155,23 @@ class HaPanelDevService extends LitElement {
>
${this._yamlMode
? this.hass.localize(
"ui.panel.developer-tools.tabs.services.ui_mode"
"ui.panel.developer-tools.tabs.actions.ui_mode"
)
: this.hass.localize(
"ui.panel.developer-tools.tabs.services.yaml_mode"
"ui.panel.developer-tools.tabs.actions.yaml_mode"
)}
</mwc-button>
${!this._uiAvailable
? html`<span class="error"
>${this.hass.localize(
"ui.panel.developer-tools.tabs.services.no_template_ui_support"
"ui.panel.developer-tools.tabs.actions.no_template_ui_support"
)}</span
>`
: ""}
</div>
<ha-progress-button raised @click=${this._callService}>
${this.hass.localize(
"ui.panel.developer-tools.tabs.services.call_service"
"ui.panel.developer-tools.tabs.actions.call_service"
)}
</ha-progress-button>
</div>
Expand All @@ -179,7 +180,7 @@ class HaPanelDevService extends LitElement {
? html`<div class="content">
<ha-card
.header=${this.hass.localize(
"ui.panel.developer-tools.tabs.services.response"
"ui.panel.developer-tools.tabs.actions.response"
)}
>
<div class="card-content">
Expand All @@ -199,10 +200,10 @@ class HaPanelDevService extends LitElement {
<ha-expansion-panel
.header=${this._yamlMode
? this.hass.localize(
"ui.panel.developer-tools.tabs.services.all_parameters"
"ui.panel.developer-tools.tabs.actions.all_parameters"
)
: this.hass.localize(
"ui.panel.developer-tools.tabs.services.yaml_parameters"
"ui.panel.developer-tools.tabs.actions.yaml_parameters"
)}
outlined
.expanded=${this._yamlMode}
Expand All @@ -213,7 +214,7 @@ class HaPanelDevService extends LitElement {
${target
? html`
${this.hass.localize(
"ui.panel.developer-tools.tabs.services.accepts_target"
"ui.panel.developer-tools.tabs.actions.accepts_target"
)}
`
: ""}
Expand Down Expand Up @@ -244,17 +245,17 @@ class HaPanelDevService extends LitElement {
<tr>
<th>
${this.hass.localize(
"ui.panel.developer-tools.tabs.services.column_parameter"
"ui.panel.developer-tools.tabs.actions.column_parameter"
)}
</th>
<th>
${this.hass.localize(
"ui.panel.developer-tools.tabs.services.column_description"
"ui.panel.developer-tools.tabs.actions.column_description"
)}
</th>
<th>
${this.hass.localize(
"ui.panel.developer-tools.tabs.services.column_example"
"ui.panel.developer-tools.tabs.actions.column_example"
)}
</th>
</tr>
Expand All @@ -281,7 +282,7 @@ class HaPanelDevService extends LitElement {
${this._yamlMode
? html`<mwc-button @click=${this._fillExampleData}
>${this.hass.localize(
"ui.panel.developer-tools.tabs.services.fill_example_data"
"ui.panel.developer-tools.tabs.actions.fill_example_data"
)}</mwc-button
>`
: ""}
Expand All @@ -305,14 +306,14 @@ class HaPanelDevService extends LitElement {
const errorCategory = yamlMode ? "yaml" : "ui";
if (!serviceData?.service) {
return localize(
`ui.panel.developer-tools.tabs.services.errors.${errorCategory}.no_service`
`ui.panel.developer-tools.tabs.actions.errors.${errorCategory}.no_service`
);
}
const domain = computeDomain(serviceData.service);
const service = computeObjectId(serviceData.service);
if (!domain || !service) {
return localize(
`ui.panel.developer-tools.tabs.services.errors.${errorCategory}.invalid_service`
`ui.panel.developer-tools.tabs.actions.errors.${errorCategory}.invalid_service`
);
}
if (
Expand All @@ -323,7 +324,7 @@ class HaPanelDevService extends LitElement {
!serviceData.data?.area_id
) {
return localize(
`ui.panel.developer-tools.tabs.services.errors.${errorCategory}.no_target`
`ui.panel.developer-tools.tabs.actions.errors.${errorCategory}.no_target`
);
}
for (const field of fields) {
Expand All @@ -332,7 +333,7 @@ class HaPanelDevService extends LitElement {
(!serviceData.data || serviceData.data[field.key] === undefined)
) {
return localize(
`ui.panel.developer-tools.tabs.services.errors.${errorCategory}.missing_required_field`,
`ui.panel.developer-tools.tabs.actions.errors.${errorCategory}.missing_required_field`,
{ key: field.key }
);
}
Expand Down Expand Up @@ -377,7 +378,7 @@ class HaPanelDevService extends LitElement {
forwardHaptic("failure");
button.actionError();
this._error = this.hass.localize(
"ui.panel.developer-tools.tabs.services.errors.yaml.invalid_yaml"
"ui.panel.developer-tools.tabs.actions.errors.yaml.invalid_yaml"
);
return;
}
Expand Down Expand Up @@ -439,7 +440,7 @@ class HaPanelDevService extends LitElement {
}
this._error =
localizedErrorMessage ||
this.hass.localize("ui.notification_toast.service_call_failed", {
this.hass.localize("ui.notification_toast.action_failed", {
service: this._serviceData!.service!,
}) + ` ${err.message}`;
return;
Expand Down Expand Up @@ -630,10 +631,8 @@ class HaPanelDevService extends LitElement {
}
}

customElements.define("developer-tools-service", HaPanelDevService);

declare global {
interface HTMLElementTagNameMap {
"developer-tools-service": HaPanelDevService;
"developer-tools-action": HaPanelDevAction;
}
}
7 changes: 4 additions & 3 deletions src/panels/developer-tools/developer-tools-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ class DeveloperToolsRouter extends HassRouterPage {
tag: "developer-tools-event",
load: () => import("./event/developer-tools-event"),
},
service: {
tag: "developer-tools-service",
load: () => import("./service/developer-tools-service"),
service: "action",
action: {
tag: "developer-tools-action",
load: () => import("./action/developer-tools-action"),
},
state: {
tag: "developer-tools-state",
Expand Down
6 changes: 2 additions & 4 deletions src/panels/developer-tools/ha-panel-developer-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ class PanelDeveloperTools extends LitElement {
<paper-tab page-name="state">
${this.hass.localize("ui.panel.developer-tools.tabs.states.title")}
</paper-tab>
<paper-tab page-name="service">
${this.hass.localize(
"ui.panel.developer-tools.tabs.services.title"
)}
<paper-tab page-name="action">
${this.hass.localize("ui.panel.developer-tools.tabs.actions.title")}
</paper-tab>
<paper-tab page-name="template">
${this.hass.localize(
Expand Down
2 changes: 1 addition & 1 deletion src/panels/lovelace/common/compute-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function computeActionTooltip(
break;
case "call-service":
tooltip += `${hass.localize(
"ui.panel.lovelace.cards.picture-elements.call_service",
"ui.panel.lovelace.cards.picture-elements.perform_action",
{ name: config.service }
)}`;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/panels/lovelace/common/handle-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const handleAction = async (
case "call-service": {
if (!actionConfig.service) {
showToast(node, {
message: hass.localize("ui.panel.lovelace.cards.actions.no_service"),
message: hass.localize("ui.panel.lovelace.cards.actions.no_action"),
});
forwardHaptic("failure");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ export class HuiTileCardEditor
return this.hass!.localize(
`ui.panel.lovelace.editor.card.tile.${schema.name}`
);

default:
return this.hass!.localize(
`ui.panel.lovelace.editor.card.generic.${schema.name}`
Expand Down
2 changes: 1 addition & 1 deletion src/state/connection-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
const message =
localizedErrorMessage ||
(this as any).hass.localize(
"ui.notification_toast.service_call_failed",
"ui.notification_toast.action_failed",
"service",
`${domain}/${service}`
) +
Expand Down
Loading

0 comments on commit d958358

Please sign in to comment.