From 33703a3b531f42480946dd95bb926d3b0646dd44 Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Tue, 27 Apr 2021 00:28:22 +0200 Subject: [PATCH] Add link to integration docs from service control (#8290) * Add link to integration help to dev tool services * Adjust to new service control * Update src/translations/en.json Co-authored-by: Bram Kragten * Make icon less noticable + correct translation Co-authored-by: Bram Kragten --- src/components/ha-service-control.ts | 37 ++++++++++++- .../service/developer-tools-service.ts | 52 ++++++++++++++++--- src/translations/en.json | 3 +- 3 files changed, 82 insertions(+), 10 deletions(-) diff --git a/src/components/ha-service-control.ts b/src/components/ha-service-control.ts index 10d5b6b24c..66152e4f8a 100644 --- a/src/components/ha-service-control.ts +++ b/src/components/ha-service-control.ts @@ -1,3 +1,4 @@ +import { mdiHelpCircle } from "@mdi/js"; import { HassService, HassServiceTarget } from "home-assistant-js-websocket"; import { css, @@ -18,11 +19,12 @@ import { ENTITY_COMPONENT_DOMAINS } from "../data/entity"; import { Selector } from "../data/selector"; import { PolymerChangedEvent } from "../polymer-types"; import { HomeAssistant } from "../types"; +import { documentationUrl } from "../util/documentation-url"; +import "./ha-checkbox"; import "./ha-selector/ha-selector"; import "./ha-service-picker"; import "./ha-settings-row"; import "./ha-yaml-editor"; -import "./ha-checkbox"; import type { HaYamlEditor } from "./ha-yaml-editor"; interface ExtHassService extends Omit { @@ -178,7 +180,29 @@ export class HaServiceControl extends LitElement { .value=${this._value?.service} @value-changed=${this._serviceChanged} > -

${serviceData?.description}

+
+

${serviceData?.description}

+ ${this.value?.service + ? html` + + + + ` + : ""} +
${serviceData && "target" in serviceData ? html` ${hasOptional @@ -410,6 +434,15 @@ export class HaServiceControl extends LitElement { ha-checkbox { margin-left: -16px; } + .help-icon { + color: var(--secondary-text-color); + } + .description { + justify-content: space-between; + display: flex; + align-items: center; + padding-right: 2px; + } `; } } diff --git a/src/panels/developer-tools/service/developer-tools-service.ts b/src/panels/developer-tools/service/developer-tools-service.ts index 69c6a84c43..38ec7a2462 100644 --- a/src/panels/developer-tools/service/developer-tools-service.ts +++ b/src/panels/developer-tools/service/developer-tools-service.ts @@ -1,3 +1,4 @@ +import { mdiHelpCircle } from "@mdi/js"; import { ERR_CONNECTION_LOST } from "home-assistant-js-websocket"; import { safeLoad } from "js-yaml"; import { @@ -23,8 +24,8 @@ import "../../../components/ha-service-control"; import "../../../components/ha-service-picker"; import "../../../components/ha-yaml-editor"; import type { HaYamlEditor } from "../../../components/ha-yaml-editor"; -import { ServiceAction } from "../../../data/script"; import { forwardHaptic } from "../../../data/haptics"; +import { ServiceAction } from "../../../data/script"; import { callExecuteScript, serviceCallWillDisconnect, @@ -33,6 +34,7 @@ import { haStyle } from "../../../resources/styles"; import "../../../styles/polymer-ha-style"; import { HomeAssistant } from "../../../types"; import "../../../util/app-localstorage-document"; +import { documentationUrl } from "../../../util/documentation-url"; import { showToast } from "../../../util/toast"; class HaPanelDevService extends LitElement { @@ -162,12 +164,39 @@ class HaPanelDevService extends LitElement { outlined .expanded=${this._yamlMode} > - ${this._yamlMode && target - ? html`

- ${this.hass.localize( - "ui.panel.developer-tools.tabs.services.accepts_target" - )} -

` + ${this._yamlMode + ? html`
+

+ ${target + ? html` + ${this.hass.localize( + "ui.panel.developer-tools.tabs.services.accepts_target" + )} + ` + : ""} +

+ ${this._serviceData?.service + ? html` + + + + ` + : ""} +
` : ""} @@ -419,6 +448,15 @@ class HaPanelDevService extends LitElement { padding: 4px; vertical-align: middle; } + + .help-icon { + color: var(--secondary-text-color); + } + .description { + justify-content: space-between; + display: flex; + align-items: center; + } `, ]; } diff --git a/src/translations/en.json b/src/translations/en.json index 0739654482..7235e240a2 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -452,7 +452,8 @@ "required": "This field is required", "target": "Targets", "target_description": "What should this service use as targeted areas, devices or entities.", - "service_data": "Service data" + "service_data": "Service data", + "integration_doc": "Integration documentation" }, "related-items": { "no_related_found": "No related items found.",