mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 21:37:21 +00:00
Use helper to generate documentation URL (#7012)
This commit is contained in:
parent
9c80776d8c
commit
7d862d6f2a
@ -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 {
|
||||
<p>
|
||||
Check the
|
||||
<a
|
||||
href="https://www.home-assistant.io/integrations/media_source/#local-media"
|
||||
href="${documentationUrl(
|
||||
this.hass,
|
||||
"/integrations/media_source/#local-media"
|
||||
)}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>documentation</a
|
||||
|
@ -20,6 +20,7 @@ import { LocalizeFunc } from "../../common/translations/localize";
|
||||
import "../../components/ha-icon-next";
|
||||
import { domainToName } from "../../data/integration";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { documentationUrl } from "../../util/documentation-url";
|
||||
import { FlowConfig } from "./show-dialog-data-entry-flow";
|
||||
import { configFlowContentStyles } from "./styles";
|
||||
|
||||
@ -122,7 +123,7 @@ class StepFlowPickHandler extends LitElement {
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.integrations.note_about_website_reference"
|
||||
)}<a
|
||||
href="https://www.home-assistant.io/integrations/"
|
||||
href="${documentationUrl(this.hass, "/integrations/")}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>${this.hass.localize(
|
||||
|
@ -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`<a
|
||||
href="https://www.home-assistant.io/integrations/automation/#automation-modes"
|
||||
href="${documentationUrl(
|
||||
this.hass,
|
||||
"/integrations/automation/#automation-modes"
|
||||
)}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>${this.hass.localize(
|
||||
@ -247,7 +251,10 @@ export class HaAutomationEditor extends LitElement {
|
||||
)}
|
||||
</p>
|
||||
<a
|
||||
href="https://home-assistant.io/docs/automation/trigger/"
|
||||
href="${documentationUrl(
|
||||
this.hass,
|
||||
"/docs/automation/trigger/"
|
||||
)}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
@ -276,7 +283,10 @@ export class HaAutomationEditor extends LitElement {
|
||||
)}
|
||||
</p>
|
||||
<a
|
||||
href="https://home-assistant.io/docs/scripts/conditions/"
|
||||
href="${documentationUrl(
|
||||
this.hass,
|
||||
"/docs/scripts/conditions/"
|
||||
)}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
@ -305,7 +315,10 @@ export class HaAutomationEditor extends LitElement {
|
||||
)}
|
||||
</p>
|
||||
<a
|
||||
href="https://home-assistant.io/docs/automation/action/"
|
||||
href="${documentationUrl(
|
||||
this.hass,
|
||||
"/docs/automation/action/"
|
||||
)}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
@ -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`
|
||||
<ha-paper-dialog with-backdrop>
|
||||
<h2>
|
||||
|
@ -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)) {
|
||||
<p>
|
||||
[[localize('ui.panel.config.cloud.register.information4')]]
|
||||
</p><ul>
|
||||
<li><a href="https://home-assistant.io/tos/" target="_blank" rel="noreferrer">[[localize('ui.panel.config.cloud.register.link_terms_conditions')]]</a></li>
|
||||
<li><a href="https://home-assistant.io/privacy/" target="_blank" rel="noreferrer">[[localize('ui.panel.config.cloud.register.link_privacy_policy')]]</a></li>
|
||||
<li><a href="[[_computeDocumentationUrlTos(hass)]]" target="_blank" rel="noreferrer">[[localize('ui.panel.config.cloud.register.link_terms_conditions')]]</a></li>
|
||||
<li><a href="[[_computeDocumentationUrlPrivacy(hass)]]" target="_blank" rel="noreferrer">[[localize('ui.panel.config.cloud.register.link_privacy_policy')]]</a></li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
<div class="warning">
|
||||
[[localize('ui.panel.config.customize.warning.include_sentence')]]
|
||||
<a
|
||||
href="https://www.home-assistant.io/docs/configuration/customizing-devices/#customization-using-the-ui"
|
||||
href="[[_computeDocumentationUrl(hass)]]"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>[[localize('ui.panel.config.customize.warning.include_link')]]</a
|
||||
@ -210,6 +211,13 @@ class HaFormCustomize extends LocalizeMixin(PolymerElement) {
|
||||
);
|
||||
}
|
||||
|
||||
_computeDocumentationUrl(hass) {
|
||||
return documentationUrl(
|
||||
hass,
|
||||
"/docs/configuration/customizing-devices/#customization-using-the-ui"
|
||||
);
|
||||
}
|
||||
|
||||
computeLocalAttributes(localConfig) {
|
||||
if (!localConfig) return [];
|
||||
const localKeys = Object.keys(localConfig);
|
||||
|
@ -12,6 +12,7 @@ import "./integrations-card";
|
||||
import "./system-health-card";
|
||||
import { configSections } from "../ha-panel-config";
|
||||
import "../../../layouts/hass-tabs-subpage";
|
||||
import { documentationUrl } from "../../../util/documentation-url";
|
||||
|
||||
const JS_TYPE = __BUILD__;
|
||||
const JS_VERSION = __VERSION__;
|
||||
@ -42,7 +43,7 @@ class HaConfigInfo extends LitElement {
|
||||
>
|
||||
<div class="about">
|
||||
<a
|
||||
href="https://www.home-assistant.io"
|
||||
href="${documentationUrl(this.hass, "")}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
><img
|
||||
@ -63,7 +64,7 @@ class HaConfigInfo extends LitElement {
|
||||
</p>
|
||||
<p class="develop">
|
||||
<a
|
||||
href="https://www.home-assistant.io/developers/credits/"
|
||||
href="${documentationUrl(this.hass, "/developers/credits/")}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
@ -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 {
|
||||
)}
|
||||
<p>
|
||||
<a
|
||||
href="https://www.home-assistant.io/docs/z-wave/control-panel/"
|
||||
href="${documentationUrl(
|
||||
this.hass,
|
||||
"/docs/z-wave/control-panel/"
|
||||
)}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
@ -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 {
|
||||
<ul>
|
||||
<li>
|
||||
<a
|
||||
href="https://www.home-assistant.io/integrations/#presence-detection"
|
||||
href="${documentationUrl(
|
||||
this.hass,
|
||||
"/integrations/#presence-detection"
|
||||
)}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>${this.hass!.localize(
|
||||
|
@ -25,6 +25,7 @@ import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import "../../../layouts/hass-tabs-subpage-data-table";
|
||||
import { haStyle } from "../../../resources/styles";
|
||||
import { HomeAssistant, Route } from "../../../types";
|
||||
import { documentationUrl } from "../../../util/documentation-url";
|
||||
import { showToast } from "../../../util/toast";
|
||||
import { configSections } from "../ha-panel-config";
|
||||
|
||||
@ -191,7 +192,7 @@ class HaSceneDashboard extends LitElement {
|
||||
${this.hass.localize("ui.panel.config.scene.picker.introduction")}
|
||||
<p>
|
||||
<a
|
||||
href="https://home-assistant.io/docs/scene/editor/"
|
||||
href="${documentationUrl(this.hass, "/docs/scene/editor/")}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
@ -1,46 +1,47 @@
|
||||
import "@material/mwc-fab";
|
||||
import { mdiContentSave } from "@mdi/js";
|
||||
import "@polymer/app-layout/app-header/app-header";
|
||||
import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light";
|
||||
import "@polymer/app-layout/app-toolbar/app-toolbar";
|
||||
import "../../../components/ha-icon-button";
|
||||
import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light";
|
||||
import { PaperListboxElement } from "@polymer/paper-listbox";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
html,
|
||||
internalProperty,
|
||||
LitElement,
|
||||
property,
|
||||
internalProperty,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
import { computeObjectId } from "../../../common/entity/compute_object_id";
|
||||
import { navigate } from "../../../common/navigate";
|
||||
import { slugify } from "../../../common/string/slugify";
|
||||
import { computeRTL } from "../../../common/util/compute_rtl";
|
||||
import "../../../components/ha-card";
|
||||
import "../../../components/ha-icon-button";
|
||||
import "../../../components/ha-icon-input";
|
||||
import { showToast } from "../../../util/toast";
|
||||
import "@material/mwc-fab";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import {
|
||||
Action,
|
||||
deleteScript,
|
||||
getScriptEditorInitData,
|
||||
ScriptConfig,
|
||||
triggerScript,
|
||||
MODES,
|
||||
MODES_MAX,
|
||||
ScriptConfig,
|
||||
triggerScript,
|
||||
} from "../../../data/script";
|
||||
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import "../../../layouts/ha-app-layout";
|
||||
import { haStyle } from "../../../resources/styles";
|
||||
import { HomeAssistant, Route } from "../../../types";
|
||||
import { documentationUrl } from "../../../util/documentation-url";
|
||||
import { showToast } from "../../../util/toast";
|
||||
import "../automation/action/ha-automation-action";
|
||||
import { HaDeviceAction } from "../automation/action/types/ha-automation-action-device_id";
|
||||
import "../ha-config-section";
|
||||
import { configSections } from "../ha-panel-config";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import { mdiContentSave } from "@mdi/js";
|
||||
import { PaperListboxElement } from "@polymer/paper-listbox";
|
||||
import { slugify } from "../../../common/string/slugify";
|
||||
|
||||
export class HaScriptEditor extends LitElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
@ -148,7 +149,10 @@ export class HaScriptEditor extends LitElement {
|
||||
"ui.panel.config.script.editor.modes.description",
|
||||
"documentation_link",
|
||||
html`<a
|
||||
href="https://www.home-assistant.io/integrations/script/#script-modes"
|
||||
href="${documentationUrl(
|
||||
this.hass,
|
||||
"/integrations/script/#script-modes"
|
||||
)}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>${this.hass.localize(
|
||||
@ -197,18 +201,20 @@ export class HaScriptEditor extends LitElement {
|
||||
</div>
|
||||
${this.scriptEntityId
|
||||
? html`
|
||||
<div class="card-actions layout horizontal justified center">
|
||||
<span></span>
|
||||
<mwc-button
|
||||
@click=${this._runScript}
|
||||
title="${this.hass.localize(
|
||||
"ui.panel.config.script.picker.activate_script"
|
||||
)}"
|
||||
?disabled=${this._dirty}
|
||||
<div
|
||||
class="card-actions layout horizontal justified center"
|
||||
>
|
||||
${this.hass.localize("ui.card.script.execute")}
|
||||
</mwc-button>
|
||||
</div>
|
||||
<span></span>
|
||||
<mwc-button
|
||||
@click=${this._runScript}
|
||||
title="${this.hass.localize(
|
||||
"ui.panel.config.script.picker.activate_script"
|
||||
)}"
|
||||
?disabled=${this._dirty}
|
||||
>
|
||||
${this.hass.localize("ui.card.script.execute")}
|
||||
</mwc-button>
|
||||
</div>
|
||||
`
|
||||
: ``}
|
||||
</ha-card>
|
||||
@ -227,7 +233,7 @@ export class HaScriptEditor extends LitElement {
|
||||
)}
|
||||
</p>
|
||||
<a
|
||||
href="https://home-assistant.io/docs/scripts/"
|
||||
href="${documentationUrl(this.hass, "/docs/scripts/")}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
@ -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")}
|
||||
<p>
|
||||
<a
|
||||
href="https://home-assistant.io/docs/scripts/editor/"
|
||||
href="${documentationUrl(this.hass, "/docs/scripts/editor/")}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
@ -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)) {
|
||||
<p>
|
||||
[[localize( 'ui.panel.developer-tools.tabs.events.description' )]]
|
||||
<a
|
||||
href="https://www.home-assistant.io/docs/configuration/events/"
|
||||
href="[[_computeDocumentationUrl(hass)]]"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
@ -149,6 +150,10 @@ class HaPanelDevEvent extends EventsMixin(LocalizeMixin(PolymerElement)) {
|
||||
}
|
||||
}
|
||||
|
||||
_computeDocumentationUrl(hass) {
|
||||
return documentationUrl(hass, "/docs/configuration/events/");
|
||||
}
|
||||
|
||||
_computeValidJSON(parsedJSON) {
|
||||
return parsedJSON !== ERROR_SENTINEL;
|
||||
}
|
||||
|
@ -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 {
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://home-assistant.io/docs/configuration/templating/"
|
||||
href="${documentationUrl(
|
||||
this.hass,
|
||||
"/docs/configuration/templating/"
|
||||
)}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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}`;
|
||||
};
|
||||
|
@ -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"
|
||||
)}<a
|
||||
class="header_button"
|
||||
href=${coreDocumentationURLBase}
|
||||
href=${documentationUrl(this.hass!, "/lovelace/")}
|
||||
title=${this.hass!.localize("ui.panel.lovelace.menu.help")}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
|
@ -53,6 +53,7 @@ import { showVoiceCommandDialog } from "../../dialogs/voice-command-dialog/show-
|
||||
import "../../layouts/ha-app-layout";
|
||||
import { haStyle } from "../../resources/styles";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import { documentationUrl } from "../../util/documentation-url";
|
||||
import { swapView } from "./editor/config-util";
|
||||
import { showEditLovelaceDialog } from "./editor/lovelace-editor/show-edit-lovelace-dialog";
|
||||
import { showEditViewDialog } from "./editor/view-editor/show-edit-view-dialog";
|
||||
@ -136,7 +137,7 @@ class HUIRoot extends LitElement {
|
||||
</mwc-icon-button>
|
||||
</div>
|
||||
<a
|
||||
href="https://www.home-assistant.io/lovelace/"
|
||||
href="${documentationUrl(this.hass, "/lovelace/")}"
|
||||
rel="noreferrer"
|
||||
class="menu-link"
|
||||
target="_blank"
|
||||
@ -266,7 +267,7 @@ class HUIRoot extends LitElement {
|
||||
`
|
||||
: ""}
|
||||
<a
|
||||
href="https://www.home-assistant.io/lovelace/"
|
||||
href="${documentationUrl(this.hass, "/lovelace/")}"
|
||||
rel="noreferrer"
|
||||
class="menu-link"
|
||||
target="_blank"
|
||||
|
@ -1,24 +1,25 @@
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-item/paper-item";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import "../../components/ha-paper-dropdown-menu";
|
||||
import { TemplateResult, html } from "lit-html";
|
||||
import {
|
||||
property,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
internalProperty,
|
||||
LitElement,
|
||||
customElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
CSSResult,
|
||||
css,
|
||||
} from "lit-element";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "../../components/ha-settings-row";
|
||||
import { html, TemplateResult } from "lit-html";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import "../../components/ha-formfield";
|
||||
import "../../components/ha-paper-dropdown-menu";
|
||||
import "../../components/ha-radio";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import type { HaRadio } from "../../components/ha-radio";
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import "../../components/ha-settings-row";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { documentationUrl } from "../../util/documentation-url";
|
||||
|
||||
@customElement("ha-pick-theme-row")
|
||||
export class HaPickThemeRow extends LitElement {
|
||||
@ -45,7 +46,10 @@ export class HaPickThemeRow extends LitElement {
|
||||
? this.hass.localize("ui.panel.profile.themes.error_no_theme")
|
||||
: ""}
|
||||
<a
|
||||
href="https://www.home-assistant.io/integrations/frontend/#defining-themes"
|
||||
href="${documentationUrl(
|
||||
this.hass!,
|
||||
"/integrations/frontend/#defining-themes"
|
||||
)}"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
@ -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) {
|
||||
<span slot="description">
|
||||
[[_description(_platformLoaded, _pushSupported)]]
|
||||
<a
|
||||
href="https://www.home-assistant.io/integrations/html5"
|
||||
href="[[_computeDocumentationUrl(hass)]]"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>[[localize('ui.panel.profile.push_notifications.link_promo')]]</a
|
||||
@ -59,6 +60,10 @@ class HaPushNotificationsRow extends LocalizeMixin(PolymerElement) {
|
||||
};
|
||||
}
|
||||
|
||||
_computeDocumentationUrl(hass) {
|
||||
return documentationUrl(hass, "/integrations/html5");
|
||||
}
|
||||
|
||||
_compPlatformLoaded(hass) {
|
||||
return isComponentLoaded(hass, "notify.html5");
|
||||
}
|
||||
|
7
src/util/documentation-url.ts
Normal file
7
src/util/documentation-url.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { HomeAssistant } from "../types";
|
||||
|
||||
export const documentationUrl = (hass: HomeAssistant, path: string) => {
|
||||
return `https://${
|
||||
hass.config.version.includes("b") ? "rc" : "www"
|
||||
}.home-assistant.io${path}`;
|
||||
};
|
19
test-mocha/util/generate-documentation-url.spec.ts
Normal file
19
test-mocha/util/generate-documentation-url.spec.ts
Normal file
@ -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"
|
||||
);
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user