diff --git a/src/components/media-player/ha-media-player-browse.ts b/src/components/media-player/ha-media-player-browse.ts index 0b14444536..f63f3592e4 100644 --- a/src/components/media-player/ha-media-player-browse.ts +++ b/src/components/media-player/ha-media-player-browse.ts @@ -22,6 +22,7 @@ import { styleMap } from "lit-html/directives/style-map"; import { fireEvent } from "../../common/dom/fire_event"; import { computeRTLDirection } from "../../common/util/compute_rtl"; import { debounce } from "../../common/util/debounce"; +import type { MediaPlayerItem } from "../../data/media-player"; import { browseLocalMediaPlayer, browseMediaPlayer, @@ -30,11 +31,11 @@ import { MediaPickedEvent, MediaPlayerBrowseAction, } from "../../data/media-player"; -import type { MediaPlayerItem } from "../../data/media-player"; import { showAlertDialog } from "../../dialogs/generic/show-dialog-box"; import { installResizeObserver } from "../../panels/lovelace/common/install-resize-observer"; import { haStyle } from "../../resources/styles"; import type { HomeAssistant } from "../../types"; +import { documentationUrl } from "../../util/documentation-url"; import "../entity/ha-entity-picker"; import "../ha-button-menu"; import "../ha-card"; @@ -511,7 +512,10 @@ export class HaMediaPlayerBrowse extends LitElement {

Check the documentation${this.hass.localize( diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index f76f44ac67..5a39e7eac8 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -39,6 +39,7 @@ import "../../../layouts/ha-app-layout"; import "../../../layouts/hass-tabs-subpage"; import { haStyle } from "../../../resources/styles"; import { HomeAssistant, Route } from "../../../types"; +import { documentationUrl } from "../../../util/documentation-url"; import "../ha-config-section"; import { configSections } from "../ha-panel-config"; import "./action/ha-automation-action"; @@ -159,7 +160,10 @@ export class HaAutomationEditor extends LitElement { "ui.panel.config.automation.editor.modes.description", "documentation_link", html`${this.hass.localize( @@ -247,7 +251,10 @@ export class HaAutomationEditor extends LitElement { )}

@@ -276,7 +283,10 @@ export class HaAutomationEditor extends LitElement { )}

@@ -305,7 +315,10 @@ export class HaAutomationEditor extends LitElement { )}

diff --git a/src/panels/config/cloud/dialog-manage-cloudhook/dialog-manage-cloudhook.ts b/src/panels/config/cloud/dialog-manage-cloudhook/dialog-manage-cloudhook.ts index b590848f99..1561ed7420 100644 --- a/src/panels/config/cloud/dialog-manage-cloudhook/dialog-manage-cloudhook.ts +++ b/src/panels/config/cloud/dialog-manage-cloudhook/dialog-manage-cloudhook.ts @@ -14,6 +14,7 @@ import type { HaPaperDialog } from "../../../../components/dialog/ha-paper-dialo import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box"; import { haStyle } from "../../../../resources/styles"; import { HomeAssistant } from "../../../../types"; +import { documentationUrl } from "../../../../util/documentation-url"; import { WebhookDialogParams } from "./show-dialog-manage-cloudhook"; const inputLabel = "Public URL – Click to copy to clipboard"; @@ -37,8 +38,11 @@ export class DialogManageCloudhook extends LitElement { const { webhook, cloudhook } = this._params; const docsUrl = webhook.domain === "automation" - ? "https://www.home-assistant.io/docs/automation/trigger/#webhook-trigger" - : `https://www.home-assistant.io/integrations/${webhook.domain}/`; + ? documentationUrl( + this.hass!, + "/docs/automation/trigger/#webhook-trigger" + ) + : documentationUrl(this.hass!, `/integrations/${webhook.domain}/`); return html`

diff --git a/src/panels/config/cloud/register/cloud-register.js b/src/panels/config/cloud/register/cloud-register.js index 8b5b04c5b1..382effb34f 100644 --- a/src/panels/config/cloud/register/cloud-register.js +++ b/src/panels/config/cloud/register/cloud-register.js @@ -8,6 +8,7 @@ import "../../../../layouts/hass-subpage"; import { EventsMixin } from "../../../../mixins/events-mixin"; import LocalizeMixin from "../../../../mixins/localize-mixin"; import "../../../../styles/polymer-ha-style"; +import { documentationUrl } from "../../../../util/documentation-url"; import "../../ha-config-section"; /* @@ -70,8 +71,8 @@ class CloudRegister extends LocalizeMixin(EventsMixin(PolymerElement)) {

[[localize('ui.panel.config.cloud.register.information4')]]

@@ -137,6 +138,14 @@ class CloudRegister extends LocalizeMixin(EventsMixin(PolymerElement)) { } } + _computeDocumentationUrlTos(hass) { + return documentationUrl(hass, "/tos/"); + } + + _computeDocumentationUrlPrivacy(hass) { + return documentationUrl(hass, "/privacy/"); + } + _handleRegister() { let invalid = false; diff --git a/src/panels/config/customize/ha-form-customize.js b/src/panels/config/customize/ha-form-customize.js index 4c85d7b27f..2ad523125d 100644 --- a/src/panels/config/customize/ha-form-customize.js +++ b/src/panels/config/customize/ha-form-customize.js @@ -6,10 +6,11 @@ import { html } from "@polymer/polymer/lib/utils/html-tag"; import { PolymerElement } from "@polymer/polymer/polymer-element"; import { computeStateDomain } from "../../../common/entity/compute_state_domain"; import LocalizeMixin from "../../../mixins/localize-mixin"; -import hassAttributeUtil from "../../../util/hass-attributes-util"; -import "./ha-form-customize-attributes"; -import "../ha-form-style"; import "../../../styles/polymer-ha-style"; +import { documentationUrl } from "../../../util/documentation-url"; +import hassAttributeUtil from "../../../util/hass-attributes-util"; +import "../ha-form-style"; +import "./ha-form-customize-attributes"; class HaFormCustomize extends LocalizeMixin(PolymerElement) { static get template() { @@ -30,7 +31,7 @@ class HaFormCustomize extends LocalizeMixin(PolymerElement) {
[[localize('ui.panel.config.customize.warning.include_sentence')]] [[localize('ui.panel.config.customize.warning.include_link')]]

diff --git a/src/panels/config/integrations/integration-panels/zwave/zwave-network.ts b/src/panels/config/integrations/integration-panels/zwave/zwave-network.ts index 7d220ba93c..b9860c0589 100644 --- a/src/panels/config/integrations/integration-panels/zwave/zwave-network.ts +++ b/src/panels/config/integrations/integration-panels/zwave/zwave-network.ts @@ -1,20 +1,20 @@ -import "../../../../../components/ha-icon-button"; -import "../../../../../components/ha-circular-progress"; import { UnsubscribeFunc } from "home-assistant-js-websocket"; import { css, CSSResult, customElement, html, + internalProperty, LitElement, property, - internalProperty, TemplateResult, } from "lit-element"; import "../../../../../components/buttons/ha-call-api-button"; import "../../../../../components/buttons/ha-call-service-button"; import "../../../../../components/ha-card"; +import "../../../../../components/ha-circular-progress"; import "../../../../../components/ha-icon"; +import "../../../../../components/ha-icon-button"; import "../../../../../components/ha-service-description"; import { fetchNetworkStatus, @@ -26,6 +26,7 @@ import { } from "../../../../../data/zwave"; import { haStyle } from "../../../../../resources/styles"; import { HomeAssistant } from "../../../../../types"; +import { documentationUrl } from "../../../../../util/documentation-url"; import "../../../ha-config-section"; @customElement("zwave-network") @@ -71,7 +72,10 @@ export class ZwaveNetwork extends LitElement { )}

diff --git a/src/panels/config/person/dialog-person-detail.ts b/src/panels/config/person/dialog-person-detail.ts index 94c50807c1..043d407607 100644 --- a/src/panels/config/person/dialog-person-detail.ts +++ b/src/panels/config/person/dialog-person-detail.ts @@ -4,23 +4,24 @@ import { css, CSSResult, html, + internalProperty, LitElement, property, - internalProperty, TemplateResult, } from "lit-element"; import memoizeOne from "memoize-one"; -import "../../../components/ha-picture-upload"; -import type { HaPictureUpload } from "../../../components/ha-picture-upload"; import "../../../components/entity/ha-entities-picker"; import { createCloseHeading } from "../../../components/ha-dialog"; +import "../../../components/ha-picture-upload"; +import type { HaPictureUpload } from "../../../components/ha-picture-upload"; import "../../../components/user/ha-user-picker"; import { PersonMutableParams } from "../../../data/person"; +import { CropOptions } from "../../../dialogs/image-cropper-dialog/show-image-cropper-dialog"; import { PolymerChangedEvent } from "../../../polymer-types"; import { haStyleDialog } from "../../../resources/styles"; import { HomeAssistant } from "../../../types"; +import { documentationUrl } from "../../../util/documentation-url"; import { PersonDetailDialogParams } from "./show-dialog-person-detail"; -import { CropOptions } from "../../../dialogs/image-cropper-dialog/show-image-cropper-dialog"; const includeDomains = ["device_tracker"]; @@ -153,7 +154,10 @@ class DialogPersonDetail extends LitElement {

${this.scriptEntityId ? html` -
- - - ${this.hass.localize("ui.card.script.execute")} - -
+ + + ${this.hass.localize("ui.card.script.execute")} + +
` : ``} @@ -227,7 +233,7 @@ export class HaScriptEditor extends LitElement { )}

diff --git a/src/panels/config/script/ha-script-picker.ts b/src/panels/config/script/ha-script-picker.ts index 99b6dce17e..d7b713596c 100644 --- a/src/panels/config/script/ha-script-picker.ts +++ b/src/panels/config/script/ha-script-picker.ts @@ -25,6 +25,7 @@ import { configSections } from "../ha-panel-config"; import "../../../components/ha-svg-icon"; import { mdiPlus } from "@mdi/js"; import { stateIcon } from "../../../common/entity/state_icon"; +import { documentationUrl } from "../../../util/documentation-url"; @customElement("ha-script-picker") class HaScriptPicker extends LitElement { @@ -187,7 +188,7 @@ class HaScriptPicker extends LitElement { ${this.hass.localize("ui.panel.config.script.picker.introduction")}

diff --git a/src/panels/developer-tools/event/developer-tools-event.js b/src/panels/developer-tools/event/developer-tools-event.js index 4466d48f10..ec7526fee9 100644 --- a/src/panels/developer-tools/event/developer-tools-event.js +++ b/src/panels/developer-tools/event/developer-tools-event.js @@ -9,6 +9,7 @@ import "../../../components/ha-code-editor"; import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box"; import { EventsMixin } from "../../../mixins/events-mixin"; import LocalizeMixin from "../../../mixins/localize-mixin"; +import { documentationUrl } from "../../../util/documentation-url"; import "../../../styles/polymer-ha-style"; import "./event-subscribe-card"; import "./events-list"; @@ -61,7 +62,7 @@ class HaPanelDevEvent extends EventsMixin(LocalizeMixin(PolymerElement)) {

[[localize( 'ui.panel.developer-tools.tabs.events.description' )]] @@ -149,6 +150,10 @@ class HaPanelDevEvent extends EventsMixin(LocalizeMixin(PolymerElement)) { } } + _computeDocumentationUrl(hass) { + return documentationUrl(hass, "/docs/configuration/events/"); + } + _computeValidJSON(parsedJSON) { return parsedJSON !== ERROR_SENTINEL; } diff --git a/src/panels/developer-tools/template/developer-tools-template.ts b/src/panels/developer-tools/template/developer-tools-template.ts index c9ca775fbf..d41e8fed1e 100644 --- a/src/panels/developer-tools/template/developer-tools-template.ts +++ b/src/panels/developer-tools/template/developer-tools-template.ts @@ -19,6 +19,7 @@ import { } from "../../../data/ws-templates"; import { haStyle } from "../../../resources/styles"; import { HomeAssistant } from "../../../types"; +import { documentationUrl } from "../../../util/documentation-url"; const DEMO_TEMPLATE = `{## Imitate available variables: ##} {% set my_test_json = { @@ -107,7 +108,10 @@ class HaPanelDevTemplate extends LitElement {

  • diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts index 87d5ea3115..e700cd097b 100755 --- a/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts @@ -115,7 +115,10 @@ export class HuiDialogEditCard extends LitElement implements HassDialog { const oldConfig = changedProps.get("_cardConfig") as LovelaceCardConfig; if (oldConfig?.type !== this._cardConfig!.type) { - this._documentationURL = getCardDocumentationURL(this._cardConfig!.type); + this._documentationURL = getCardDocumentationURL( + this.hass, + this._cardConfig!.type + ); } } diff --git a/src/panels/lovelace/editor/get-card-documentation-url.ts b/src/panels/lovelace/editor/get-card-documentation-url.ts index 4d1e989a1d..e810f6bb4f 100644 --- a/src/panels/lovelace/editor/get-card-documentation-url.ts +++ b/src/panels/lovelace/editor/get-card-documentation-url.ts @@ -1,14 +1,17 @@ import { - getCustomCardEntry, CUSTOM_TYPE_PREFIX, + getCustomCardEntry, } from "../../../data/lovelace_custom_cards"; +import { HomeAssistant } from "../../../types"; +import { documentationUrl } from "../../../util/documentation-url"; -const coreDocumentationURLBase = "https://www.home-assistant.io/lovelace/"; - -export const getCardDocumentationURL = (type: string): string | undefined => { +export const getCardDocumentationURL = ( + hass: HomeAssistant, + type: string +): string | undefined => { if (type.startsWith(CUSTOM_TYPE_PREFIX)) { return getCustomCardEntry(type)?.documentationURL; } - return `${coreDocumentationURLBase}${type}`; + return `${documentationUrl(hass, "/lovelace/")}${type}`; }; diff --git a/src/panels/lovelace/editor/hui-dialog-save-config.ts b/src/panels/lovelace/editor/hui-dialog-save-config.ts index f056413258..3fd5997ffa 100644 --- a/src/panels/lovelace/editor/hui-dialog-save-config.ts +++ b/src/panels/lovelace/editor/hui-dialog-save-config.ts @@ -1,33 +1,32 @@ import "@material/mwc-button"; import "@material/mwc-icon-button/mwc-icon-button"; +import { mdiHelpCircle } from "@mdi/js"; import { css, CSSResult, customElement, html, + internalProperty, LitElement, property, - internalProperty, TemplateResult, } from "lit-element"; -import { mdiHelpCircle } from "@mdi/js"; import { fireEvent } from "../../../common/dom/fire_event"; +import { computeRTLDirection } from "../../../common/util/compute_rtl"; +import "../../../components/ha-circular-progress"; +import "../../../components/ha-dialog"; +import "../../../components/ha-formfield"; +import "../../../components/ha-svg-icon"; +import "../../../components/ha-switch"; +import "../../../components/ha-yaml-editor"; +import type { HassDialog } from "../../../dialogs/make-dialog-manager"; import { haStyleDialog } from "../../../resources/styles"; import type { HomeAssistant } from "../../../types"; +import { documentationUrl } from "../../../util/documentation-url"; import type { SaveDialogParams } from "./show-save-config-dialog"; -import { computeRTLDirection } from "../../../common/util/compute_rtl"; -import type { HassDialog } from "../../../dialogs/make-dialog-manager"; -import "../../../components/ha-switch"; -import "../../../components/ha-formfield"; -import "../../../components/ha-yaml-editor"; -import "../../../components/ha-svg-icon"; -import "../../../components/ha-dialog"; -import "../../../components/ha-circular-progress"; const EMPTY_CONFIG = { views: [] }; -const coreDocumentationURLBase = "https://www.home-assistant.io/lovelace/"; - @customElement("hui-dialog-save-config") export class HuiSaveConfig extends LitElement implements HassDialog { @property({ attribute: false }) public hass?: HomeAssistant; @@ -68,7 +67,7 @@ export class HuiSaveConfig extends LitElement implements HassDialog { "ui.panel.lovelace.editor.save_config.header" )} diff --git a/src/panels/profile/ha-push-notifications-row.js b/src/panels/profile/ha-push-notifications-row.js index 7f0bbc0af0..528a447298 100644 --- a/src/panels/profile/ha-push-notifications-row.js +++ b/src/panels/profile/ha-push-notifications-row.js @@ -7,6 +7,7 @@ import { isComponentLoaded } from "../../common/config/is_component_loaded"; import { pushSupported } from "../../components/ha-push-notifications-toggle"; import LocalizeMixin from "../../mixins/localize-mixin"; import "../../components/ha-settings-row"; +import { documentationUrl } from "../../util/documentation-url"; /* * @appliesMixin LocalizeMixin @@ -26,7 +27,7 @@ class HaPushNotificationsRow extends LocalizeMixin(PolymerElement) { [[_description(_platformLoaded, _pushSupported)]] [[localize('ui.panel.profile.push_notifications.link_promo')]] { + return `https://${ + hass.config.version.includes("b") ? "rc" : "www" + }.home-assistant.io${path}`; +}; diff --git a/test-mocha/util/generate-documentation-url.spec.ts b/test-mocha/util/generate-documentation-url.spec.ts new file mode 100644 index 0000000000..9e34e61448 --- /dev/null +++ b/test-mocha/util/generate-documentation-url.spec.ts @@ -0,0 +1,19 @@ +import * as assert from "assert"; +import { documentationUrl } from "../../src/util/documentation-url"; + +describe("Generate documentation URL", function () { + it("Generate documentation url for stable", function () { + assert.strictEqual( + // @ts-ignore + documentationUrl({ config: { version: "1.0.0" } }, "/blog"), + "https://www.home-assistant.io/blog" + ); + }); + it("Generate documentation url for rc", function () { + assert.strictEqual( + // @ts-ignore + documentationUrl({ config: { version: "1.0.0b0" } }, "/blog"), + "https://rc.home-assistant.io/blog" + ); + }); +});