mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 05:47:20 +00:00
Check if energy integration is enabled (#11458)
This commit is contained in:
parent
242bad0a29
commit
f04b844223
@ -8,6 +8,7 @@ import "@polymer/paper-tooltip/paper-tooltip";
|
|||||||
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoize from "memoize-one";
|
import memoize from "memoize-one";
|
||||||
|
import { isComponentLoaded } from "../../../../common/config/is_component_loaded";
|
||||||
import { navigate } from "../../../../common/navigate";
|
import { navigate } from "../../../../common/navigate";
|
||||||
import { stringCompare } from "../../../../common/string/compare";
|
import { stringCompare } from "../../../../common/string/compare";
|
||||||
import {
|
import {
|
||||||
@ -183,31 +184,34 @@ export class HaConfigLovelaceDashboards extends LitElement {
|
|||||||
).mode;
|
).mode;
|
||||||
const defaultUrlPath = this.hass.defaultPanel;
|
const defaultUrlPath = this.hass.defaultPanel;
|
||||||
const isDefault = defaultUrlPath === "lovelace";
|
const isDefault = defaultUrlPath === "lovelace";
|
||||||
return [
|
const result: Record<string, any>[] = [
|
||||||
{
|
{
|
||||||
icon: "hass:view-dashboard",
|
icon: "hass:view-dashboard",
|
||||||
title: this.hass.localize("panel.states"),
|
title: this.hass.localize("panel.states"),
|
||||||
default: isDefault,
|
default: isDefault,
|
||||||
sidebar: isDefault,
|
show_in_sidebar: isDefault,
|
||||||
require_admin: false,
|
require_admin: false,
|
||||||
url_path: "lovelace",
|
url_path: "lovelace",
|
||||||
mode: defaultMode,
|
mode: defaultMode,
|
||||||
filename: defaultMode === "yaml" ? "ui-lovelace.yaml" : "",
|
filename: defaultMode === "yaml" ? "ui-lovelace.yaml" : "",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
icon: "hass:lightning-bolt",
|
|
||||||
title: this.hass.localize(`ui.panel.config.dashboard.energy.title`),
|
|
||||||
show_in_sidebar: true,
|
|
||||||
mode: "storage",
|
|
||||||
url_path: "energy",
|
|
||||||
filename: "",
|
|
||||||
},
|
|
||||||
...dashboards.map((dashboard) => ({
|
...dashboards.map((dashboard) => ({
|
||||||
filename: "",
|
filename: "",
|
||||||
...dashboard,
|
...dashboard,
|
||||||
default: defaultUrlPath === dashboard.url_path,
|
default: defaultUrlPath === dashboard.url_path,
|
||||||
})),
|
})),
|
||||||
];
|
];
|
||||||
|
if (isComponentLoaded(this.hass, "energy")) {
|
||||||
|
result.push({
|
||||||
|
icon: "hass:lightning-bolt",
|
||||||
|
title: this.hass.localize(`ui.panel.config.dashboard.energy.title`),
|
||||||
|
show_in_sidebar: true,
|
||||||
|
mode: "storage",
|
||||||
|
url_path: "energy",
|
||||||
|
filename: "",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user